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.
- clarifai/__init__.py +1 -1
- clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/__pycache__/errors.cpython-310.pyc +0 -0
- clarifai/__pycache__/versions.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/app.cpython-39.pyc +0 -0
- clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
- clarifai/client/cli/__init__.py +0 -0
- clarifai/client/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
- clarifai/client/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
- clarifai/client/cli/base_cli.py +88 -0
- clarifai/client/cli/model_cli.py +29 -0
- clarifai/client/model.py +0 -1
- clarifai/client/model_client.py +22 -24
- clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/export/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/models/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/modules/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/rag/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/dockerfile_template/Dockerfile.cpu.template +31 -0
- clarifai/runners/dockerfile_template/Dockerfile.cuda.template +42 -0
- clarifai/runners/dockerfile_template/Dockerfile.nim +71 -0
- clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/base_typed_model.cpython-39.pyc +0 -0
- clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_run_locally.cpython-310-pytest-7.1.2.pyc +0 -0
- clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
- clarifai/runners/models/model_builder.py +12 -1
- clarifai/runners/models/model_class.py +18 -12
- clarifai/runners/models/model_class_refract.py +80 -0
- clarifai/runners/models/model_upload.py +607 -0
- clarifai/runners/models/temp.py +25 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/buffered_stream.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/buffered_stream.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/buffered_stream.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/constants.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/constants.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/grpc_server.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/grpc_server.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/grpc_server.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/health.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/health.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/health.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/logging.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/logging.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/stream_source.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/stream_source.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
- clarifai/runners/utils/data_handler.py +271 -210
- clarifai/runners/utils/data_handler_refract.py +213 -0
- clarifai/runners/utils/logger.py +0 -0
- clarifai/runners/utils/method_signatures.py +100 -128
- clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/METADATA +15 -15
- clarifai-11.1.7rc2.dist-info/RECORD +237 -0
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/WHEEL +1 -1
- clarifai/cli/__main__.py~ +0 -4
- clarifai/cli/__pycache__/__main__.cpython-310.pyc +0 -0
- clarifai/client/#model_client.py# +0 -430
- clarifai/client/__pycache__/runner.cpython-310.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-310.pyc +0 -0
- clarifai/models/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/_utils.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/build.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/create.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/config.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/inference_parameter.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/output.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/serializer.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/triton_config.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/wrappers.cpython-310.pyc +0 -0
- clarifai/models/model_serving/repo_build/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/repo_build/__pycache__/build.cpython-310.pyc +0 -0
- clarifai/models/model_serving/repo_build/static_files/__pycache__/base_test.cpython-310-pytest-7.2.0.pyc +0 -0
- clarifai/runners/__pycache__/server.cpython-310.pyc +0 -0
- clarifai/runners/dockerfile_template/Dockerfile.debug +0 -11
- clarifai/runners/dockerfile_template/Dockerfile.debug~ +0 -9
- clarifai/runners/models/__pycache__/model_builder.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_types.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/method_signatures.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/serializers.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/helpers.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-310.pyc +0 -0
- clarifai-11.1.7rc1.dist-info/RECORD +0 -205
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/LICENSE +0 -0
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc2.dist-info}/entry_points.txt +0 -0
- {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.
|
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.
|
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 = [
|
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.
|
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.
|
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(
|
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.
|
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.
|
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.
|
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],
|
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,
|
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()
|