clarifai 11.2.4rc1__py3-none-any.whl → 11.2.4rc2__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/runners/models/model_builder.py +40 -40
- clarifai/runners/utils/data_utils.py +14 -12
- clarifai/runners/utils/method_signatures.py +8 -2
- {clarifai-11.2.4rc1.dist-info → clarifai-11.2.4rc2.dist-info}/METADATA +1 -1
- {clarifai-11.2.4rc1.dist-info → clarifai-11.2.4rc2.dist-info}/RECORD +10 -10
- {clarifai-11.2.4rc1.dist-info → clarifai-11.2.4rc2.dist-info}/LICENSE +0 -0
- {clarifai-11.2.4rc1.dist-info → clarifai-11.2.4rc2.dist-info}/WHEEL +0 -0
- {clarifai-11.2.4rc1.dist-info → clarifai-11.2.4rc2.dist-info}/entry_points.txt +0 -0
- {clarifai-11.2.4rc1.dist-info → clarifai-11.2.4rc2.dist-info}/top_level.txt +0 -0
clarifai/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "11.2.
|
1
|
+
__version__ = "11.2.4rc2"
|
@@ -633,55 +633,55 @@ class ModelBuilder:
|
|
633
633
|
concepts = config.get('concepts')
|
634
634
|
logger.info(f"Updated config.yaml with {len(concepts)} concepts.")
|
635
635
|
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
636
|
+
def filled_params_specs_with_inference_params(self, method_signatures: list[resources_pb2.MethodSignature], methods_defaults) -> list[resources_pb2.ModelTypeField]:
|
637
|
+
"""
|
638
|
+
Fills the params_specs with the inference params.
|
639
|
+
"""
|
640
|
+
inference_params = set()
|
641
|
+
for i, method_defaults in enumerate(methods_defaults):
|
642
|
+
for name, default in method_defaults.items():
|
643
|
+
if isinstance(default, data_utils.InputField):
|
644
|
+
if i==0:
|
645
|
+
inference_params.add(name)
|
646
|
+
else:
|
647
|
+
# if field.name not in inference_params then remove from inference_params
|
648
|
+
if name not in inference_params:
|
649
|
+
inference_params.remove(field.name)
|
650
|
+
output=[]
|
651
|
+
for signature in method_signatures:
|
652
|
+
for field in signature.input_fields:
|
653
|
+
if field.name in inference_params:
|
654
|
+
field.path = field.name
|
655
|
+
if field.type == resources_pb2.ModelTypeField.DataType.STR:
|
656
|
+
field.default_value= str(field.default)
|
657
|
+
field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.STRING
|
658
|
+
elif field.type == resources_pb2.ModelTypeField.DataType.INT:
|
659
|
+
field.default_value= int(field.default)
|
660
|
+
field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.NUMBER
|
661
|
+
elif field.type == resources_pb2.ModelTypeField.DataType.FLOAT:
|
662
|
+
field.default_value= float(field.default)
|
663
|
+
field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.NUMBER
|
664
|
+
elif field.type == resources_pb2.ModelTypeField.DataType.BOOL:
|
665
|
+
field.default_value= bool(field.default)
|
666
|
+
field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.BOOLEAN
|
667
|
+
else:
|
668
|
+
field.default_value= field.default
|
669
|
+
field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.STRING
|
670
|
+
output.append(field)
|
671
|
+
return output
|
672
672
|
|
673
673
|
|
674
674
|
def get_model_version_proto(self):
|
675
675
|
signatures = self.get_method_signatures()
|
676
|
-
|
676
|
+
methods_defaults = self.get_methods_defaults()
|
677
677
|
|
678
678
|
model_version_proto = resources_pb2.ModelVersion(
|
679
679
|
pretrained_model_config=resources_pb2.PretrainedModelConfig(),
|
680
680
|
inference_compute_info=self.inference_compute_info,
|
681
681
|
method_signatures=signatures,
|
682
|
-
|
683
|
-
|
684
|
-
|
682
|
+
output_info= resources_pb2.OutputInfo(
|
683
|
+
params_specs=self.filled_params_specs_with_inference_params(signatures, methods_defaults),
|
684
|
+
)
|
685
685
|
)
|
686
686
|
|
687
687
|
|
@@ -115,12 +115,7 @@ class InputField(MessageData):
|
|
115
115
|
# proto.is_param = self.is_param
|
116
116
|
|
117
117
|
if self.default is not None:
|
118
|
-
|
119
|
-
self.default, (int, float)):
|
120
|
-
proto.default = str(self.default)
|
121
|
-
else:
|
122
|
-
import json
|
123
|
-
proto.default = json.dumps(self.default)
|
118
|
+
proto = self.set_default(proto, self.default)
|
124
119
|
|
125
120
|
return proto
|
126
121
|
|
@@ -169,12 +164,19 @@ class InputField(MessageData):
|
|
169
164
|
|
170
165
|
@classmethod
|
171
166
|
def set_default(cls, proto=None, default=None):
|
172
|
-
|
173
|
-
|
174
|
-
proto
|
175
|
-
|
176
|
-
|
177
|
-
|
167
|
+
try:
|
168
|
+
import json
|
169
|
+
if proto is None:
|
170
|
+
proto = InputFieldProto()
|
171
|
+
if default is not None:
|
172
|
+
proto.default = json.dumps(default)
|
173
|
+
return proto
|
174
|
+
except json.JSONDecodeError:
|
175
|
+
if default is not None:
|
176
|
+
proto.default = str(default)
|
177
|
+
return proto
|
178
|
+
except Exception as e:
|
179
|
+
raise ValueError(f"Error setting default value: {e}")
|
178
180
|
|
179
181
|
@classmethod
|
180
182
|
def get_default(cls, proto):
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import collections.abc as abc
|
2
2
|
import inspect
|
3
|
+
import logging
|
3
4
|
import json
|
4
5
|
from collections import namedtuple
|
5
6
|
from typing import Dict, List, Tuple, get_args, get_origin
|
@@ -312,8 +313,13 @@ def deserialize(proto, signatures, inference_params={}, is_output=False):
|
|
312
313
|
kwargs[sig.name] = serializer.deserialize(part.data)
|
313
314
|
elif inference_params_value is not None:
|
314
315
|
kwargs[sig.name] = inference_params_value
|
315
|
-
|
316
|
-
|
316
|
+
elif sig.default and (sig.required is False) and (not is_output):
|
317
|
+
try:
|
318
|
+
kwargs[sig.name] = data_utils.InputField.get_default(sig)
|
319
|
+
except Exception as e:
|
320
|
+
# default is not set, so ignore
|
321
|
+
logging.exception('Default value not set for %s: %s', sig.name, e)
|
322
|
+
pass
|
317
323
|
else:
|
318
324
|
if sig_i == 0:
|
319
325
|
# possible inlined first value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
clarifai/__init__.py,sha256=
|
1
|
+
clarifai/__init__.py,sha256=MifEmQdTShs6F9sPHBKRleuDIhSTAInWoN8okWqMJPs,26
|
2
2
|
clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
clarifai/errors.py,sha256=RwzTajwds51wLD0MVlMC5kcpBnzRpreDLlazPSBZxrg,2605
|
4
4
|
clarifai/versions.py,sha256=jctnczzfGk_S3EnVqb2FjRKfSREkNmvNEwAAa_VoKiQ,222
|
@@ -138,7 +138,7 @@ clarifai/runners/dockerfile_template/Dockerfile.nim,sha256=CSdUAehj3uOwminioLnT5
|
|
138
138
|
clarifai/runners/dockerfile_template/Dockerfile.template,sha256=5cjv7U8PmWa3DB_5B1CqSYh_6GE0E0np52TIAa7EIDE,2312
|
139
139
|
clarifai/runners/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
140
140
|
clarifai/runners/models/base_typed_model.py,sha256=0QCWxch8CcyJSKvE1D4PILd2RSnQZHTmx4DXlQQ6dpo,7856
|
141
|
-
clarifai/runners/models/model_builder.py,sha256=
|
141
|
+
clarifai/runners/models/model_builder.py,sha256=6ezRfKxXYI7jwWUiXdsy2L72Q3dvarqikvQuE5ZraVQ,38849
|
142
142
|
clarifai/runners/models/model_class.py,sha256=j3oyOCmh-XfFg3UhdquMZ-DxrNSlOGnFlQMNT3fNQSI,14920
|
143
143
|
clarifai/runners/models/model_class_refract.py,sha256=HxuozxSW7ag5yWCPxjNwgLArQ6dORhyGXlnpPaZz2-c,3211
|
144
144
|
clarifai/runners/models/model_run_locally.py,sha256=H7FKUBzZ_EPPj1b6P59qbOYr3mUJjJTlD5gavH5e80o,17746
|
@@ -161,10 +161,10 @@ clarifai/runners/utils/const.py,sha256=9qnOC1Bt6SGLQ9XCQEQ6519XhW4gzcztsV1Rgej67
|
|
161
161
|
clarifai/runners/utils/data_handler.py,sha256=b7k6MWYPXSgjrfw6wsDf82xFYa0D7UjYmjE4mw5HzHM,8499
|
162
162
|
clarifai/runners/utils/data_handler_refract.py,sha256=3M-V4hkOoF-9Ix4hE6ocXWiTJPc9dewtu6FMtddd-jQ,6343
|
163
163
|
clarifai/runners/utils/data_types.py,sha256=CtcYoW4EFE1EG6JkcP2rcRast9Eac8hFoYRHHCuwl2w,12432
|
164
|
-
clarifai/runners/utils/data_utils.py,sha256=
|
164
|
+
clarifai/runners/utils/data_utils.py,sha256=BuIxcQOudFEle8V6ZvycrYd-6X0i__EQbXxKKF1n7mA,12911
|
165
165
|
clarifai/runners/utils/loader.py,sha256=Sl0m29RDtMPx2cIiSbbDFtKHQj2ktXQ5CnkvaHi-zDc,8804
|
166
166
|
clarifai/runners/utils/logger.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
167
|
-
clarifai/runners/utils/method_signatures.py,sha256=
|
167
|
+
clarifai/runners/utils/method_signatures.py,sha256=HypEj1EN7pzRPzn-KUu1oOZcKlwfarvYTZXUZ-DEEYQ,18509
|
168
168
|
clarifai/runners/utils/openai_convertor.py,sha256=tFFNkjcdsNi73DfT_JOqdZZAu8fDYQwpbToWcr62OOw,7650
|
169
169
|
clarifai/runners/utils/openai_format.py,sha256=vOrpgqVWmQZGGFANZf0hmR_ksZXsr2-S9WUxvkG5lZs,1980
|
170
170
|
clarifai/runners/utils/serializers.py,sha256=S4sRsOVvH191vAGTRTAAdwLlQwlK4T5QVRDGPptg9nQ,7191
|
@@ -233,9 +233,9 @@ clarifai/workflows/__pycache__/__init__.cpython-39.pyc,sha256=9nA--jULSW7OFrYOcs
|
|
233
233
|
clarifai/workflows/__pycache__/export.cpython-310.pyc,sha256=phEGwi2gAojCUhRTqjZVeTDn7Gk6LCVBeSTjAj4m9iY,2418
|
234
234
|
clarifai/workflows/__pycache__/utils.cpython-310.pyc,sha256=M9_KTM7GOOS5SPrWwAzqHDqyGvgKi3xuSGvyw6MNf-I,1925
|
235
235
|
clarifai/workflows/__pycache__/validate.cpython-310.pyc,sha256=c18Jgp_-CAm8RD_tmUpDCPoqZeexaoWELG0yBzb9rjw,2149
|
236
|
-
clarifai-11.2.
|
237
|
-
clarifai-11.2.
|
238
|
-
clarifai-11.2.
|
239
|
-
clarifai-11.2.
|
240
|
-
clarifai-11.2.
|
241
|
-
clarifai-11.2.
|
236
|
+
clarifai-11.2.4rc2.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
|
237
|
+
clarifai-11.2.4rc2.dist-info/METADATA,sha256=2NQ4ajyyei0MMGHMBZimPeO7qxqoxMfMvlq1TaNzLRI,22453
|
238
|
+
clarifai-11.2.4rc2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
239
|
+
clarifai-11.2.4rc2.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
|
240
|
+
clarifai-11.2.4rc2.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
|
241
|
+
clarifai-11.2.4rc2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|