clarifai 11.3.0rc3__py3-none-any.whl → 11.4.1__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/client/auth/helper.py +2 -8
- clarifai/runners/utils/data_utils.py +163 -11
- clarifai/runners/utils/method_signatures.py +2 -2
- {clarifai-11.3.0rc3.dist-info → clarifai-11.4.1.dist-info}/METADATA +3 -3
- {clarifai-11.3.0rc3.dist-info → clarifai-11.4.1.dist-info}/RECORD +10 -10
- {clarifai-11.3.0rc3.dist-info → clarifai-11.4.1.dist-info}/WHEEL +0 -0
- {clarifai-11.3.0rc3.dist-info → clarifai-11.4.1.dist-info}/entry_points.txt +0 -0
- {clarifai-11.3.0rc3.dist-info → clarifai-11.4.1.dist-info}/licenses/LICENSE +0 -0
- {clarifai-11.3.0rc3.dist-info → clarifai-11.4.1.dist-info}/top_level.txt +0 -0
clarifai/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "11.
|
1
|
+
__version__ = "11.4.1"
|
clarifai/client/auth/helper.py
CHANGED
@@ -151,13 +151,8 @@ class ClarifaiAuthHelper:
|
|
151
151
|
try:
|
152
152
|
if st.query_params:
|
153
153
|
auth.add_streamlit_query_params(st.query_params)
|
154
|
-
elif "query_params" in st.session_state:
|
155
|
-
auth.add_streamlit_query_params(st.session_state.query_params)
|
156
154
|
else:
|
157
|
-
st.
|
158
|
-
"Either initialize the 'ClarifaiAuthHelper' in the main app.py file or add 'query_params' to the session state in the main app.py file."
|
159
|
-
)
|
160
|
-
st.stop()
|
155
|
+
auth.add_streamlit_query_params(st.session_state)
|
161
156
|
except Exception as e:
|
162
157
|
st.error(e)
|
163
158
|
st.stop()
|
@@ -209,8 +204,7 @@ class ClarifaiAuthHelper:
|
|
209
204
|
base: as 'base' in query_params.
|
210
205
|
|
211
206
|
Args:
|
212
|
-
query_params: the streamlit.
|
213
|
-
back to using env vars.
|
207
|
+
query_params: the streamlit.query_params response or streamlit.session_state.
|
214
208
|
"""
|
215
209
|
|
216
210
|
if query_params == "": # empty response from streamlit
|
@@ -1,9 +1,11 @@
|
|
1
|
+
import math
|
2
|
+
import operator
|
1
3
|
from io import BytesIO
|
2
4
|
from typing import List
|
3
5
|
|
4
6
|
from clarifai_grpc.grpc.api import resources_pb2
|
5
7
|
from clarifai_grpc.grpc.api.resources_pb2 import ModelTypeEnumOption, ModelTypeRangeInfo
|
6
|
-
from clarifai_grpc.grpc.api.resources_pb2 import ModelTypeField as
|
8
|
+
from clarifai_grpc.grpc.api.resources_pb2 import ModelTypeField as ParamProto
|
7
9
|
from PIL import Image
|
8
10
|
|
9
11
|
from clarifai.runners.utils.data_types import MessageData
|
@@ -57,7 +59,7 @@ def is_openai_chat_format(messages):
|
|
57
59
|
return True
|
58
60
|
|
59
61
|
|
60
|
-
class
|
62
|
+
class Param(MessageData):
|
61
63
|
"""A field that can be used to store input data."""
|
62
64
|
|
63
65
|
def __init__(
|
@@ -67,14 +69,14 @@ class InputField(MessageData):
|
|
67
69
|
min_value=None,
|
68
70
|
max_value=None,
|
69
71
|
choices=None,
|
70
|
-
|
72
|
+
is_param=True,
|
71
73
|
):
|
72
74
|
self.default = default
|
73
75
|
self.description = description
|
74
76
|
self.min_value = min_value
|
75
77
|
self.max_value = max_value
|
76
78
|
self.choices = choices
|
77
|
-
|
79
|
+
self.is_param = is_param
|
78
80
|
|
79
81
|
def __repr__(self) -> str:
|
80
82
|
attrs = []
|
@@ -88,12 +90,162 @@ class InputField(MessageData):
|
|
88
90
|
attrs.append(f"max_value={self.max_value!r}")
|
89
91
|
if self.choices is not None:
|
90
92
|
attrs.append(f"choices={self.choices!r}")
|
91
|
-
|
92
|
-
return f"
|
93
|
+
attrs.append(f"is_param={self.is_param!r}")
|
94
|
+
return f"Param({', '.join(attrs)})"
|
93
95
|
|
94
|
-
|
96
|
+
# All *explicit* conversions
|
97
|
+
def __int__(self):
|
98
|
+
return int(self.default)
|
99
|
+
|
100
|
+
def __float__(self):
|
101
|
+
return float(self.default)
|
102
|
+
|
103
|
+
def __str__(self):
|
104
|
+
return str(self.default)
|
105
|
+
|
106
|
+
def __bool__(self):
|
107
|
+
return bool(self.default)
|
108
|
+
|
109
|
+
def __index__(self):
|
110
|
+
return int(self.default) # for slicing
|
111
|
+
|
112
|
+
# sequence / mapping protocol delegation
|
113
|
+
def __len__(self):
|
114
|
+
return len(self.default)
|
115
|
+
|
116
|
+
def __iter__(self):
|
117
|
+
return iter(self.default)
|
118
|
+
|
119
|
+
def __reversed__(self):
|
120
|
+
return reversed(self.default)
|
121
|
+
|
122
|
+
def __contains__(self, item):
|
123
|
+
return item in self.default
|
124
|
+
|
125
|
+
def __getitem__(self, key):
|
126
|
+
return self.default[key]
|
127
|
+
|
128
|
+
def __setitem__(self, k, v):
|
129
|
+
self.default[k] = v
|
130
|
+
|
131
|
+
def __delitem__(self, k):
|
132
|
+
del self.default[k]
|
133
|
+
|
134
|
+
def __hash__(self):
|
135
|
+
return hash(self.default)
|
136
|
+
|
137
|
+
def __call__(self, *args, **kwargs):
|
138
|
+
return self.default(*args, **kwargs)
|
139
|
+
|
140
|
+
# Comparison operators
|
141
|
+
def __eq__(self, other):
|
142
|
+
return self.default == other
|
143
|
+
|
144
|
+
def __lt__(self, other):
|
145
|
+
return self.default < other
|
146
|
+
|
147
|
+
def __le__(self, other):
|
148
|
+
return self.default <= other
|
149
|
+
|
150
|
+
def __gt__(self, other):
|
151
|
+
return self.default > other
|
152
|
+
|
153
|
+
def __ge__(self, other):
|
154
|
+
return self.default >= other
|
155
|
+
|
156
|
+
# Arithmetic operators – # arithmetic & bitwise operators – auto-generated
|
157
|
+
_arith_ops = {
|
158
|
+
"__add__": operator.add,
|
159
|
+
"__sub__": operator.sub,
|
160
|
+
"__mul__": operator.mul,
|
161
|
+
"__truediv__": operator.truediv,
|
162
|
+
"__floordiv__": operator.floordiv,
|
163
|
+
"__mod__": operator.mod,
|
164
|
+
"__pow__": operator.pow,
|
165
|
+
"__and__": operator.and_,
|
166
|
+
"__or__": operator.or_,
|
167
|
+
"__xor__": operator.xor,
|
168
|
+
"__lshift__": operator.lshift,
|
169
|
+
"__rshift__": operator.rshift,
|
170
|
+
}
|
171
|
+
|
172
|
+
# Create both left- and right-hand versions of each operator
|
173
|
+
for _name, _op in _arith_ops.items():
|
174
|
+
|
175
|
+
def _make(op):
|
176
|
+
def _f(self, other, *, _op=op): # default arg binds op
|
177
|
+
return _op(self.default, other)
|
178
|
+
|
179
|
+
return _f
|
180
|
+
|
181
|
+
locals()[_name] = _make(_op)
|
182
|
+
locals()["__r" + _name[2:]] = _make(lambda x, y, _op=_op: _op(y, x))
|
183
|
+
del _name, _op, _make
|
184
|
+
|
185
|
+
# In-place operators
|
186
|
+
_inplace_ops = {
|
187
|
+
"__iadd__": operator.iadd,
|
188
|
+
"__isub__": operator.isub,
|
189
|
+
"__imul__": operator.imul,
|
190
|
+
"__itruediv__": operator.itruediv,
|
191
|
+
"__ifloordiv__": operator.ifloordiv,
|
192
|
+
"__imod__": operator.imod,
|
193
|
+
"__ipow__": operator.ipow,
|
194
|
+
"__ilshift__": operator.ilshift,
|
195
|
+
"__irshift__": operator.irshift,
|
196
|
+
"__iand__": operator.iand,
|
197
|
+
"__ixor__": operator.ixor,
|
198
|
+
"__ior__": operator.ior,
|
199
|
+
}
|
200
|
+
|
201
|
+
for _name, _op in _inplace_ops.items():
|
202
|
+
|
203
|
+
def _make_inplace(op):
|
204
|
+
def _f(self, other, *, _op=op):
|
205
|
+
self.default = _op(self.default, other)
|
206
|
+
return self
|
207
|
+
|
208
|
+
return _f
|
209
|
+
|
210
|
+
locals()[_name] = _make_inplace(_op)
|
211
|
+
del _name, _op, _make_inplace
|
212
|
+
|
213
|
+
# Formatting and other conversions
|
214
|
+
def __format__(self, format_spec):
|
215
|
+
return format(self.default, format_spec)
|
216
|
+
|
217
|
+
def __bytes__(self):
|
218
|
+
return bytes(self.default)
|
219
|
+
|
220
|
+
def __complex__(self):
|
221
|
+
return complex(self.default)
|
222
|
+
|
223
|
+
def __round__(self, ndigits=None):
|
224
|
+
return round(self.default, ndigits)
|
225
|
+
|
226
|
+
def __trunc__(self):
|
227
|
+
return math.trunc(self.default)
|
228
|
+
|
229
|
+
def __floor__(self):
|
230
|
+
return math.floor(self.default)
|
231
|
+
|
232
|
+
def __ceil__(self):
|
233
|
+
return math.ceil(self.default)
|
234
|
+
|
235
|
+
# Attribute access delegation – anything we did *not* define above
|
236
|
+
# will automatically be looked up on the wrapped default value.
|
237
|
+
# Attribute access delegation
|
238
|
+
def __getattr__(self, item):
|
239
|
+
return getattr(self.default, item)
|
240
|
+
|
241
|
+
def __get__(self, instance, owner):
|
242
|
+
if instance is None:
|
243
|
+
return self
|
244
|
+
return self.default
|
245
|
+
|
246
|
+
def to_proto(self, proto=None) -> ParamProto:
|
95
247
|
if proto is None:
|
96
|
-
proto =
|
248
|
+
proto = ParamProto()
|
97
249
|
if self.description is not None:
|
98
250
|
proto.description = self.description
|
99
251
|
|
@@ -111,7 +263,7 @@ class InputField(MessageData):
|
|
111
263
|
if self.max_value is not None:
|
112
264
|
range_info.max = float(self.max_value)
|
113
265
|
proto.model_type_range_info.CopyFrom(range_info)
|
114
|
-
|
266
|
+
proto.is_param = self.is_param
|
115
267
|
|
116
268
|
if self.default is not None:
|
117
269
|
proto = self.set_default(proto, self.default)
|
@@ -162,7 +314,7 @@ class InputField(MessageData):
|
|
162
314
|
min_value=min_value,
|
163
315
|
max_value=max_value,
|
164
316
|
choices=choices,
|
165
|
-
|
317
|
+
is_param=proto.is_param,
|
166
318
|
)
|
167
319
|
|
168
320
|
@classmethod
|
@@ -171,7 +323,7 @@ class InputField(MessageData):
|
|
171
323
|
import json
|
172
324
|
|
173
325
|
if proto is None:
|
174
|
-
proto =
|
326
|
+
proto = ParamProto()
|
175
327
|
if default is not None:
|
176
328
|
proto.default = json.dumps(default)
|
177
329
|
return proto
|
@@ -161,10 +161,10 @@ def build_variable_signature(name, annotation, default=inspect.Parameter.empty,
|
|
161
161
|
if not is_output:
|
162
162
|
sig.required = default is inspect.Parameter.empty
|
163
163
|
if not sig.required:
|
164
|
-
if isinstance(default, data_utils.
|
164
|
+
if isinstance(default, data_utils.Param):
|
165
165
|
sig = default.to_proto(sig)
|
166
166
|
else:
|
167
|
-
sig = data_utils.
|
167
|
+
sig = data_utils.Param.set_default(sig, default)
|
168
168
|
|
169
169
|
_fill_signature_type(sig, tp)
|
170
170
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: clarifai
|
3
|
-
Version: 11.
|
3
|
+
Version: 11.4.1
|
4
4
|
Home-page: https://github.com/Clarifai/clarifai-python
|
5
5
|
Author: Clarifai
|
6
6
|
Author-email: support@clarifai.com
|
@@ -19,8 +19,8 @@ Classifier: Operating System :: OS Independent
|
|
19
19
|
Requires-Python: >=3.8
|
20
20
|
Description-Content-Type: text/markdown
|
21
21
|
License-File: LICENSE
|
22
|
-
Requires-Dist: clarifai-grpc>=11.3.
|
23
|
-
Requires-Dist: clarifai-protocol>=0.0.
|
22
|
+
Requires-Dist: clarifai-grpc>=11.3.4
|
23
|
+
Requires-Dist: clarifai-protocol>=0.0.23
|
24
24
|
Requires-Dist: numpy>=1.22.0
|
25
25
|
Requires-Dist: tqdm>=4.65.0
|
26
26
|
Requires-Dist: rich>=13.4.2
|
@@ -1,4 +1,4 @@
|
|
1
|
-
clarifai/__init__.py,sha256=
|
1
|
+
clarifai/__init__.py,sha256=2En8s3vAF6UtYOsy9zZZ7y0N_jqRJPbqJoD5cTWTleo,23
|
2
2
|
clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
clarifai/errors.py,sha256=GXa6D4v_L404J83jnRNFPH7s-1V9lk7w6Ws99f1g-AY,2772
|
4
4
|
clarifai/versions.py,sha256=ecSuEB_nOL2XSoYHDw2n23XUbm_KPOGjudMXmQrGdS8,224
|
@@ -27,7 +27,7 @@ clarifai/client/search.py,sha256=Z-8PJJYAw5IlF0ac1M0GCz6TRQhouI8fwZryOJZkP1Q,156
|
|
27
27
|
clarifai/client/user.py,sha256=Ey-sqW5dFE_3HLC-E4mHncKth-nQ1j_q6Tp80TMOfwI,18358
|
28
28
|
clarifai/client/workflow.py,sha256=55fO5IYhER-kHL1FwP3IiWjWEZYNG3jpe7vBRIi_PJQ,13381
|
29
29
|
clarifai/client/auth/__init__.py,sha256=7EwR0NrozkAUwpUnCsqXvE_p0wqx_SelXlSpKShKJK0,136
|
30
|
-
clarifai/client/auth/helper.py,sha256=
|
30
|
+
clarifai/client/auth/helper.py,sha256=10Ow_eCgWMKURYW2aT46GLEax-GYoEUHwbcdt7tX6jg,15199
|
31
31
|
clarifai/client/auth/register.py,sha256=pyY-Kg_64WpN6rXz1SyEzfqL14BS4yADtuYMxLJ4jx4,554
|
32
32
|
clarifai/client/auth/stub.py,sha256=pU4FYeghooCBZmCRyNTdDfJaVe4WyeRBqE3xVwfmMTY,5388
|
33
33
|
clarifai/constants/base.py,sha256=ogmFSZYoF0YhGjHg5aiOc3MLqPr_poKAls6xaD0_C3U,89
|
@@ -75,9 +75,9 @@ clarifai/runners/models/model_servicer.py,sha256=rRd_fNEXwqiBSzTUtPI2r07EBdcCPd8
|
|
75
75
|
clarifai/runners/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
76
76
|
clarifai/runners/utils/code_script.py,sha256=CeIhBYX-vB17ThQy5x4ObQoehYo3w4Nms5Qh1p5pTDk,10382
|
77
77
|
clarifai/runners/utils/const.py,sha256=czPVidLCb2S1HbA8YbNkoDYphqr0-W7oeqrkf8LsTc4,1068
|
78
|
-
clarifai/runners/utils/data_utils.py,sha256=
|
78
|
+
clarifai/runners/utils/data_utils.py,sha256=e6aJdQf0NlOynoMUuJD8F5lHnmKMfO9JNRFClBVrovM,18836
|
79
79
|
clarifai/runners/utils/loader.py,sha256=KliTvPgi_7SkN3PhOeDFDATRaKFbqRU4CxOq6Gkh9T0,10070
|
80
|
-
clarifai/runners/utils/method_signatures.py,sha256=
|
80
|
+
clarifai/runners/utils/method_signatures.py,sha256=sZdHr1F9MmJSLCOR64PzVU1yZO4EqXNm5aCbh8KbBcY,19222
|
81
81
|
clarifai/runners/utils/openai_convertor.py,sha256=QhbytqGU856gEFggaamZy01hhCwjiWz8ju48iubvbeI,5074
|
82
82
|
clarifai/runners/utils/serializers.py,sha256=pI7GqMTC0T3Lu_X8v8TO4RiplO-gC_49Ns37jYwsPtg,7908
|
83
83
|
clarifai/runners/utils/url_fetcher.py,sha256=Segkvi-ktPa3-koOpUu8DNZeWOaK6G82Ya9b7_oIKwo,1778
|
@@ -101,9 +101,9 @@ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
101
101
|
clarifai/workflows/export.py,sha256=Oq3RVNKvv1iH46U6oIjXa-MXWJ4sTlXr_NSfwoxr3H4,2149
|
102
102
|
clarifai/workflows/utils.py,sha256=ESL3INcouNcLKCh-nMpfXX-YbtCzX7tz7hT57_RGQ3M,2079
|
103
103
|
clarifai/workflows/validate.py,sha256=UhmukyHkfxiMFrPPeBdUTiCOHQT5-shqivlBYEyKTlU,2931
|
104
|
-
clarifai-11.
|
105
|
-
clarifai-11.
|
106
|
-
clarifai-11.
|
107
|
-
clarifai-11.
|
108
|
-
clarifai-11.
|
109
|
-
clarifai-11.
|
104
|
+
clarifai-11.4.1.dist-info/licenses/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
|
105
|
+
clarifai-11.4.1.dist-info/METADATA,sha256=0lxRlfleSaiJMEgPr4Brf-H9UNWbdVz9b1stmpRPuwo,22426
|
106
|
+
clarifai-11.4.1.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
107
|
+
clarifai-11.4.1.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
|
108
|
+
clarifai-11.4.1.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
|
109
|
+
clarifai-11.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|