fxn 0.0.32__py3-none-any.whl → 0.0.34__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.
- fxn/graph/client.py +4 -6
- fxn/libs/macos/Function.dylib +0 -0
- fxn/libs/windows/Function.dll +0 -0
- fxn/services/prediction/service.py +33 -20
- fxn/services/predictor.py +1 -1
- fxn/version.py +1 -1
- {fxn-0.0.32.dist-info → fxn-0.0.34.dist-info}/METADATA +1 -1
- {fxn-0.0.32.dist-info → fxn-0.0.34.dist-info}/RECORD +12 -12
- {fxn-0.0.32.dist-info → fxn-0.0.34.dist-info}/LICENSE +0 -0
- {fxn-0.0.32.dist-info → fxn-0.0.34.dist-info}/WHEEL +0 -0
- {fxn-0.0.32.dist-info → fxn-0.0.34.dist-info}/entry_points.txt +0 -0
- {fxn-0.0.32.dist-info → fxn-0.0.34.dist-info}/top_level.txt +0 -0
fxn/graph/client.py
CHANGED
@@ -32,14 +32,12 @@ class GraphClient:
|
|
32
32
|
json={ "query": query, "variables": variables },
|
33
33
|
headers={ "Authorization": f"Bearer {self.access_key}" } if self.access_key else { }
|
34
34
|
)
|
35
|
-
# Check
|
36
35
|
payload = response.json()
|
36
|
+
# Check error
|
37
37
|
try:
|
38
38
|
response.raise_for_status()
|
39
|
-
except:
|
40
|
-
|
41
|
-
|
42
|
-
if "errors" in payload:
|
43
|
-
raise RuntimeError(payload["errors"][0]["message"])
|
39
|
+
except Exception as ex:
|
40
|
+
error = payload["errors"][0]["message"] if "errors" in payload else str(ex)
|
41
|
+
raise RuntimeError(error)
|
44
42
|
# Return
|
45
43
|
return payload["data"]
|
fxn/libs/macos/Function.dylib
CHANGED
Binary file
|
fxn/libs/windows/Function.dll
CHANGED
Binary file
|
@@ -44,7 +44,9 @@ class PredictionService:
|
|
44
44
|
inputs: Dict[str, Union[ndarray, str, float, int, bool, List, Dict[str, Any], Path, Image.Image, Value]] = None,
|
45
45
|
raw_outputs: bool=False,
|
46
46
|
return_binary_path: bool=True,
|
47
|
-
data_url_limit: int=None
|
47
|
+
data_url_limit: int=None,
|
48
|
+
client_id: str=None,
|
49
|
+
configuration_id: str=None
|
48
50
|
) -> Prediction:
|
49
51
|
"""
|
50
52
|
Create a prediction.
|
@@ -55,6 +57,8 @@ class PredictionService:
|
|
55
57
|
raw_outputs (bool): Skip converting output values into Pythonic types. This only applies to `CLOUD` predictions.
|
56
58
|
return_binary_path (bool): Write binary values to file and return a `Path` instead of returning `BytesIO` instance.
|
57
59
|
data_url_limit (int): Return a data URL if a given output value is smaller than this size in bytes. This only applies to `CLOUD` predictions.
|
60
|
+
client_id (str): Function client identifier. Specify this to override the current client identifier.
|
61
|
+
configuration_id (str): Configuration identifier. Specify this to override the current client configuration identifier.
|
58
62
|
|
59
63
|
Returns:
|
60
64
|
Prediction: Created prediction.
|
@@ -66,13 +70,13 @@ class PredictionService:
|
|
66
70
|
key = uuid4().hex
|
67
71
|
values = { name: self.to_value(value, name, key=key).model_dump(mode="json") for name, value in inputs.items() } if inputs is not None else { }
|
68
72
|
# Query
|
69
|
-
response = post(
|
73
|
+
response = post(
|
70
74
|
f"{self.client.api_url}/predict/{tag}?rawOutputs=true&dataUrlLimit={data_url_limit}",
|
71
75
|
json=values,
|
72
76
|
headers={
|
73
77
|
"Authorization": f"Bearer {self.client.access_key}",
|
74
|
-
"fxn-client": self.__get_client_id(),
|
75
|
-
"fxn-configuration-token": self.
|
78
|
+
"fxn-client": client_id if client_id is not None else self.__get_client_id(),
|
79
|
+
"fxn-configuration-token": configuration_id if configuration_id is not None else self.__get_configuration_id()
|
76
80
|
}
|
77
81
|
)
|
78
82
|
# Check
|
@@ -84,12 +88,14 @@ class PredictionService:
|
|
84
88
|
raise RuntimeError(error)
|
85
89
|
# Parse prediction
|
86
90
|
prediction = self.__parse_prediction(prediction, raw_outputs=raw_outputs, return_binary_path=return_binary_path)
|
91
|
+
# Check edge prediction
|
92
|
+
if prediction.type != PredictorType.Edge or raw_outputs:
|
93
|
+
return prediction
|
94
|
+
# Load edge predictor
|
95
|
+
predictor = self.__load(prediction)
|
96
|
+
self.__cache[tag] = predictor
|
87
97
|
# Create edge prediction
|
88
|
-
|
89
|
-
predictor = self.__load(prediction)
|
90
|
-
self.__cache[tag] = predictor
|
91
|
-
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs) if inputs is not None else prediction
|
92
|
-
# Return
|
98
|
+
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs) if inputs is not None else prediction
|
93
99
|
return prediction
|
94
100
|
|
95
101
|
async def stream (
|
@@ -100,6 +106,8 @@ class PredictionService:
|
|
100
106
|
raw_outputs: bool=False,
|
101
107
|
return_binary_path: bool=True,
|
102
108
|
data_url_limit: int=None,
|
109
|
+
client_id: str=None,
|
110
|
+
configuration_id: str=None
|
103
111
|
) -> AsyncIterator[Prediction]:
|
104
112
|
"""
|
105
113
|
Create a streaming prediction.
|
@@ -112,6 +120,8 @@ class PredictionService:
|
|
112
120
|
raw_outputs (bool): Skip converting output values into Pythonic types. This only applies to `CLOUD` predictions.
|
113
121
|
return_binary_path (bool): Write binary values to file and return a `Path` instead of returning `BytesIO` instance.
|
114
122
|
data_url_limit (int): Return a data URL if a given output value is smaller than this size in bytes. This only applies to `CLOUD` predictions.
|
123
|
+
client_id (str): Function client identifier. Specify this to override the current client identifier.
|
124
|
+
configuration_id (str): Configuration identifier. Specify this to override the current client configuration identifier.
|
115
125
|
|
116
126
|
Returns:
|
117
127
|
Prediction: Created prediction.
|
@@ -122,14 +132,14 @@ class PredictionService:
|
|
122
132
|
return
|
123
133
|
# Serialize inputs
|
124
134
|
key = uuid4().hex
|
125
|
-
values = { name: self.to_value(value, name, key=key).model_dump(mode="json") for name, value in inputs.items() }
|
135
|
+
values = { name: self.to_value(value, name, key=key).model_dump(mode="json") for name, value in inputs.items() }
|
126
136
|
# Request
|
127
137
|
url = f"{self.client.api_url}/predict/{tag}?stream=true&rawOutputs=true&dataUrlLimit={data_url_limit}"
|
128
138
|
headers = {
|
129
139
|
"Content-Type": "application/json",
|
130
140
|
"Authorization": f"Bearer {self.client.access_key}",
|
131
|
-
"fxn-client": self.__get_client_id(),
|
132
|
-
"fxn-configuration-token": self.
|
141
|
+
"fxn-client": client_id if client_id is not None else self.__get_client_id(),
|
142
|
+
"fxn-configuration-token": configuration_id if configuration_id is not None else self.__get_configuration_id()
|
133
143
|
}
|
134
144
|
async with ClientSession(headers=headers) as session:
|
135
145
|
async with session.post(url, data=dumps(values)) as response:
|
@@ -143,12 +153,15 @@ class PredictionService:
|
|
143
153
|
raise RuntimeError(error)
|
144
154
|
# Parse prediction
|
145
155
|
prediction = self.__parse_prediction(prediction, raw_outputs=raw_outputs, return_binary_path=return_binary_path)
|
146
|
-
#
|
147
|
-
if prediction.type
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
156
|
+
# Check edge prediction
|
157
|
+
if prediction.type != PredictorType.Edge or raw_outputs:
|
158
|
+
yield prediction
|
159
|
+
continue
|
160
|
+
# Load edge predictor
|
161
|
+
predictor = self.__load(prediction)
|
162
|
+
self.__cache[tag] = predictor
|
163
|
+
# Create prediction
|
164
|
+
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs) if inputs is not None else prediction
|
152
165
|
yield prediction
|
153
166
|
|
154
167
|
def to_object (
|
@@ -303,14 +316,14 @@ class PredictionService:
|
|
303
316
|
return f"windows:{machine()}"
|
304
317
|
raise RuntimeError(f"Function cannot make predictions on the {id} platform")
|
305
318
|
|
306
|
-
def
|
319
|
+
def __get_configuration_id (self) -> Optional[str]:
|
307
320
|
# Check
|
308
321
|
if not self.__fxnc:
|
309
322
|
return None
|
310
323
|
# Get
|
311
324
|
buffer = create_string_buffer(2048)
|
312
325
|
status = self.__fxnc.FXNConfigurationGetUniqueID(buffer, len(buffer))
|
313
|
-
assert status.value == FXNStatus.OK, f"Failed to create prediction configuration
|
326
|
+
assert status.value == FXNStatus.OK, f"Failed to create prediction configuration identifier with status: {status.value}"
|
314
327
|
uid = buffer.value.decode("utf-8")
|
315
328
|
# Return
|
316
329
|
return uid
|
fxn/services/predictor.py
CHANGED
fxn/version.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
fxn/__init__.py,sha256=tWk0-aCNHX_yCS-Dg90pYnniNka9MWFoNMk6xY7u4nI,157
|
2
2
|
fxn/function.py,sha256=H2oviHGWfal2O7d386R8BZDMUZYdfOuMB7OijiPKo54,1632
|
3
3
|
fxn/magic.py,sha256=PQmXhO9EvJ5EZylioV-6gsCvqhVRYscKBSOBoN4VhTk,1041
|
4
|
-
fxn/version.py,sha256=
|
4
|
+
fxn/version.py,sha256=dDB8U8vJA_k2rzwbLOd_LdkqkLdWLH3ol5jiNfrM-zQ,95
|
5
5
|
fxn/cli/__init__.py,sha256=gwMG0euV0qCe_vSvJLqBd6VWoQ99T-y4xQXeA4m4Wf0,1492
|
6
6
|
fxn/cli/auth.py,sha256=MpHxhqPjGY92TmaTh3o58i868Cv-6Xgf13Si1NFluMg,1677
|
7
7
|
fxn/cli/env.py,sha256=shqoP4tUiXdOoil73oiUYpqGeVcR119HPYFKgnoF894,1553
|
@@ -9,21 +9,21 @@ fxn/cli/misc.py,sha256=J3WgNjrxRzm-_iKC3Cp0o4VHeBYBQ1ta_t2-ozD9roo,662
|
|
9
9
|
fxn/cli/predict.py,sha256=Q6oni_YScpBKRM1CuLK5jDAOORSfTcY6NLS5lC4a3jA,3259
|
10
10
|
fxn/cli/predictors.py,sha256=Fg1yFvPgVnLORnQ3K_EWnGYw_lpkjTOA2l4W2wbXr08,4310
|
11
11
|
fxn/graph/__init__.py,sha256=rJIDBhYg5jcrWO4hT4-CpwPq6dSgmLTEHCfUYTLpVaI,103
|
12
|
-
fxn/graph/client.py,sha256=
|
12
|
+
fxn/graph/client.py,sha256=WCNsebcuwIlP9W5k_8AQCpxOCcy7cpbengfu2rIkGmc,1192
|
13
13
|
fxn/libs/__init__.py,sha256=c_q01PLV3Mi-qV0_HVbNRHOI2TIUr_cDIJHvCASsYZk,71
|
14
14
|
fxn/libs/linux/__init__.py,sha256=c_q01PLV3Mi-qV0_HVbNRHOI2TIUr_cDIJHvCASsYZk,71
|
15
|
-
fxn/libs/macos/Function.dylib,sha256=
|
15
|
+
fxn/libs/macos/Function.dylib,sha256=RLI17yfKPZqIeItXAnijg87mYGrgK5EvdccVKh23I6E,562176
|
16
16
|
fxn/libs/macos/__init__.py,sha256=c_q01PLV3Mi-qV0_HVbNRHOI2TIUr_cDIJHvCASsYZk,71
|
17
|
-
fxn/libs/windows/Function.dll,sha256=
|
17
|
+
fxn/libs/windows/Function.dll,sha256=rYXuzHUjoHpNqDvyVkLPdjot1ID9-MUqBP_CKATCMxw,426496
|
18
18
|
fxn/libs/windows/__init__.py,sha256=c_q01PLV3Mi-qV0_HVbNRHOI2TIUr_cDIJHvCASsYZk,71
|
19
19
|
fxn/services/__init__.py,sha256=OTBRL_wH94hc_scZgRd42VrJQfldNLjv4APN4YaWBAw,366
|
20
20
|
fxn/services/environment.py,sha256=-K84dJhlQ_R13CPCqBMngdxSPP2jsgtNc_wBYx6dxjU,3716
|
21
|
-
fxn/services/predictor.py,sha256=
|
21
|
+
fxn/services/predictor.py,sha256=2thCKP6N6e7T-nXMoWPoDGGkYV2h4_BxrhXeHJoBP5M,7877
|
22
22
|
fxn/services/storage.py,sha256=MY4in8XXVHDIpp8f928PFdujwegESb6m1zzop6d-z58,5517
|
23
23
|
fxn/services/user.py,sha256=z7mencF-muknruaUuoleu6JoL-QsPJcrJ6ONT_6U7fk,1219
|
24
24
|
fxn/services/prediction/__init__.py,sha256=TPox_z58SRjIvziCt1UnLNN1O23n_iF6HcmI0p9hwpQ,129
|
25
25
|
fxn/services/prediction/fxnc.py,sha256=VIqEBCWl725NhuPek3t6GLOSWfva_faLxGOIDyKwa8A,12739
|
26
|
-
fxn/services/prediction/service.py,sha256=
|
26
|
+
fxn/services/prediction/service.py,sha256=s0ztU5bA6dY1ya5vgUiOnVz2z31UUjc4OvdawC0TijU,23142
|
27
27
|
fxn/types/__init__.py,sha256=jHLpQnvUKGQujVPK3li1rIkANBBvw6l_EznzIsfoD88,438
|
28
28
|
fxn/types/dtype.py,sha256=YpTnIG-yzrQwda27GzfGZcel-zF3gOMMoHhcWD915BY,617
|
29
29
|
fxn/types/environment.py,sha256=FbmfGjSb5yYMT9IyDj8zNUpsoP3RbzqM6tK8gn2TfDs,394
|
@@ -34,9 +34,9 @@ fxn/types/storage.py,sha256=AtVKR3CtHzvSWLiJS_bbUyIA2Of_IKZVeL5_1PqqrQ0,228
|
|
34
34
|
fxn/types/tag.py,sha256=hWzSDCo8VjRHjS5ZLuFi3xVo8cuCNaNeULQ2mHEuwzM,707
|
35
35
|
fxn/types/user.py,sha256=_hc1YQh0WydniAurywA70EDs4VCY5rnGRYSiRc97Ab0,150
|
36
36
|
fxn/types/value.py,sha256=_Euyb3ffydKV1Q68Mf2G9mz7gKD5NzFap-aX1NEuNuY,767
|
37
|
-
fxn-0.0.
|
38
|
-
fxn-0.0.
|
39
|
-
fxn-0.0.
|
40
|
-
fxn-0.0.
|
41
|
-
fxn-0.0.
|
42
|
-
fxn-0.0.
|
37
|
+
fxn-0.0.34.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
38
|
+
fxn-0.0.34.dist-info/METADATA,sha256=FThpoXq7uHtOeEDBbe3jFx3k7r7wlweunFGW-C0MciY,16309
|
39
|
+
fxn-0.0.34.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
40
|
+
fxn-0.0.34.dist-info/entry_points.txt,sha256=O_AwD5dYaeB-YT1F9hPAPuDYCkw_W0tdNGYbc5RVR2k,45
|
41
|
+
fxn-0.0.34.dist-info/top_level.txt,sha256=1ULIEGrnMlhId8nYAkjmRn9g3KEFuHKboq193SEKQkA,4
|
42
|
+
fxn-0.0.34.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|