fxn 0.0.37__tar.gz → 0.0.38__tar.gz
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-0.0.37 → fxn-0.0.38}/PKG-INFO +15 -9
- {fxn-0.0.37 → fxn-0.0.38}/README.md +14 -8
- {fxn-0.0.37 → fxn-0.0.38}/fxn/__init__.py +1 -1
- fxn-0.0.38/fxn/lib/linux/arm64/libFunction.so +0 -0
- fxn-0.0.38/fxn/lib/linux/x86_64/libFunction.so +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/lib/macos/arm64/Function.dylib +0 -0
- fxn-0.0.38/fxn/lib/macos/x86_64/Function.dylib +0 -0
- fxn-0.0.38/fxn/lib/windows/arm64/Function.dll +0 -0
- fxn-0.0.38/fxn/lib/windows/x86_64/Function.dll +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/services/prediction.py +29 -30
- {fxn-0.0.37 → fxn-0.0.38}/fxn/services/predictor.py +1 -1
- {fxn-0.0.37 → fxn-0.0.38}/fxn/types/__init__.py +1 -4
- {fxn-0.0.37 → fxn-0.0.38}/fxn/types/predictor.py +4 -4
- fxn-0.0.37/fxn/types/profile.py → fxn-0.0.38/fxn/types/user.py +6 -1
- {fxn-0.0.37 → fxn-0.0.38}/fxn/version.py +1 -1
- {fxn-0.0.37 → fxn-0.0.38}/fxn.egg-info/PKG-INFO +15 -9
- {fxn-0.0.37 → fxn-0.0.38}/fxn.egg-info/SOURCES.txt +2 -4
- fxn-0.0.37/fxn/lib/macos/x86_64/Function.dylib +0 -0
- fxn-0.0.37/fxn/lib/windows/arm64/Function.dll +0 -0
- fxn-0.0.37/fxn/lib/windows/x86_64/Function.dll +0 -0
- fxn-0.0.37/fxn/types/environment.py +0 -17
- fxn-0.0.37/fxn/types/storage.py +0 -14
- fxn-0.0.37/fxn/types/tag.py +0 -28
- fxn-0.0.37/fxn/types/user.py +0 -11
- {fxn-0.0.37 → fxn-0.0.38}/LICENSE +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/api/__init__.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/api/client.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/__init__.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/configuration.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/dtype.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/fxnc.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/map.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/prediction.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/predictor.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/status.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/stream.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/value.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/c/version.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/cli/__init__.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/cli/auth.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/cli/env.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/cli/misc.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/cli/predict.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/cli/predictors.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/function.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/lib/__init__.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/services/__init__.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/services/user.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/types/dtype.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn/types/prediction.py +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn.egg-info/dependency_links.txt +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn.egg-info/entry_points.txt +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn.egg-info/requires.txt +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/fxn.egg-info/top_level.txt +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/pyproject.toml +0 -0
- {fxn-0.0.37 → fxn-0.0.38}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fxn
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.38
|
4
4
|
Summary: Run prediction functions locally in Python. Register at https://fxn.ai.
|
5
5
|
Author-email: "NatML Inc." <hi@fxn.ai>
|
6
6
|
License: Apache License
|
@@ -239,20 +239,24 @@ $ pip install --upgrade fxn
|
|
239
239
|
```
|
240
240
|
|
241
241
|
> [!NOTE]
|
242
|
-
> Function requires Python 3.
|
242
|
+
> Function requires Python 3.10+
|
243
243
|
|
244
244
|
## Retrieving your Access Key
|
245
|
-
Head over to [fxn.ai](https://fxn.ai) to create an account by logging in. Once you do, generate an access key:
|
245
|
+
Head over to [fxn.ai](https://www.fxn.ai/account/developer) to create an account by logging in. Once you do, generate an access key:
|
246
246
|
|
247
247
|

|
248
248
|
|
249
249
|
## Making a Prediction
|
250
|
-
|
250
|
+
First, create a Function client, specifying your access key:
|
251
251
|
```py
|
252
252
|
from fxn import Function
|
253
253
|
|
254
254
|
# Create the Function client
|
255
255
|
fxn = Function(access_key="<Function access key>")
|
256
|
+
```
|
257
|
+
|
258
|
+
Then make a prediction:
|
259
|
+
```py
|
256
260
|
# Create a prediction
|
257
261
|
prediction = fxn.predictions.create(
|
258
262
|
tag="@fxn/greeting",
|
@@ -264,16 +268,18 @@ print(prediction.results[0])
|
|
264
268
|
|
265
269
|
> [!TIP]
|
266
270
|
> Explore public predictors [on Function](https://fxn.ai/explore) or [create your own](https://fxn.ai/waitlist).
|
267
|
-
r
|
268
|
-
## Using the Function CLI
|
269
|
-
Open up a terminal and run the following command:
|
270
271
|
|
272
|
+
## Using the Function CLI
|
273
|
+
Open up a terminal and login to the Function CLI:
|
271
274
|
```sh
|
272
275
|
# Login to Function
|
273
|
-
fxn auth login <ACCESS KEY>
|
276
|
+
$ fxn auth login <ACCESS KEY>
|
277
|
+
```
|
274
278
|
|
279
|
+
Then make a prediction:
|
280
|
+
```sh
|
275
281
|
# Make a prediction using the Function CLI
|
276
|
-
fxn predict @fxn/greeting --name Peter
|
282
|
+
$ fxn predict @fxn/greeting --name Peter
|
277
283
|
```
|
278
284
|
|
279
285
|
___
|
@@ -14,20 +14,24 @@ $ pip install --upgrade fxn
|
|
14
14
|
```
|
15
15
|
|
16
16
|
> [!NOTE]
|
17
|
-
> Function requires Python 3.
|
17
|
+
> Function requires Python 3.10+
|
18
18
|
|
19
19
|
## Retrieving your Access Key
|
20
|
-
Head over to [fxn.ai](https://fxn.ai) to create an account by logging in. Once you do, generate an access key:
|
20
|
+
Head over to [fxn.ai](https://www.fxn.ai/account/developer) to create an account by logging in. Once you do, generate an access key:
|
21
21
|
|
22
22
|

|
23
23
|
|
24
24
|
## Making a Prediction
|
25
|
-
|
25
|
+
First, create a Function client, specifying your access key:
|
26
26
|
```py
|
27
27
|
from fxn import Function
|
28
28
|
|
29
29
|
# Create the Function client
|
30
30
|
fxn = Function(access_key="<Function access key>")
|
31
|
+
```
|
32
|
+
|
33
|
+
Then make a prediction:
|
34
|
+
```py
|
31
35
|
# Create a prediction
|
32
36
|
prediction = fxn.predictions.create(
|
33
37
|
tag="@fxn/greeting",
|
@@ -39,16 +43,18 @@ print(prediction.results[0])
|
|
39
43
|
|
40
44
|
> [!TIP]
|
41
45
|
> Explore public predictors [on Function](https://fxn.ai/explore) or [create your own](https://fxn.ai/waitlist).
|
42
|
-
r
|
43
|
-
## Using the Function CLI
|
44
|
-
Open up a terminal and run the following command:
|
45
46
|
|
47
|
+
## Using the Function CLI
|
48
|
+
Open up a terminal and login to the Function CLI:
|
46
49
|
```sh
|
47
50
|
# Login to Function
|
48
|
-
fxn auth login <ACCESS KEY>
|
51
|
+
$ fxn auth login <ACCESS KEY>
|
52
|
+
```
|
49
53
|
|
54
|
+
Then make a prediction:
|
55
|
+
```sh
|
50
56
|
# Make a prediction using the Function CLI
|
51
|
-
fxn predict @fxn/greeting --name Peter
|
57
|
+
$ fxn predict @fxn/greeting --name Peter
|
52
58
|
```
|
53
59
|
|
54
60
|
___
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -17,6 +17,7 @@ from PIL import Image
|
|
17
17
|
from platform import machine, system
|
18
18
|
from pydantic import BaseModel
|
19
19
|
from requests import get, post
|
20
|
+
from tempfile import gettempdir
|
20
21
|
from typing import Any, AsyncIterator, Dict, List, Optional, Union
|
21
22
|
from urllib.parse import urlparse
|
22
23
|
|
@@ -35,7 +36,7 @@ class PredictionService:
|
|
35
36
|
self,
|
36
37
|
tag: str,
|
37
38
|
*,
|
38
|
-
inputs: Optional[Dict[str,
|
39
|
+
inputs: Optional[Dict[str, ndarray | str | float | int | bool | List[Any] | Dict[str, Any] | Path | Image.Image]] = None,
|
39
40
|
acceleration: Acceleration=Acceleration.Default,
|
40
41
|
client_id: str=None,
|
41
42
|
configuration_id: str=None
|
@@ -58,7 +59,7 @@ class PredictionService:
|
|
58
59
|
return self.__predict(tag=tag, predictor=self.__cache[tag], inputs=inputs)
|
59
60
|
# Query
|
60
61
|
response = post(
|
61
|
-
f"{self.client.api_url}/predict/{tag}
|
62
|
+
f"{self.client.api_url}/predict/{tag}",
|
62
63
|
json={ },
|
63
64
|
headers={
|
64
65
|
"Authorization": f"Bearer {self.client.access_key}",
|
@@ -124,35 +125,27 @@ class PredictionService:
|
|
124
125
|
prediction = self.__predict(tag=tag, predictor=predictor, inputs=inputs)
|
125
126
|
# Yield
|
126
127
|
yield prediction
|
127
|
-
|
128
|
+
|
128
129
|
@classmethod
|
129
130
|
def __load_fxnc (self) -> Optional[CDLL]:
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
if
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
elif os == "Windows":
|
140
|
-
package = f"fxn.lib.windows.{machine()}"
|
141
|
-
resource = f"Function.dll"
|
142
|
-
else:
|
143
|
-
return None
|
144
|
-
# Load
|
131
|
+
os = system().lower()
|
132
|
+
os = "macos" if os == "darwin" else os
|
133
|
+
arch = machine()
|
134
|
+
arch = "arm64" if arch == "aarch64" else arch
|
135
|
+
arch = "x86_64" if arch == "x64" else arch
|
136
|
+
package = f"fxn.lib.{os}.{arch}"
|
137
|
+
resource = "libFunction.so"
|
138
|
+
resource = "Function.dylib" if os == "macos" else resource
|
139
|
+
resource = "Function.dll" if os == "windows" else resource
|
145
140
|
with resources.path(package, resource) as fxnc_path:
|
146
141
|
return load_fxnc(fxnc_path)
|
147
142
|
|
148
143
|
def __get_client_id (self) -> str:
|
149
144
|
# Fallback if fxnc failed to load
|
150
145
|
if not self.__fxnc:
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
"Windows": f"windows-{machine()}"
|
155
|
-
}[system()]
|
146
|
+
os = system().lower()
|
147
|
+
os = "macos" if os == "darwin" else os
|
148
|
+
return f"{os}-{machine()}"
|
156
149
|
# Get
|
157
150
|
buffer = create_string_buffer(64)
|
158
151
|
status = self.__fxnc.FXNConfigurationGetClientID(buffer, len(buffer))
|
@@ -383,7 +376,7 @@ class PredictionService:
|
|
383
376
|
raise RuntimeError(f"Failed to convert Function value to Python value because Function value has unsupported type: {dtype}")
|
384
377
|
|
385
378
|
def __get_resource_path (self, resource: PredictionResource) -> Path:
|
386
|
-
cache_dir =
|
379
|
+
cache_dir = self.__class__.__get_resource_dir() / ".fxn" / "cache"
|
387
380
|
cache_dir.mkdir(exist_ok=True)
|
388
381
|
res_name = Path(urlparse(resource.url).path).name
|
389
382
|
res_path = cache_dir / res_name
|
@@ -394,7 +387,18 @@ class PredictionService:
|
|
394
387
|
with open(res_path, "wb") as f:
|
395
388
|
f.write(req.content)
|
396
389
|
return res_path
|
397
|
-
|
390
|
+
|
391
|
+
@classmethod
|
392
|
+
def __get_resource_dir (cls) -> Path:
|
393
|
+
try:
|
394
|
+
check = Path.home() / ".fxntest"
|
395
|
+
with open(check, "w") as f:
|
396
|
+
f.write("fxn")
|
397
|
+
check.unlink()
|
398
|
+
return Path.home()
|
399
|
+
except:
|
400
|
+
return Path(gettempdir())
|
401
|
+
|
398
402
|
@classmethod
|
399
403
|
def __try_ensure_serializable (cls, object: Any) -> Any:
|
400
404
|
if object is None:
|
@@ -427,11 +431,6 @@ resources {{
|
|
427
431
|
url
|
428
432
|
name
|
429
433
|
}}
|
430
|
-
results {{
|
431
|
-
data
|
432
|
-
type
|
433
|
-
shape
|
434
|
-
}}
|
435
434
|
latency
|
436
435
|
error
|
437
436
|
logs
|
@@ -4,9 +4,6 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
from .dtype import Dtype
|
7
|
-
from .environment import EnvironmentVariable
|
8
7
|
from .prediction import Prediction, PredictionResource
|
9
8
|
from .predictor import Acceleration, AccessMode, EnumerationMember, Parameter, Predictor, PredictorStatus, Signature
|
10
|
-
from .
|
11
|
-
from .storage import UploadType
|
12
|
-
from .user import User
|
9
|
+
from .user import Profile, User
|
@@ -11,16 +11,16 @@ from pydantic import AliasChoices, BaseModel, ConfigDict, Field
|
|
11
11
|
from typing import Any, Dict, List, Optional, Tuple
|
12
12
|
|
13
13
|
from .dtype import Dtype
|
14
|
-
from .
|
14
|
+
from .user import Profile
|
15
15
|
|
16
16
|
class Acceleration (IntFlag):
|
17
17
|
"""
|
18
18
|
Predictor acceleration.
|
19
19
|
"""
|
20
20
|
Default = 0,
|
21
|
-
CPU
|
22
|
-
GPU
|
23
|
-
NPU
|
21
|
+
CPU = 1 << 0,
|
22
|
+
GPU = 1 << 1,
|
23
|
+
NPU = 1 << 2
|
24
24
|
|
25
25
|
class AccessMode (str, Enum):
|
26
26
|
"""
|
@@ -27,4 +27,9 @@ class Profile (BaseModel):
|
|
27
27
|
avatar: Optional[str] = Field(default=None, description="User avatar URL.")
|
28
28
|
bio: Optional[str] = Field(default=None, description="User bio.")
|
29
29
|
website: Optional[str] = Field(default=None, description="User website.")
|
30
|
-
github: Optional[str] = Field(default=None, description="User GitHub handle.")
|
30
|
+
github: Optional[str] = Field(default=None, description="User GitHub handle.")
|
31
|
+
|
32
|
+
class User (Profile):
|
33
|
+
"""
|
34
|
+
User.
|
35
|
+
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fxn
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.38
|
4
4
|
Summary: Run prediction functions locally in Python. Register at https://fxn.ai.
|
5
5
|
Author-email: "NatML Inc." <hi@fxn.ai>
|
6
6
|
License: Apache License
|
@@ -239,20 +239,24 @@ $ pip install --upgrade fxn
|
|
239
239
|
```
|
240
240
|
|
241
241
|
> [!NOTE]
|
242
|
-
> Function requires Python 3.
|
242
|
+
> Function requires Python 3.10+
|
243
243
|
|
244
244
|
## Retrieving your Access Key
|
245
|
-
Head over to [fxn.ai](https://fxn.ai) to create an account by logging in. Once you do, generate an access key:
|
245
|
+
Head over to [fxn.ai](https://www.fxn.ai/account/developer) to create an account by logging in. Once you do, generate an access key:
|
246
246
|
|
247
247
|

|
248
248
|
|
249
249
|
## Making a Prediction
|
250
|
-
|
250
|
+
First, create a Function client, specifying your access key:
|
251
251
|
```py
|
252
252
|
from fxn import Function
|
253
253
|
|
254
254
|
# Create the Function client
|
255
255
|
fxn = Function(access_key="<Function access key>")
|
256
|
+
```
|
257
|
+
|
258
|
+
Then make a prediction:
|
259
|
+
```py
|
256
260
|
# Create a prediction
|
257
261
|
prediction = fxn.predictions.create(
|
258
262
|
tag="@fxn/greeting",
|
@@ -264,16 +268,18 @@ print(prediction.results[0])
|
|
264
268
|
|
265
269
|
> [!TIP]
|
266
270
|
> Explore public predictors [on Function](https://fxn.ai/explore) or [create your own](https://fxn.ai/waitlist).
|
267
|
-
r
|
268
|
-
## Using the Function CLI
|
269
|
-
Open up a terminal and run the following command:
|
270
271
|
|
272
|
+
## Using the Function CLI
|
273
|
+
Open up a terminal and login to the Function CLI:
|
271
274
|
```sh
|
272
275
|
# Login to Function
|
273
|
-
fxn auth login <ACCESS KEY>
|
276
|
+
$ fxn auth login <ACCESS KEY>
|
277
|
+
```
|
274
278
|
|
279
|
+
Then make a prediction:
|
280
|
+
```sh
|
275
281
|
# Make a prediction using the Function CLI
|
276
|
-
fxn predict @fxn/greeting --name Peter
|
282
|
+
$ fxn predict @fxn/greeting --name Peter
|
277
283
|
```
|
278
284
|
|
279
285
|
___
|
@@ -30,6 +30,8 @@ fxn/cli/misc.py
|
|
30
30
|
fxn/cli/predict.py
|
31
31
|
fxn/cli/predictors.py
|
32
32
|
fxn/lib/__init__.py
|
33
|
+
fxn/lib/linux/arm64/libFunction.so
|
34
|
+
fxn/lib/linux/x86_64/libFunction.so
|
33
35
|
fxn/lib/macos/arm64/Function.dylib
|
34
36
|
fxn/lib/macos/x86_64/Function.dylib
|
35
37
|
fxn/lib/windows/arm64/Function.dll
|
@@ -40,10 +42,6 @@ fxn/services/predictor.py
|
|
40
42
|
fxn/services/user.py
|
41
43
|
fxn/types/__init__.py
|
42
44
|
fxn/types/dtype.py
|
43
|
-
fxn/types/environment.py
|
44
45
|
fxn/types/prediction.py
|
45
46
|
fxn/types/predictor.py
|
46
|
-
fxn/types/profile.py
|
47
|
-
fxn/types/storage.py
|
48
|
-
fxn/types/tag.py
|
49
47
|
fxn/types/user.py
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Function
|
3
|
-
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
from pydantic import BaseModel, Field
|
7
|
-
|
8
|
-
class EnvironmentVariable (BaseModel):
|
9
|
-
"""
|
10
|
-
Predictor environment variable.
|
11
|
-
|
12
|
-
Members:
|
13
|
-
name (str): Variable name.
|
14
|
-
value (str): Variable value.
|
15
|
-
"""
|
16
|
-
name: str = Field(description="Variable name.")
|
17
|
-
value: str = Field(description="Variable value.")
|
fxn-0.0.37/fxn/types/storage.py
DELETED
fxn-0.0.37/fxn/types/tag.py
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Function
|
3
|
-
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
-
#
|
5
|
-
|
6
|
-
from __future__ import annotations
|
7
|
-
from pydantic import BaseModel, Field
|
8
|
-
|
9
|
-
class Tag (BaseModel):
|
10
|
-
"""
|
11
|
-
Predictor tag.
|
12
|
-
|
13
|
-
Members:
|
14
|
-
username (str): Predictor owner username.
|
15
|
-
name (str): Predictor name.
|
16
|
-
"""
|
17
|
-
username: str = Field(description="Predictor owner username.")
|
18
|
-
name: str = Field(description="Predictor name.")
|
19
|
-
|
20
|
-
def from_str (cls, tag: str) -> Tag:
|
21
|
-
"""
|
22
|
-
Parse a predictor tag from a string.
|
23
|
-
"""
|
24
|
-
username, name = tag.lower()[1:].split("/")
|
25
|
-
return Tag(username=username, name=name)
|
26
|
-
|
27
|
-
def __str__ (self):
|
28
|
-
return f"@{self.username}/{self.name}"
|
fxn-0.0.37/fxn/types/user.py
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|