fxn 0.0.35__py3-none-any.whl → 0.0.37__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/c/__init__.py +16 -0
- fxn/c/configuration.py +60 -0
- fxn/c/dtype.py +26 -0
- fxn/c/fxnc.py +28 -0
- fxn/c/map.py +34 -0
- fxn/c/prediction.py +37 -0
- fxn/c/predictor.py +31 -0
- fxn/c/status.py +12 -0
- fxn/c/stream.py +22 -0
- fxn/c/value.py +50 -0
- fxn/c/version.py +13 -0
- fxn/cli/__init__.py +8 -8
- fxn/cli/auth.py +1 -1
- fxn/cli/misc.py +10 -4
- fxn/cli/predict.py +3 -4
- fxn/cli/predictors.py +1 -40
- fxn/function.py +4 -10
- fxn/lib/macos/arm64/Function.dylib +0 -0
- fxn/lib/macos/x86_64/Function.dylib +0 -0
- fxn/lib/windows/arm64/Function.dll +0 -0
- fxn/lib/windows/x86_64/Function.dll +0 -0
- fxn/services/__init__.py +1 -3
- fxn/services/prediction.py +456 -0
- fxn/services/predictor.py +4 -73
- fxn/services/user.py +1 -1
- fxn/types/__init__.py +2 -3
- fxn/types/prediction.py +0 -4
- fxn/types/predictor.py +15 -22
- fxn/version.py +1 -1
- {fxn-0.0.35.dist-info → fxn-0.0.37.dist-info}/METADATA +27 -29
- fxn-0.0.37.dist-info/RECORD +46 -0
- {fxn-0.0.35.dist-info → fxn-0.0.37.dist-info}/WHEEL +1 -1
- fxn/libs/linux/__init__.py +0 -4
- fxn/libs/macos/Function.dylib +0 -0
- fxn/libs/macos/__init__.py +0 -4
- fxn/libs/windows/Function.dll +0 -0
- fxn/libs/windows/__init__.py +0 -4
- fxn/magic.py +0 -35
- fxn/services/environment.py +0 -111
- fxn/services/prediction/__init__.py +0 -6
- fxn/services/prediction/fxnc.py +0 -312
- fxn/services/prediction/service.py +0 -512
- fxn/services/storage.py +0 -160
- fxn/types/value.py +0 -22
- fxn-0.0.35.dist-info/RECORD +0 -42
- /fxn/{graph → api}/__init__.py +0 -0
- /fxn/{graph → api}/client.py +0 -0
- /fxn/{libs → lib}/__init__.py +0 -0
- {fxn-0.0.35.dist-info → fxn-0.0.37.dist-info}/LICENSE +0 -0
- {fxn-0.0.35.dist-info → fxn-0.0.37.dist-info}/entry_points.txt +0 -0
- {fxn-0.0.35.dist-info → fxn-0.0.37.dist-info}/top_level.txt +0 -0
fxn/c/__init__.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
# https://github.com/fxnai/fxnc
|
7
|
+
|
8
|
+
from .status import FXNStatus
|
9
|
+
from .value import FXNDtype, FXNValueRef, FXNValueFlags
|
10
|
+
from .map import FXNValueMapRef
|
11
|
+
from .configuration import FXNConfigurationRef, FXNAcceleration
|
12
|
+
from .prediction import FXNPredictionRef
|
13
|
+
from .stream import FXNPredictionStreamRef
|
14
|
+
from .predictor import FXNPredictorRef
|
15
|
+
|
16
|
+
from .fxnc import load_fxnc
|
fxn/c/configuration.py
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import c_char_p, c_int, c_int32, c_void_p, CDLL, POINTER, Structure
|
7
|
+
from .status import FXNStatus
|
8
|
+
|
9
|
+
class FXNAcceleration(c_int):
|
10
|
+
FXN_ACCELERATION_DEFAULT = 0
|
11
|
+
FXN_ACCELERATION_CPU = 1 << 0
|
12
|
+
FXN_ACCELERATION_GPU = 1 << 1
|
13
|
+
FXN_ACCELERATION_NPU = 1 << 2
|
14
|
+
|
15
|
+
class FXNConfiguration(Structure): pass
|
16
|
+
|
17
|
+
FXNConfigurationRef = POINTER(FXNConfiguration)
|
18
|
+
|
19
|
+
def _register_fxn_configuration (fxnc: CDLL) -> CDLL:
|
20
|
+
# FXNConfigurationGetUniqueID
|
21
|
+
fxnc.FXNConfigurationGetUniqueID.argtypes = [c_char_p, c_int32]
|
22
|
+
fxnc.FXNConfigurationGetUniqueID.restype = FXNStatus
|
23
|
+
# FXNConfigurationGetClientID
|
24
|
+
fxnc.FXNConfigurationGetClientID.argtypes = [c_char_p, c_int32]
|
25
|
+
fxnc.FXNConfigurationGetClientID.restype = FXNStatus
|
26
|
+
# FXNConfigurationCreate
|
27
|
+
fxnc.FXNConfigurationCreate.argtypes = [POINTER(FXNConfigurationRef)]
|
28
|
+
fxnc.FXNConfigurationCreate.restype = FXNStatus
|
29
|
+
# FXNConfigurationRelease
|
30
|
+
fxnc.FXNConfigurationRelease.argtypes = [FXNConfigurationRef]
|
31
|
+
fxnc.FXNConfigurationRelease.restype = FXNStatus
|
32
|
+
# FXNConfigurationGetTag
|
33
|
+
fxnc.FXNConfigurationGetTag.argtypes = [FXNConfigurationRef, c_char_p, c_int32]
|
34
|
+
fxnc.FXNConfigurationRelease.restype = FXNStatus
|
35
|
+
# FXNConfigurationSetTag
|
36
|
+
fxnc.FXNConfigurationSetTag.argtypes = [FXNConfigurationRef, c_char_p]
|
37
|
+
fxnc.FXNConfigurationSetTag.restype = FXNStatus
|
38
|
+
# FXNConfigurationGetToken
|
39
|
+
fxnc.FXNConfigurationGetToken.argtypes = [FXNConfigurationRef, c_char_p, c_int32]
|
40
|
+
fxnc.FXNConfigurationGetToken.restype = FXNStatus
|
41
|
+
# FXNConfigurationSetToken
|
42
|
+
fxnc.FXNConfigurationSetToken.argtypes = [FXNConfigurationRef, c_char_p]
|
43
|
+
fxnc.FXNConfigurationSetToken.restype = FXNStatus
|
44
|
+
# FXNConfigurationGetAcceleration
|
45
|
+
fxnc.FXNConfigurationGetAcceleration.argtypes = [FXNConfigurationRef, POINTER(FXNAcceleration)]
|
46
|
+
fxnc.FXNConfigurationGetAcceleration.restype = FXNStatus
|
47
|
+
# FXNConfigurationSetAcceleration
|
48
|
+
fxnc.FXNConfigurationSetAcceleration.argtypes = [FXNConfigurationRef, FXNAcceleration]
|
49
|
+
fxnc.FXNConfigurationSetAcceleration.restype = FXNStatus
|
50
|
+
# FXNConfigurationGetDevice
|
51
|
+
fxnc.FXNConfigurationGetDevice.argtypes = [FXNConfigurationRef, POINTER(c_void_p)]
|
52
|
+
fxnc.FXNConfigurationGetDevice.restype = FXNStatus
|
53
|
+
# FXNConfigurationSetDevice
|
54
|
+
fxnc.FXNConfigurationSetDevice.argtypes = [FXNConfigurationRef, c_void_p]
|
55
|
+
fxnc.FXNConfigurationSetDevice.restype = FXNStatus
|
56
|
+
# FXNConfigurationAddResource
|
57
|
+
fxnc.FXNConfigurationAddResource.argtypes = [FXNConfigurationRef, c_char_p, c_char_p]
|
58
|
+
fxnc.FXNConfigurationAddResource.restype = FXNStatus
|
59
|
+
# Return
|
60
|
+
return fxnc
|
fxn/c/dtype.py
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import c_int
|
7
|
+
|
8
|
+
class FXNDtype(c_int):
|
9
|
+
NULL = 0
|
10
|
+
FLOAT16 = 1
|
11
|
+
FLOAT32 = 2
|
12
|
+
FLOAT64 = 3
|
13
|
+
INT8 = 4
|
14
|
+
INT16 = 5
|
15
|
+
INT32 = 6
|
16
|
+
INT64 = 7
|
17
|
+
UINT8 = 8
|
18
|
+
UINT16 = 9
|
19
|
+
UINT32 = 10
|
20
|
+
UINT64 = 11
|
21
|
+
BOOL = 12
|
22
|
+
STRING = 13
|
23
|
+
LIST = 14
|
24
|
+
DICT = 15
|
25
|
+
IMAGE = 16
|
26
|
+
BINARY = 17
|
fxn/c/fxnc.py
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import CDLL
|
7
|
+
from pathlib import Path
|
8
|
+
from .configuration import _register_fxn_configuration
|
9
|
+
from .prediction import _register_fxn_prediction
|
10
|
+
from .stream import _register_fxn_prediction_stream
|
11
|
+
from .predictor import _register_fxn_predictor
|
12
|
+
from .value import _register_fxn_value
|
13
|
+
from .map import _register_fxn_value_map
|
14
|
+
from .version import _register_fxn_version
|
15
|
+
|
16
|
+
def load_fxnc (path: Path) -> CDLL:
|
17
|
+
# Open
|
18
|
+
fxnc = CDLL(str(path))
|
19
|
+
# Register
|
20
|
+
fxnc = _register_fxn_value(fxnc)
|
21
|
+
fxnc = _register_fxn_value_map(fxnc)
|
22
|
+
fxnc = _register_fxn_configuration(fxnc)
|
23
|
+
fxnc = _register_fxn_prediction(fxnc)
|
24
|
+
fxnc = _register_fxn_prediction_stream(fxnc)
|
25
|
+
fxnc = _register_fxn_predictor(fxnc)
|
26
|
+
fxnc = _register_fxn_version(fxnc)
|
27
|
+
# Return
|
28
|
+
return fxnc
|
fxn/c/map.py
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import c_char_p, c_int32, CDLL, POINTER, Structure
|
7
|
+
from .status import FXNStatus
|
8
|
+
from .value import FXNValueRef
|
9
|
+
|
10
|
+
class FXNValueMap(Structure): pass
|
11
|
+
|
12
|
+
FXNValueMapRef = POINTER(FXNValueMap)
|
13
|
+
|
14
|
+
def _register_fxn_value_map (fxnc: CDLL) -> CDLL:
|
15
|
+
# FXNValueMapCreate
|
16
|
+
fxnc.FXNValueMapCreate.argtypes = [POINTER(FXNValueMapRef)]
|
17
|
+
fxnc.FXNValueMapCreate.restype = FXNStatus
|
18
|
+
# FXNValueMapRelease
|
19
|
+
fxnc.FXNValueMapRelease.argtypes = [FXNValueMapRef]
|
20
|
+
fxnc.FXNValueMapRelease.restype = FXNStatus
|
21
|
+
# FXNValueMapGetSize
|
22
|
+
fxnc.FXNValueMapGetSize.argtypes = [FXNValueMapRef, POINTER(c_int32)]
|
23
|
+
fxnc.FXNValueMapGetSize.restype = FXNStatus
|
24
|
+
# FXNValueMapGetKey
|
25
|
+
fxnc.FXNValueMapGetKey.argtypes = [FXNValueMapRef, c_int32, c_char_p, c_int32]
|
26
|
+
fxnc.FXNValueMapGetKey.restype = FXNStatus
|
27
|
+
# FXNValueMapGetValue
|
28
|
+
fxnc.FXNValueMapGetValue.argtypes = [FXNValueMapRef, c_char_p, POINTER(FXNValueRef)]
|
29
|
+
fxnc.FXNValueMapGetValue.restype = FXNStatus
|
30
|
+
# FXNValueMapSetValue
|
31
|
+
fxnc.FXNValueMapSetValue.argtypes = [FXNValueMapRef, c_char_p, FXNValueRef]
|
32
|
+
fxnc.FXNValueMapSetValue.restype = FXNStatus
|
33
|
+
# Return
|
34
|
+
return fxnc
|
fxn/c/prediction.py
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import c_char_p, c_double, c_int32, CDLL, POINTER, Structure
|
7
|
+
from .status import FXNStatus
|
8
|
+
from .map import FXNValueMapRef
|
9
|
+
|
10
|
+
class FXNPrediction(Structure): pass
|
11
|
+
|
12
|
+
FXNPredictionRef = POINTER(FXNPrediction)
|
13
|
+
|
14
|
+
def _register_fxn_prediction (fxnc: CDLL) -> CDLL:
|
15
|
+
# FXNPredictionRelease
|
16
|
+
fxnc.FXNPredictionRelease.argtypes = [FXNPredictionRef]
|
17
|
+
fxnc.FXNPredictionRelease.restype = FXNStatus
|
18
|
+
# FXNPredictionGetID
|
19
|
+
fxnc.FXNPredictionGetID.argtypes = [FXNPredictionRef, c_char_p, c_int32]
|
20
|
+
fxnc.FXNPredictionGetID.restype = FXNStatus
|
21
|
+
# FXNPredictionGetLatency
|
22
|
+
fxnc.FXNPredictionGetLatency.argtypes = [FXNPredictionRef, POINTER(c_double)]
|
23
|
+
fxnc.FXNPredictionGetLatency.restype = FXNStatus
|
24
|
+
# FXNPredictionGetResults
|
25
|
+
fxnc.FXNPredictionGetResults.argtypes = [FXNPredictionRef, POINTER(FXNValueMapRef)]
|
26
|
+
fxnc.FXNPredictionGetResults.restype = FXNStatus
|
27
|
+
# FXNPredictionGetError
|
28
|
+
fxnc.FXNPredictionGetError.argtypes = [FXNPredictionRef, c_char_p, c_int32]
|
29
|
+
fxnc.FXNPredictionGetError.restype = FXNStatus
|
30
|
+
# FXNPredictionGetLogs
|
31
|
+
fxnc.FXNPredictionGetLogs.argtypes = [FXNPredictionRef, c_char_p, c_int32]
|
32
|
+
fxnc.FXNPredictionGetLogs.restype = FXNStatus
|
33
|
+
# FXNPredictionGetLogLength
|
34
|
+
fxnc.FXNPredictionGetLogLength.argtypes = [FXNPredictionRef, POINTER(c_int32)]
|
35
|
+
fxnc.FXNPredictionGetLogLength.restype = FXNStatus
|
36
|
+
# Return
|
37
|
+
return fxnc
|
fxn/c/predictor.py
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import CDLL, POINTER, Structure
|
7
|
+
from .configuration import FXNConfigurationRef
|
8
|
+
from .prediction import FXNPredictionRef
|
9
|
+
from .stream import FXNPredictionStreamRef
|
10
|
+
from .status import FXNStatus
|
11
|
+
from .map import FXNValueMapRef
|
12
|
+
|
13
|
+
class FXNPredictor(Structure): pass
|
14
|
+
|
15
|
+
FXNPredictorRef = POINTER(FXNPredictor)
|
16
|
+
|
17
|
+
def _register_fxn_predictor (fxnc: CDLL) -> CDLL:
|
18
|
+
# FXNPredictorCreate
|
19
|
+
fxnc.FXNPredictorCreate.argtypes = [FXNConfigurationRef, POINTER(FXNPredictorRef)]
|
20
|
+
fxnc.FXNPredictorCreate.restype = FXNStatus
|
21
|
+
# FXNPredictorRelease
|
22
|
+
fxnc.FXNPredictorRelease.argtypes = [FXNPredictorRef]
|
23
|
+
fxnc.FXNPredictorRelease.restype = FXNStatus
|
24
|
+
# FXNPredictorCreatePrediction
|
25
|
+
fxnc.FXNPredictorCreatePrediction.argtypes = [FXNPredictorRef, FXNValueMapRef, POINTER(FXNPredictionRef)]
|
26
|
+
fxnc.FXNPredictorCreatePrediction.restype = FXNStatus
|
27
|
+
# FXNPredictorStreamPrediction
|
28
|
+
fxnc.FXNPredictorStreamPrediction.argtypes = [FXNPredictionRef, FXNValueMapRef, POINTER(FXNPredictionStreamRef)]
|
29
|
+
fxnc.FXNPredictorStreamPrediction.restype = FXNStatus
|
30
|
+
# Return
|
31
|
+
return fxnc
|
fxn/c/status.py
ADDED
fxn/c/stream.py
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import CDLL, POINTER, Structure
|
7
|
+
from .prediction import FXNPredictionRef
|
8
|
+
from .status import FXNStatus
|
9
|
+
|
10
|
+
class FXNPredictionStream(Structure): pass
|
11
|
+
|
12
|
+
FXNPredictionStreamRef = POINTER(FXNPredictionStream)
|
13
|
+
|
14
|
+
def _register_fxn_prediction_stream (fxnc: CDLL) -> CDLL:
|
15
|
+
# FXNPredictionStreamRelease
|
16
|
+
fxnc.FXNPredictionStreamRelease.argtypes = [FXNPredictionStreamRef]
|
17
|
+
fxnc.FXNPredictionStreamRelease.restype = FXNStatus
|
18
|
+
# FXNPredictionStreamReadNext
|
19
|
+
fxnc.FXNPredictionStreamReadNext.argtypes = [FXNPredictionStreamRef, POINTER(FXNPredictionRef)]
|
20
|
+
fxnc.FXNPredictionStreamReadNext.restype = FXNStatus
|
21
|
+
# Return
|
22
|
+
return fxnc
|
fxn/c/value.py
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import c_char_p, c_int, c_int32, c_void_p, CDLL, POINTER, Structure
|
7
|
+
from .dtype import FXNDtype
|
8
|
+
from .status import FXNStatus
|
9
|
+
|
10
|
+
class FXNValueFlags(c_int):
|
11
|
+
NONE = 0
|
12
|
+
COPY_DATA = 1
|
13
|
+
|
14
|
+
class FXNValue(Structure): pass
|
15
|
+
|
16
|
+
FXNValueRef = POINTER(FXNValue)
|
17
|
+
|
18
|
+
def _register_fxn_value (fxnc: CDLL) -> CDLL:
|
19
|
+
# FXNValueRelease
|
20
|
+
fxnc.FXNValueRelease.argtypes = [FXNValueRef]
|
21
|
+
fxnc.FXNValueRelease.restype = FXNStatus
|
22
|
+
# FXNValueGetData
|
23
|
+
fxnc.FXNValueGetData.argtypes = [FXNValueRef, POINTER(c_void_p)]
|
24
|
+
fxnc.FXNValueGetData.restype = FXNStatus
|
25
|
+
# FXNValueGetType
|
26
|
+
fxnc.FXNValueGetType.argtypes = [FXNValueRef, POINTER(FXNDtype)]
|
27
|
+
fxnc.FXNValueGetType.restype = FXNStatus
|
28
|
+
# FXNValueGetDimensions
|
29
|
+
fxnc.FXNValueGetDimensions.argtypes = [FXNValueRef, POINTER(c_int32)]
|
30
|
+
fxnc.FXNValueGetDimensions.restype = FXNStatus
|
31
|
+
# FXNValueGetShape
|
32
|
+
fxnc.FXNValueGetShape.argtypes = [FXNValueRef, POINTER(c_int32), c_int32]
|
33
|
+
fxnc.FXNValueGetShape.restype = FXNStatus
|
34
|
+
# FXNValueCreateArray
|
35
|
+
fxnc.FXNValueCreateArray.argtypes = [c_void_p, POINTER(c_int32), c_int32, FXNDtype, FXNValueFlags, POINTER(FXNValueRef)]
|
36
|
+
fxnc.FXNValueCreateArray.restype = FXNStatus
|
37
|
+
# FXNValueCreateString
|
38
|
+
fxnc.FXNValueCreateString.argtypes = [c_char_p, POINTER(FXNValueRef)]
|
39
|
+
fxnc.FXNValueCreateString.restype = FXNStatus
|
40
|
+
# FXNValueCreateList
|
41
|
+
fxnc.FXNValueCreateList.argtypes = [c_char_p, POINTER(FXNValueRef)]
|
42
|
+
fxnc.FXNValueCreateList.restype = FXNStatus
|
43
|
+
# FXNValueCreateDict
|
44
|
+
fxnc.FXNValueCreateDict.argtypes = [c_char_p, POINTER(FXNValueRef)]
|
45
|
+
fxnc.FXNValueCreateDict.restype = FXNStatus
|
46
|
+
# FXNValueCreateImage
|
47
|
+
fxnc.FXNValueCreateImage.argtypes = [c_void_p, c_int32, c_int32, c_int32, FXNValueFlags, POINTER(FXNValueRef)]
|
48
|
+
fxnc.FXNValueCreateImage.restype = FXNStatus
|
49
|
+
# Return
|
50
|
+
return fxnc
|
fxn/c/version.py
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#
|
2
|
+
# Function
|
3
|
+
# Copyright © 2024 NatML Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
|
6
|
+
from ctypes import c_char_p, CDLL
|
7
|
+
|
8
|
+
def _register_fxn_version (fxnc: CDLL) -> CDLL:
|
9
|
+
# FXNGetVersion
|
10
|
+
fxnc.FXNGetVersion.argtypes = []
|
11
|
+
fxnc.FXNGetVersion.restype = c_char_p
|
12
|
+
# Return
|
13
|
+
return fxnc
|
fxn/cli/__init__.py
CHANGED
@@ -9,7 +9,7 @@ from .auth import app as auth_app
|
|
9
9
|
from .env import app as env_app
|
10
10
|
from .misc import cli_options
|
11
11
|
from .predict import predict
|
12
|
-
from .predictors import archive_predictor,
|
12
|
+
from .predictors import archive_predictor, delete_predictor, list_predictors, retrieve_predictor, search_predictors
|
13
13
|
from ..version import __version__
|
14
14
|
|
15
15
|
# Define CLI
|
@@ -26,16 +26,16 @@ app.callback()(cli_options)
|
|
26
26
|
|
27
27
|
# Add subcommands
|
28
28
|
app.add_typer(auth_app, name="auth", help="Login, logout, and check your authentication status.")
|
29
|
-
app.add_typer(env_app, name="env", help="Manage predictor environment variables.")
|
29
|
+
#app.add_typer(env_app, name="env", help="Manage predictor environment variables.")
|
30
30
|
|
31
31
|
# Add top-level commands
|
32
|
-
app.command(name="create", help="Create a predictor.")(create_predictor)
|
33
|
-
app.command(name="delete", help="Delete a predictor.")(delete_predictor)
|
32
|
+
#app.command(name="create", help="Create a predictor.")(create_predictor)
|
33
|
+
#app.command(name="delete", help="Delete a predictor.")(delete_predictor)
|
34
34
|
app.command(name="predict", help="Make a prediction.", context_settings={ "allow_extra_args": True, "ignore_unknown_options": True })(predict)
|
35
|
-
app.command(name="list", help="List predictors.")(list_predictors)
|
36
|
-
app.command(name="search", help="Search predictors.")(search_predictors)
|
37
|
-
app.command(name="retrieve", help="Retrieve a predictor.")(retrieve_predictor)
|
38
|
-
app.command(name="archive", help="Archive a predictor.")(archive_predictor)
|
35
|
+
#app.command(name="list", help="List predictors.")(list_predictors)
|
36
|
+
#app.command(name="search", help="Search predictors.")(search_predictors)
|
37
|
+
#app.command(name="retrieve", help="Retrieve a predictor.")(retrieve_predictor)
|
38
|
+
#app.command(name="archive", help="Archive a predictor.")(archive_predictor)
|
39
39
|
|
40
40
|
# Run
|
41
41
|
if __name__ == "__main__":
|
fxn/cli/auth.py
CHANGED
@@ -15,7 +15,7 @@ app = Typer(no_args_is_help=True)
|
|
15
15
|
def login (
|
16
16
|
access_key: str=Argument(..., help="Function access key.", envvar="FXN_ACCESS_KEY")
|
17
17
|
):
|
18
|
-
fxn = Function(access_key)
|
18
|
+
fxn = Function(access_key=access_key)
|
19
19
|
user = fxn.users.retrieve()
|
20
20
|
user = user.model_dump() if user else None
|
21
21
|
_set_access_key(access_key if user is not None else None)
|
fxn/cli/misc.py
CHANGED
@@ -9,18 +9,24 @@ from webbrowser import open as open_browser
|
|
9
9
|
|
10
10
|
from ..version import __version__
|
11
11
|
|
12
|
-
def
|
12
|
+
def _explore (value: bool):
|
13
|
+
if value:
|
14
|
+
open_browser("https://fxn.ai/explore")
|
15
|
+
raise Exit()
|
16
|
+
|
17
|
+
def _learn (value: bool):
|
13
18
|
if value:
|
14
19
|
open_browser("https://docs.fxn.ai")
|
15
20
|
raise Exit()
|
16
21
|
|
17
|
-
def
|
22
|
+
def _version (value: bool):
|
18
23
|
if value:
|
19
24
|
print(__version__)
|
20
25
|
raise Exit()
|
21
26
|
|
22
27
|
def cli_options (
|
23
|
-
|
24
|
-
|
28
|
+
explore: bool = Option(None, "--explore", callback=_explore, help="Explore predictors on Function."),
|
29
|
+
learn: bool = Option(None, "--learn", callback=_learn, help="Learn about Function."),
|
30
|
+
version: bool = Option(None, "--version", callback=_version, help="Get the Function CLI version.")
|
25
31
|
):
|
26
32
|
pass
|
fxn/cli/predict.py
CHANGED
@@ -18,12 +18,11 @@ from .auth import get_access_key
|
|
18
18
|
|
19
19
|
def predict (
|
20
20
|
tag: str = Argument(..., help="Predictor tag."),
|
21
|
-
raw_outputs: bool = Option(False, "--raw-outputs", help="Output raw Function values instead of converting into plain Python values."),
|
22
21
|
context: Context = 0
|
23
22
|
):
|
24
|
-
run_async(_predict_async(tag, context=context
|
23
|
+
run_async(_predict_async(tag, context=context))
|
25
24
|
|
26
|
-
async def _predict_async (tag: str, context: Context
|
25
|
+
async def _predict_async (tag: str, context: Context):
|
27
26
|
with Progress(
|
28
27
|
SpinnerColumn(spinner_name="dots"),
|
29
28
|
TextColumn("[progress.description]{task.description}"),
|
@@ -34,7 +33,7 @@ async def _predict_async (tag: str, context: Context, raw_outputs: bool):
|
|
34
33
|
inputs = { context.args[i].replace("-", ""): _parse_value(context.args[i+1]) for i in range(0, len(context.args), 2) }
|
35
34
|
# Stream
|
36
35
|
fxn = Function(get_access_key())
|
37
|
-
async for prediction in fxn.predictions.stream(tag, inputs=inputs
|
36
|
+
async for prediction in fxn.predictions.stream(tag, inputs=inputs):
|
38
37
|
# Parse results
|
39
38
|
images = [value for value in prediction.results or [] if isinstance(value, Image.Image)]
|
40
39
|
prediction.results = [_serialize_value(value) for value in prediction.results] if prediction.results is not None else None
|
fxn/cli/predictors.py
CHANGED
@@ -5,12 +5,10 @@
|
|
5
5
|
|
6
6
|
from rich import print_json
|
7
7
|
from rich.progress import Progress, SpinnerColumn, TextColumn
|
8
|
-
from pathlib import Path
|
9
8
|
from typer import Argument, Option
|
10
|
-
from typing import List
|
11
9
|
|
12
10
|
from ..function import Function
|
13
|
-
from ..types import
|
11
|
+
from ..types import PredictorStatus
|
14
12
|
from .auth import get_access_key
|
15
13
|
|
16
14
|
def retrieve_predictor (
|
@@ -47,43 +45,6 @@ def search_predictors (
|
|
47
45
|
predictors = [predictor.model_dump() for predictor in predictors]
|
48
46
|
print_json(data=predictors)
|
49
47
|
|
50
|
-
def create_predictor (
|
51
|
-
tag: str=Argument(..., help="Predictor tag."),
|
52
|
-
notebook: Path=Argument(..., help="Path to predictor notebook."),
|
53
|
-
type: PredictorType=Option(None, case_sensitive=False, help="Predictor type. This defaults to `cloud`."),
|
54
|
-
edge: bool=Option(False, "--edge", is_flag=True, help="Shorthand for `--type edge`."),
|
55
|
-
cloud: bool=Option(False, "--cloud", is_flag=True, help="Shorthand for `--type cloud`."),
|
56
|
-
access: AccessMode=Option(None, case_sensitive=False, help="Predictor access mode. This defaults to `private`."),
|
57
|
-
description: str=Option(None, help="Predictor description. This must be less than 200 characters long."),
|
58
|
-
media: Path=Option(None, help="Predictor image path."),
|
59
|
-
acceleration: Acceleration=Option(None, case_sensitive=False, help="Cloud predictor acceleration. This defaults to `cpu`."),
|
60
|
-
license: str=Option(None, help="Predictor license URL."),
|
61
|
-
env: List[str]=Option([], help="Specify a predictor environment variable."),
|
62
|
-
overwrite: bool=Option(None, "--overwrite", help="Overwrite any existing predictor with the same tag.")
|
63
|
-
):
|
64
|
-
with Progress(
|
65
|
-
SpinnerColumn(spinner_name="dots"),
|
66
|
-
TextColumn("[progress.description]{task.description}"),
|
67
|
-
transient=True
|
68
|
-
) as progress:
|
69
|
-
progress.add_task(description="Analyzing Function...", total=None)
|
70
|
-
fxn = Function(get_access_key())
|
71
|
-
type = PredictorType.Cloud if cloud else PredictorType.Edge if edge else type
|
72
|
-
environment = { e.split("=")[0].strip(): e.split("=")[1].strip() for e in env }
|
73
|
-
predictor = fxn.predictors.create(
|
74
|
-
tag=tag,
|
75
|
-
notebook=notebook,
|
76
|
-
type=type,
|
77
|
-
access=access,
|
78
|
-
description=description,
|
79
|
-
media=media,
|
80
|
-
acceleration=acceleration,
|
81
|
-
environment=environment,
|
82
|
-
license=license,
|
83
|
-
overwrite=overwrite
|
84
|
-
)
|
85
|
-
print_json(data=predictor.model_dump())
|
86
|
-
|
87
48
|
def delete_predictor (
|
88
49
|
tag: str=Argument(..., help="Predictor tag.")
|
89
50
|
):
|
fxn/function.py
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
|
6
6
|
from os import environ
|
7
7
|
|
8
|
-
from .
|
9
|
-
from .services import
|
8
|
+
from .api import GraphClient
|
9
|
+
from .services import PredictionService, PredictorService, UserService
|
10
10
|
|
11
11
|
class Function:
|
12
12
|
"""
|
@@ -17,8 +17,6 @@ class Function:
|
|
17
17
|
users (UserService): Manage users.
|
18
18
|
predictors (PredictorService): Manage predictors.
|
19
19
|
predictions (PredictionService): Manage predictions.
|
20
|
-
environment_variables (EnvironmentVariableService): Manage predictor environment variables.
|
21
|
-
storage (StorageService): Upload and download files.
|
22
20
|
|
23
21
|
Constructor:
|
24
22
|
access_key (str): Function access key.
|
@@ -28,15 +26,11 @@ class Function:
|
|
28
26
|
users: UserService
|
29
27
|
predictors: PredictorService
|
30
28
|
predictions: PredictionService
|
31
|
-
environment_variables: EnvironmentVariableService
|
32
|
-
storage: StorageService
|
33
29
|
|
34
30
|
def __init__ (self, access_key: str=None, api_url: str=None):
|
35
31
|
access_key = access_key or environ.get("FXN_ACCESS_KEY", None)
|
36
32
|
api_url = api_url or environ.get("FXN_API_URL", "https://api.fxn.ai")
|
37
33
|
self.client = GraphClient(access_key, api_url)
|
38
34
|
self.users = UserService(self.client)
|
39
|
-
self.
|
40
|
-
self.
|
41
|
-
self.predictions = PredictionService(self.client, self.storage)
|
42
|
-
self.environment_variables = EnvironmentVariableService(self.client)
|
35
|
+
self.predictors = PredictorService(self.client)
|
36
|
+
self.predictions = PredictionService(self.client)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
fxn/services/__init__.py
CHANGED
@@ -5,6 +5,4 @@
|
|
5
5
|
|
6
6
|
from .user import UserService, PROFILE_FIELDS, USER_FIELDS
|
7
7
|
from .predictor import PredictorService, PREDICTOR_FIELDS
|
8
|
-
from .prediction import PredictionService, PREDICTION_FIELDS
|
9
|
-
from .environment import EnvironmentVariableService, ENVIRONMENT_VARIABLE_FIELDS
|
10
|
-
from .storage import StorageService
|
8
|
+
from .prediction import PredictionService, PREDICTION_FIELDS
|