clarifai 11.1.7rc1__py3-none-any.whl → 11.1.7rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. clarifai/__init__.py +1 -1
  2. clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
  3. clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
  4. clarifai/__pycache__/errors.cpython-310.pyc +0 -0
  5. clarifai/__pycache__/versions.cpython-310.pyc +0 -0
  6. clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  7. clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
  8. clarifai/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  9. clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  10. clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
  11. clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  12. clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  13. clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
  14. clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
  15. clarifai/client/__pycache__/__init__.cpython-39.pyc +0 -0
  16. clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
  17. clarifai/client/__pycache__/app.cpython-39.pyc +0 -0
  18. clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
  19. clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  20. clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
  21. clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
  22. clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
  23. clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
  24. clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
  25. clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
  26. clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
  27. clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
  28. clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
  29. clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
  30. clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  31. clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
  32. clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
  33. clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
  34. clarifai/client/cli/__init__.py +0 -0
  35. clarifai/client/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  36. clarifai/client/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  37. clarifai/client/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  38. clarifai/client/cli/base_cli.py +88 -0
  39. clarifai/client/cli/model_cli.py +29 -0
  40. clarifai/client/model.py +0 -1
  41. clarifai/client/model_client.py +22 -24
  42. clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
  43. clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
  44. clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
  45. clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
  46. clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
  47. clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
  48. clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
  49. clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
  50. clarifai/datasets/__pycache__/__init__.cpython-39.pyc +0 -0
  51. clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
  52. clarifai/datasets/export/__pycache__/__init__.cpython-39.pyc +0 -0
  53. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
  54. clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
  55. clarifai/datasets/upload/__pycache__/__init__.cpython-39.pyc +0 -0
  56. clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
  57. clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
  58. clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
  59. clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
  60. clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
  61. clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
  62. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
  63. clarifai/models/__pycache__/__init__.cpython-39.pyc +0 -0
  64. clarifai/modules/__pycache__/__init__.cpython-39.pyc +0 -0
  65. clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
  66. clarifai/rag/__pycache__/__init__.cpython-39.pyc +0 -0
  67. clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
  68. clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
  69. clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
  70. clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  71. clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
  72. clarifai/runners/dockerfile_template/Dockerfile.cpu.template +31 -0
  73. clarifai/runners/dockerfile_template/Dockerfile.cuda.template +42 -0
  74. clarifai/runners/dockerfile_template/Dockerfile.nim +71 -0
  75. clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
  76. clarifai/runners/models/__pycache__/__init__.cpython-39.pyc +0 -0
  77. clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
  78. clarifai/runners/models/__pycache__/base_typed_model.cpython-39.pyc +0 -0
  79. clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  80. clarifai/runners/models/__pycache__/model_run_locally.cpython-310-pytest-7.1.2.pyc +0 -0
  81. clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
  82. clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
  83. clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
  84. clarifai/runners/models/model_builder.py +12 -1
  85. clarifai/runners/models/model_class.py +18 -12
  86. clarifai/runners/models/model_class_refract.py +80 -0
  87. clarifai/runners/models/model_upload.py +607 -0
  88. clarifai/runners/models/temp.py +25 -0
  89. clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  90. clarifai/runners/utils/__pycache__/__init__.cpython-38.pyc +0 -0
  91. clarifai/runners/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  92. clarifai/runners/utils/__pycache__/buffered_stream.cpython-310.pyc +0 -0
  93. clarifai/runners/utils/__pycache__/buffered_stream.cpython-38.pyc +0 -0
  94. clarifai/runners/utils/__pycache__/buffered_stream.cpython-39.pyc +0 -0
  95. clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
  96. clarifai/runners/utils/__pycache__/constants.cpython-310.pyc +0 -0
  97. clarifai/runners/utils/__pycache__/constants.cpython-38.pyc +0 -0
  98. clarifai/runners/utils/__pycache__/constants.cpython-39.pyc +0 -0
  99. clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
  100. clarifai/runners/utils/__pycache__/data_handler.cpython-38.pyc +0 -0
  101. clarifai/runners/utils/__pycache__/data_handler.cpython-39.pyc +0 -0
  102. clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
  103. clarifai/runners/utils/__pycache__/data_utils.cpython-38.pyc +0 -0
  104. clarifai/runners/utils/__pycache__/data_utils.cpython-39.pyc +0 -0
  105. clarifai/runners/utils/__pycache__/grpc_server.cpython-310.pyc +0 -0
  106. clarifai/runners/utils/__pycache__/grpc_server.cpython-38.pyc +0 -0
  107. clarifai/runners/utils/__pycache__/grpc_server.cpython-39.pyc +0 -0
  108. clarifai/runners/utils/__pycache__/health.cpython-310.pyc +0 -0
  109. clarifai/runners/utils/__pycache__/health.cpython-38.pyc +0 -0
  110. clarifai/runners/utils/__pycache__/health.cpython-39.pyc +0 -0
  111. clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
  112. clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
  113. clarifai/runners/utils/__pycache__/logging.cpython-38.pyc +0 -0
  114. clarifai/runners/utils/__pycache__/logging.cpython-39.pyc +0 -0
  115. clarifai/runners/utils/__pycache__/stream_source.cpython-310.pyc +0 -0
  116. clarifai/runners/utils/__pycache__/stream_source.cpython-39.pyc +0 -0
  117. clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
  118. clarifai/runners/utils/__pycache__/url_fetcher.cpython-38.pyc +0 -0
  119. clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
  120. clarifai/runners/utils/data_handler.py +271 -210
  121. clarifai/runners/utils/data_handler_refract.py +213 -0
  122. clarifai/runners/utils/logger.py +0 -0
  123. clarifai/runners/utils/method_signatures.py +100 -128
  124. clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
  125. clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
  126. clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  127. clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  128. clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
  129. clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
  130. clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
  131. clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
  132. clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
  133. clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
  134. clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
  135. clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
  136. clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
  137. clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
  138. clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
  139. clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
  140. {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/METADATA +15 -15
  141. clarifai-11.1.7rc2.dist-info/RECORD +237 -0
  142. {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/WHEEL +1 -1
  143. clarifai/cli/__main__.py~ +0 -4
  144. clarifai/cli/__pycache__/__main__.cpython-310.pyc +0 -0
  145. clarifai/client/#model_client.py# +0 -430
  146. clarifai/client/__pycache__/runner.cpython-310.pyc +0 -0
  147. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-310.pyc +0 -0
  148. clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-310.pyc +0 -0
  149. clarifai/models/__pycache__/__init__.cpython-310.pyc +0 -0
  150. clarifai/models/model_serving/__pycache__/__init__.cpython-310.pyc +0 -0
  151. clarifai/models/model_serving/__pycache__/constants.cpython-310.pyc +0 -0
  152. clarifai/models/model_serving/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  153. clarifai/models/model_serving/cli/__pycache__/_utils.cpython-310.pyc +0 -0
  154. clarifai/models/model_serving/cli/__pycache__/base.cpython-310.pyc +0 -0
  155. clarifai/models/model_serving/cli/__pycache__/build.cpython-310.pyc +0 -0
  156. clarifai/models/model_serving/cli/__pycache__/create.cpython-310.pyc +0 -0
  157. clarifai/models/model_serving/model_config/__pycache__/__init__.cpython-310.pyc +0 -0
  158. clarifai/models/model_serving/model_config/__pycache__/base.cpython-310.pyc +0 -0
  159. clarifai/models/model_serving/model_config/__pycache__/config.cpython-310.pyc +0 -0
  160. clarifai/models/model_serving/model_config/__pycache__/inference_parameter.cpython-310.pyc +0 -0
  161. clarifai/models/model_serving/model_config/__pycache__/output.cpython-310.pyc +0 -0
  162. clarifai/models/model_serving/model_config/triton/__pycache__/__init__.cpython-310.pyc +0 -0
  163. clarifai/models/model_serving/model_config/triton/__pycache__/serializer.cpython-310.pyc +0 -0
  164. clarifai/models/model_serving/model_config/triton/__pycache__/triton_config.cpython-310.pyc +0 -0
  165. clarifai/models/model_serving/model_config/triton/__pycache__/wrappers.cpython-310.pyc +0 -0
  166. clarifai/models/model_serving/repo_build/__pycache__/__init__.cpython-310.pyc +0 -0
  167. clarifai/models/model_serving/repo_build/__pycache__/build.cpython-310.pyc +0 -0
  168. clarifai/models/model_serving/repo_build/static_files/__pycache__/base_test.cpython-310-pytest-7.2.0.pyc +0 -0
  169. clarifai/runners/__pycache__/server.cpython-310.pyc +0 -0
  170. clarifai/runners/dockerfile_template/Dockerfile.debug +0 -11
  171. clarifai/runners/dockerfile_template/Dockerfile.debug~ +0 -9
  172. clarifai/runners/models/__pycache__/model_builder.cpython-310.pyc +0 -0
  173. clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc +0 -0
  174. clarifai/runners/utils/__pycache__/data_types.cpython-310.pyc +0 -0
  175. clarifai/runners/utils/__pycache__/method_signatures.cpython-310.pyc +0 -0
  176. clarifai/runners/utils/__pycache__/serializers.cpython-310.pyc +0 -0
  177. clarifai/utils/evaluation/__pycache__/__init__.cpython-310.pyc +0 -0
  178. clarifai/utils/evaluation/__pycache__/helpers.cpython-310.pyc +0 -0
  179. clarifai/utils/evaluation/__pycache__/main.cpython-310.pyc +0 -0
  180. clarifai-11.1.7rc1.dist-info/RECORD +0 -205
  181. {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/LICENSE +0 -0
  182. {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/entry_points.txt +0 -0
  183. {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/top_level.txt +0 -0
@@ -94,15 +94,17 @@ class ModelClass(ABC):
94
94
  method_info = method._cf_method_info
95
95
  signature = method_info.signature
96
96
  python_param_types = method_info.python_param_types
97
- inputs = self._convert_input_protos_to_python(request.inputs, signature.inputs,
97
+ inputs = self._convert_input_protos_to_python(request.inputs, signature.input_fields,
98
98
  python_param_types)
99
99
  if len(inputs) == 1:
100
100
  inputs = inputs[0]
101
101
  output = method(**inputs)
102
- outputs.append(self._convert_output_to_proto(output, signature.outputs))
102
+ outputs.append(self._convert_output_to_proto(output, signature.output_fields))
103
103
  else:
104
104
  outputs = self._batch_predict(method, inputs)
105
- outputs = [self._convert_output_to_proto(output, signature.outputs) for output in outputs]
105
+ outputs = [
106
+ self._convert_output_to_proto(output, signature.output_fields) for output in outputs
107
+ ]
106
108
 
107
109
  return service_pb2.MultiOutputResponse(
108
110
  outputs=outputs, status=status_pb2.Status(code=status_code_pb2.SUCCESS))
@@ -126,20 +128,21 @@ class ModelClass(ABC):
126
128
  signature = method_info.signature
127
129
  python_param_types = method_info.python_param_types
128
130
 
129
- inputs = self._convert_input_protos_to_python(request.inputs, signature.inputs,
131
+ inputs = self._convert_input_protos_to_python(request.inputs, signature.input_fields,
130
132
  python_param_types)
131
133
  if len(inputs) == 1:
132
134
  inputs = inputs[0]
133
135
  for output in method(**inputs):
134
136
  resp = service_pb2.MultiOutputResponse()
135
- self._convert_output_to_proto(output, signature.outputs, proto=resp.outputs.add())
137
+ self._convert_output_to_proto(output, signature.output_fields, proto=resp.outputs.add())
136
138
  resp.status.code = status_code_pb2.SUCCESS
137
139
  yield resp
138
140
  else:
139
141
  for outputs in self._batch_generate(method, inputs):
140
142
  resp = service_pb2.MultiOutputResponse()
141
143
  for output in outputs:
142
- self._convert_output_to_proto(output, signature.outputs, proto=resp.outputs.add())
144
+ self._convert_output_to_proto(
145
+ output, signature.output_fields, proto=resp.outputs.add())
143
146
  resp.status.code = status_code_pb2.SUCCESS
144
147
  yield resp
145
148
  except Exception as e:
@@ -166,13 +169,13 @@ class ModelClass(ABC):
166
169
  python_param_types = method_info.python_param_types
167
170
 
168
171
  # find the streaming vars in the signature
169
- stream_sig = get_stream_from_signature(signature.inputs)
172
+ stream_sig = get_stream_from_signature(signature.input_fields)
170
173
  if stream_sig is None:
171
174
  raise ValueError("Streaming method must have a Stream input")
172
175
  stream_argname = stream_sig.name
173
176
 
174
177
  # convert all inputs for the first request, including the first stream value
175
- inputs = self._convert_input_protos_to_python(request.inputs, signature.inputs,
178
+ inputs = self._convert_input_protos_to_python(request.inputs, signature.input_fields,
176
179
  python_param_types)
177
180
  kwargs = inputs[0]
178
181
 
@@ -184,7 +187,7 @@ class ModelClass(ABC):
184
187
  yield first_item
185
188
  # subsequent streaming items contain only the streaming input
186
189
  for request in request_iterator:
187
- item = self._convert_input_protos_to_python(request.inputs, stream_sig,
190
+ item = self._convert_input_protos_to_python(request.inputs, [stream_sig],
188
191
  python_param_types)
189
192
  item = item[0][stream_argname]
190
193
  yield item
@@ -194,7 +197,7 @@ class ModelClass(ABC):
194
197
 
195
198
  for output in method(**kwargs):
196
199
  resp = service_pb2.MultiOutputResponse()
197
- self._convert_output_to_proto(output, signature.outputs, proto=resp.outputs.add())
200
+ self._convert_output_to_proto(output, signature.output_fields, proto=resp.outputs.add())
198
201
  resp.status.code = status_code_pb2.SUCCESS
199
202
  yield resp
200
203
  except Exception as e:
@@ -206,7 +209,8 @@ class ModelClass(ABC):
206
209
  details=str(e),
207
210
  stack_trace=traceback.format_exc().split('\n')))
208
211
 
209
- def _convert_input_protos_to_python(self, inputs: List[resources_pb2.Input], variables_signature,
212
+ def _convert_input_protos_to_python(self, inputs: List[resources_pb2.Input],
213
+ variables_signature: List[resources_pb2.ModelTypeField],
210
214
  python_param_types) -> List[Dict[str, Any]]:
211
215
  result = []
212
216
  for input in inputs:
@@ -219,7 +223,9 @@ class ModelClass(ABC):
219
223
  result.append(kwargs)
220
224
  return result
221
225
 
222
- def _convert_output_to_proto(self, output: Any, variables_signature,
226
+ def _convert_output_to_proto(self,
227
+ output: Any,
228
+ variables_signature: List[resources_pb2.ModelTypeField],
223
229
  proto=None) -> resources_pb2.Output:
224
230
  if proto is None:
225
231
  proto = resources_pb2.Output()
@@ -0,0 +1,80 @@
1
+ import inspect
2
+ from abc import ABC, abstractmethod
3
+ from concurrent.futures import ThreadPoolExecutor
4
+ from typing import Any, Dict, Iterator, List, get_type_hints
5
+
6
+ from clarifai_grpc.grpc.api import resources_pb2, service_pb2
7
+
8
+ from clarifai.runners.utils.data_handler import Output, kwargs_to_proto, proto_to_kwargs
9
+
10
+
11
+ class ModelClass(ABC):
12
+
13
+ @abstractmethod
14
+ def load_model(self):
15
+ raise NotImplementedError("load_model() not implemented")
16
+
17
+ @abstractmethod
18
+ def predict(self, *args, **kwargs) -> Output:
19
+ raise NotImplementedError("predict() not implemented")
20
+
21
+ @abstractmethod
22
+ def generate(self, *args, **kwargs) -> Iterator[Output]:
23
+ raise NotImplementedError("generate() not implemented")
24
+
25
+ @abstractmethod
26
+ def stream(self, *args, **kwargs) -> Iterator[Output]:
27
+ raise NotImplementedError("stream() not implemented")
28
+
29
+ def batch_predict(self, inputs: List[Dict[str, Any]]) -> List[Output]:
30
+ with ThreadPoolExecutor() as executor:
31
+ return list(executor.map(lambda x: self.predict(**x), inputs))
32
+
33
+ def _process_request(self, request, process_func, is_stream=False):
34
+ inputs = self._convert_proto_to_python(request.inputs)
35
+ if len(inputs) == 1:
36
+ result = process_func(**inputs[0])
37
+ if is_stream:
38
+ return (self._convert_output_to_proto(output) for output in result)
39
+ else:
40
+ return [self._convert_output_to_proto(result)]
41
+ else:
42
+ results = self.batch_predict(inputs) if not is_stream else []
43
+ return [self._convert_output_to_proto(output) for output in results]
44
+
45
+ def predict_wrapper(
46
+ self, request: service_pb2.PostModelOutputsRequest) -> service_pb2.MultiOutputResponse:
47
+ outputs = self._process_request(request, self.predict)
48
+ return service_pb2.MultiOutputResponse(outputs=outputs)
49
+
50
+ def generate_wrapper(self, request: service_pb2.PostModelOutputsRequest
51
+ ) -> Iterator[service_pb2.MultiOutputResponse]:
52
+ outputs = self._process_request(request, self.generate, is_stream=True)
53
+ for output in outputs:
54
+ yield service_pb2.MultiOutputResponse(outputs=[output])
55
+
56
+ def stream_wrapper(self, requests: Iterator[service_pb2.PostModelOutputsRequest]
57
+ ) -> Iterator[service_pb2.MultiOutputResponse]:
58
+ for request in requests:
59
+ outputs = self._process_request(request, self.stream, is_stream=True)
60
+ yield service_pb2.MultiOutputResponse(outputs=outputs)
61
+
62
+ def _convert_proto_to_python(self, inputs: List[resources_pb2.Input]) -> List[Dict[str, Any]]:
63
+ get_type_hints(self.predict)
64
+ required_params = [
65
+ name for name, param in inspect.signature(self.predict).parameters.items()
66
+ if param.default == inspect.Parameter.empty
67
+ ]
68
+ kwargs_list = []
69
+ for input_proto in inputs:
70
+ kwargs = proto_to_kwargs(input_proto.data)
71
+ missing = [name for name in required_params if name not in kwargs]
72
+ if missing:
73
+ raise ValueError(f"Missing required parameters: {missing}")
74
+ kwargs_list.append(kwargs)
75
+ return kwargs_list
76
+
77
+ def _convert_output_to_proto(self, output: Any) -> resources_pb2.Output:
78
+ if isinstance(output, Output):
79
+ return output.to_proto()
80
+ return kwargs_to_proto(**output).outputs.add()