opengradient 0.2.6__py3-none-any.whl → 0.2.8__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.
- opengradient/__init__.py +8 -8
- opengradient/abi/inference.abi +1 -1
- opengradient/cli.py +27 -21
- opengradient/client.py +14 -8
- opengradient/defaults.py +7 -0
- opengradient/utils.py +37 -9
- opengradient-0.2.8.dist-info/METADATA +209 -0
- opengradient-0.2.8.dist-info/RECORD +14 -0
- opengradient-0.2.6.dist-info/METADATA +0 -93
- opengradient-0.2.6.dist-info/RECORD +0 -13
- {opengradient-0.2.6.dist-info → opengradient-0.2.8.dist-info}/LICENSE +0 -0
- {opengradient-0.2.6.dist-info → opengradient-0.2.8.dist-info}/WHEEL +0 -0
- {opengradient-0.2.6.dist-info → opengradient-0.2.8.dist-info}/entry_points.txt +0 -0
- {opengradient-0.2.6.dist-info → opengradient-0.2.8.dist-info}/top_level.txt +0 -0
opengradient/__init__.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
from .client import Client
|
|
2
|
-
from .
|
|
3
|
-
from .types import
|
|
2
|
+
from .defaults import *
|
|
3
|
+
from .types import InferenceMode
|
|
4
4
|
|
|
5
|
-
__version__ = "0.2.
|
|
5
|
+
__version__ = "0.2.8"
|
|
6
6
|
|
|
7
7
|
_client = None
|
|
8
8
|
|
|
9
|
-
def init(private_key=
|
|
10
|
-
rpc_url=
|
|
11
|
-
contract_address=
|
|
12
|
-
email=
|
|
13
|
-
password=
|
|
9
|
+
def init(private_key=DEFAULT_PRIVATE_KEY,
|
|
10
|
+
rpc_url=DEFAULT_RPC_URL,
|
|
11
|
+
contract_address=DEFAULT_INFERENCE_CONTRACT_ADDRESS,
|
|
12
|
+
email=DEFAULT_HUB_EMAIL,
|
|
13
|
+
password=DEFAULT_HUB_PASSWORD):
|
|
14
14
|
global _client
|
|
15
15
|
_client = Client(private_key=private_key, rpc_url=rpc_url, contract_address=contract_address, email=email, password=password)
|
|
16
16
|
|
opengradient/abi/inference.abi
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"anonymous":false,"inputs":[{"components":[{"components":[{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"int128","name":"value","type":"int128"},{"internalType":"int128","name":"decimals","type":"int128"}],"internalType":"struct Number[]","name":"values","type":"tuple[]"}],"internalType":"struct
|
|
1
|
+
[{"anonymous":false,"inputs":[{"components":[{"components":[{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"int128","name":"value","type":"int128"},{"internalType":"int128","name":"decimals","type":"int128"}],"internalType":"struct TensorLib.Number[]","name":"values","type":"tuple[]"},{"internalType":"uint32[]","name":"shape","type":"uint32[]"}],"internalType":"struct TensorLib.MultiDimensionalNumberTensor[]","name":"numbers","type":"tuple[]"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string[]","name":"values","type":"string[]"}],"internalType":"struct TensorLib.StringTensor[]","name":"strings","type":"tuple[]"},{"internalType":"bool","name":"is_simulation_result","type":"bool"}],"indexed":false,"internalType":"struct ModelOutput","name":"output","type":"tuple"}],"name":"InferenceResult","type":"event"},{"inputs":[{"internalType":"string","name":"modelId","type":"string"},{"internalType":"enum ModelInferenceMode","name":"inferenceMode","type":"uint8"},{"components":[{"components":[{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"int128","name":"value","type":"int128"},{"internalType":"int128","name":"decimals","type":"int128"}],"internalType":"struct TensorLib.Number[]","name":"values","type":"tuple[]"},{"internalType":"uint32[]","name":"shape","type":"uint32[]"}],"internalType":"struct TensorLib.MultiDimensionalNumberTensor[]","name":"numbers","type":"tuple[]"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string[]","name":"values","type":"string[]"}],"internalType":"struct TensorLib.StringTensor[]","name":"strings","type":"tuple[]"}],"internalType":"struct ModelInput","name":"modelInput","type":"tuple"}],"name":"run","outputs":[{"components":[{"components":[{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"int128","name":"value","type":"int128"},{"internalType":"int128","name":"decimals","type":"int128"}],"internalType":"struct TensorLib.Number[]","name":"values","type":"tuple[]"},{"internalType":"uint32[]","name":"shape","type":"uint32[]"}],"internalType":"struct TensorLib.MultiDimensionalNumberTensor[]","name":"numbers","type":"tuple[]"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string[]","name":"values","type":"string[]"}],"internalType":"struct TensorLib.StringTensor[]","name":"strings","type":"tuple[]"},{"internalType":"bool","name":"is_simulation_result","type":"bool"}],"internalType":"struct ModelOutput","name":"","type":"tuple"}],"stateMutability":"nonpayable","type":"function"}]
|
opengradient/cli.py
CHANGED
|
@@ -5,10 +5,11 @@ import json
|
|
|
5
5
|
import ast
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from .client import Client
|
|
8
|
-
from
|
|
8
|
+
from .defaults import *
|
|
9
|
+
from .types import InferenceMode, ModelInput
|
|
9
10
|
|
|
10
11
|
# Environment variable names
|
|
11
|
-
|
|
12
|
+
PRIVATE_KEY_ENV = 'OPENGRADIENT_PRIVATE_KEY'
|
|
12
13
|
RPC_URL_ENV = 'OPENGRADIENT_RPC_URL'
|
|
13
14
|
CONTRACT_ADDRESS_ENV = 'OPENGRADIENT_CONTRACT_ADDRESS'
|
|
14
15
|
EMAIL_ENV = 'OPENGRADIENT_EMAIL'
|
|
@@ -39,48 +40,48 @@ Dict = DictParamType()
|
|
|
39
40
|
|
|
40
41
|
# Support inference modes
|
|
41
42
|
InferenceModes = {
|
|
42
|
-
"VANILLA":
|
|
43
|
-
"ZKML":
|
|
44
|
-
"TEE":
|
|
43
|
+
"VANILLA": InferenceMode.VANILLA,
|
|
44
|
+
"ZKML": InferenceMode.ZKML,
|
|
45
|
+
"TEE": InferenceMode.TEE,
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
# TODO (Kyle): Once we're farther into development, we should remove the defaults for these options
|
|
48
49
|
@click.group()
|
|
49
|
-
@click.option('--
|
|
50
|
-
envvar=
|
|
50
|
+
@click.option('--private_key',
|
|
51
|
+
envvar=PRIVATE_KEY_ENV,
|
|
51
52
|
help='Your OpenGradient private key',
|
|
52
|
-
default=
|
|
53
|
+
default=DEFAULT_PRIVATE_KEY)
|
|
53
54
|
@click.option('--rpc_url',
|
|
54
55
|
envvar=RPC_URL_ENV,
|
|
55
56
|
help='OpenGradient RPC URL address',
|
|
56
|
-
default=
|
|
57
|
+
default=DEFAULT_RPC_URL)
|
|
57
58
|
@click.option('--contract_address',
|
|
58
59
|
envvar=CONTRACT_ADDRESS_ENV,
|
|
59
|
-
help='OpenGradient contract address',
|
|
60
|
-
default=
|
|
60
|
+
help='OpenGradient inference contract address',
|
|
61
|
+
default=DEFAULT_INFERENCE_CONTRACT_ADDRESS)
|
|
61
62
|
@click.option('--email',
|
|
62
63
|
envvar=EMAIL_ENV,
|
|
63
|
-
help='Your OpenGradient
|
|
64
|
-
default=
|
|
64
|
+
help='Your OpenGradient Hub email address -- not required for inference',
|
|
65
|
+
default=DEFAULT_HUB_EMAIL)
|
|
65
66
|
@click.option('--password',
|
|
66
67
|
envvar=PASSWORD_ENV,
|
|
67
|
-
help='Your OpenGradient
|
|
68
|
-
default=
|
|
68
|
+
help='Your OpenGradient Hub password -- not required for inference',
|
|
69
|
+
default=DEFAULT_HUB_PASSWORD)
|
|
69
70
|
@click.pass_context
|
|
70
|
-
def cli(ctx,
|
|
71
|
+
def cli(ctx, private_key, rpc_url, contract_address, email, password):
|
|
71
72
|
"""CLI for OpenGradient SDK"""
|
|
72
|
-
if not
|
|
73
|
-
click.echo("Please provide
|
|
73
|
+
if not private_key:
|
|
74
|
+
click.echo("Please provide a private key via flag or setting environment variable OPENGRADIENT_PRIVATE_KEY")
|
|
74
75
|
if not rpc_url:
|
|
75
76
|
click.echo("Please provide a RPC URL via flag or setting environment variable OPENGRADIENT_RPC_URL")
|
|
76
77
|
if not contract_address:
|
|
77
78
|
click.echo("Please provide a contract address via flag or setting environment variable OPENGRADIENT_CONTRACT_ADDRESS")
|
|
78
|
-
if not
|
|
79
|
+
if not private_key or not rpc_url or not contract_address:
|
|
79
80
|
ctx.exit(1)
|
|
80
81
|
return
|
|
81
82
|
|
|
82
83
|
try:
|
|
83
|
-
ctx.obj = Client(private_key=
|
|
84
|
+
ctx.obj = Client(private_key=private_key,
|
|
84
85
|
rpc_url=rpc_url,
|
|
85
86
|
contract_address=contract_address,
|
|
86
87
|
email=email,
|
|
@@ -98,7 +99,7 @@ def client_settings(ctx):
|
|
|
98
99
|
ctx.exit(1)
|
|
99
100
|
|
|
100
101
|
click.echo("Settings for OpenGradient client:")
|
|
101
|
-
click.echo(f"\
|
|
102
|
+
click.echo(f"\tPrivate key ({PRIVATE_KEY_ENV}): {client.private_key}")
|
|
102
103
|
click.echo(f"\tRPC URL ({RPC_URL_ENV}): {client.rpc_url}")
|
|
103
104
|
click.echo(f"\tContract address ({CONTRACT_ADDRESS_ENV}): {client.contract_address}")
|
|
104
105
|
if client.user:
|
|
@@ -185,5 +186,10 @@ def infer(ctx, model_cid, inference_mode, input_data, input_file):
|
|
|
185
186
|
except Exception as e:
|
|
186
187
|
click.echo(f"Error running inference: {str(e)}")
|
|
187
188
|
|
|
189
|
+
|
|
190
|
+
@cli.command()
|
|
191
|
+
def version():
|
|
192
|
+
click.echo(f"OpenGradient CLI version: {opengradient.__version__}")
|
|
193
|
+
|
|
188
194
|
if __name__ == '__main__':
|
|
189
195
|
cli()
|
opengradient/client.py
CHANGED
|
@@ -43,6 +43,12 @@ class Client:
|
|
|
43
43
|
self.firebase_app = firebase.initialize_app(self.FIREBASE_CONFIG)
|
|
44
44
|
self.auth = self.firebase_app.auth()
|
|
45
45
|
self.user = None
|
|
46
|
+
|
|
47
|
+
logging.debug("Initialized client with parameters:\n"
|
|
48
|
+
"private key: %s\n"
|
|
49
|
+
"RPC URL: %s\n"
|
|
50
|
+
"Contract Address: %s\n",
|
|
51
|
+
private_key, rpc_url, contract_address)
|
|
46
52
|
|
|
47
53
|
abi_path = os.path.join(os.path.dirname(__file__), 'abi', 'inference.abi')
|
|
48
54
|
with open(abi_path, 'r') as abi_file:
|
|
@@ -104,20 +110,20 @@ class Client:
|
|
|
104
110
|
response.raise_for_status()
|
|
105
111
|
|
|
106
112
|
json_response = response.json()
|
|
107
|
-
|
|
108
|
-
if not
|
|
109
|
-
raise Exception(f"Model creation response missing '
|
|
110
|
-
logging.info(f"Model creation successful. Model
|
|
113
|
+
model_name = json_response.get('name')
|
|
114
|
+
if not model_name:
|
|
115
|
+
raise Exception(f"Model creation response missing 'name'. Full response: {json_response}")
|
|
116
|
+
logging.info(f"Model creation successful. Model name: {model_name}")
|
|
111
117
|
|
|
112
118
|
# Create the specified version for the newly created model
|
|
113
119
|
try:
|
|
114
|
-
version_response = self.create_version(
|
|
115
|
-
logging.info(f"Version creation successful. Version
|
|
120
|
+
version_response = self.create_version(model_name, version)
|
|
121
|
+
logging.info(f"Version creation successful. Version string: {version_response['versionString']}")
|
|
116
122
|
except Exception as ve:
|
|
117
123
|
logging.error(f"Version creation failed, but model was created. Error: {str(ve)}")
|
|
118
|
-
return {"
|
|
124
|
+
return {"name": model_name, "versionString": None, "version_error": str(ve)}
|
|
119
125
|
|
|
120
|
-
return {"
|
|
126
|
+
return {"name": model_name, "versionString": version_response["versionString"]}
|
|
121
127
|
|
|
122
128
|
except requests.RequestException as e:
|
|
123
129
|
logging.error(f"Model creation failed: {str(e)}")
|
opengradient/defaults.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
# Default variables
|
|
3
|
+
DEFAULT_PRIVATE_KEY="cd09980ef6e280afc3900d2d6801f9e9c5d858a5deaeeab74a65643f5ff1a4c1"
|
|
4
|
+
DEFAULT_RPC_URL="http://18.218.115.248:8545"
|
|
5
|
+
DEFAULT_INFERENCE_CONTRACT_ADDRESS="0x75D0266DAb643417e9FFD828A1A31C1E039a966c"
|
|
6
|
+
DEFAULT_HUB_EMAIL="test@test.com"
|
|
7
|
+
DEFAULT_HUB_PASSWORD="Test-123"
|
opengradient/utils.py
CHANGED
|
@@ -40,11 +40,10 @@ def convert_to_model_input(inputs: Dict[str, np.ndarray]) -> Tuple[List[Tuple[st
|
|
|
40
40
|
"""
|
|
41
41
|
Expect SDK input to be a dict with the format
|
|
42
42
|
key: tensor name
|
|
43
|
-
value: np.array
|
|
43
|
+
value: np.array / list
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Return a tuple of (number tensors, string tensors) depending on the input type
|
|
45
|
+
Return a tuple of (number tensors, string tensors) depending on the input type. Each number and string tensor converted
|
|
46
|
+
to a numpy array and flattened and the shape saved.
|
|
48
47
|
"""
|
|
49
48
|
logging.debug("Converting the following input dictionary to ModelInput: %s", inputs)
|
|
50
49
|
number_tensors = []
|
|
@@ -59,19 +58,37 @@ def convert_to_model_input(inputs: Dict[str, np.ndarray]) -> Tuple[List[Tuple[st
|
|
|
59
58
|
logging.debug(f"\tConverting single entry {tensor_data} to a list")
|
|
60
59
|
tensor_data = np.array([tensor_data])
|
|
61
60
|
|
|
61
|
+
# Check if type is np array
|
|
62
|
+
if not isinstance(tensor_data, np.ndarray):
|
|
63
|
+
raise TypeError("Inference input must be list, numpy array, or type (str, int, float): %s" % type(tensor_data))
|
|
64
|
+
|
|
65
|
+
# Flatten list and retain shape
|
|
66
|
+
shape = tensor_data.shape
|
|
67
|
+
flat_data = tensor_data.flatten()
|
|
68
|
+
logging.debug("Shape and flattened data: %s, %s", shape, flat_data)
|
|
69
|
+
|
|
62
70
|
# Parse into number and string tensors
|
|
63
71
|
if issubclass(tensor_data.dtype.type, np.floating):
|
|
64
|
-
|
|
72
|
+
# Convert to fixed-point tuples
|
|
73
|
+
data_type = np.dtype([('value', int), ('decimal', int)])
|
|
74
|
+
converted_tensor_data = np.array([convert_to_fixed_point(i) for i in flat_data], dtype=data_type)
|
|
75
|
+
|
|
76
|
+
input = (tensor_name, converted_tensor_data.tolist(), shape)
|
|
65
77
|
logging.debug("\tFloating tensor input: %s", input)
|
|
66
78
|
|
|
67
79
|
number_tensors.append(input)
|
|
68
80
|
elif issubclass(tensor_data.dtype.type, np.integer):
|
|
69
|
-
|
|
81
|
+
# Convert to fixed-point tuples
|
|
82
|
+
data_type = np.dtype([('value', int), ('decimal', int)])
|
|
83
|
+
converted_tensor_data = np.array([convert_to_fixed_point(int(i)) for i in flat_data], dtype=data_type)
|
|
84
|
+
|
|
85
|
+
input = (tensor_name, converted_tensor_data.tolist(), shape)
|
|
70
86
|
logging.debug("\tInteger tensor input: %s", input)
|
|
71
87
|
|
|
72
88
|
number_tensors.append(input)
|
|
73
89
|
elif issubclass(tensor_data.dtype.type, np.str_):
|
|
74
|
-
|
|
90
|
+
# TODO (Kyle): Add shape into here as well
|
|
91
|
+
input = (tensor_name, [s for s in flat_data])
|
|
75
92
|
logging.debug("\tString tensor input: %s", input)
|
|
76
93
|
|
|
77
94
|
string_tensors.append(input)
|
|
@@ -85,6 +102,15 @@ def convert_to_model_input(inputs: Dict[str, np.ndarray]) -> Tuple[List[Tuple[st
|
|
|
85
102
|
return number_tensors, string_tensors
|
|
86
103
|
|
|
87
104
|
def convert_to_model_output(event_data: AttributeDict) -> Dict[str, np.ndarray]:
|
|
105
|
+
"""
|
|
106
|
+
Converts inference output into a user-readable output.
|
|
107
|
+
Expects the inference node to return a dict with the format:
|
|
108
|
+
key: output_name (str)
|
|
109
|
+
value: (output_array (list), shape (list)) (tuple)
|
|
110
|
+
|
|
111
|
+
We need to reshape each output array using the shape parameter in order to get the array
|
|
112
|
+
back into its original shape.
|
|
113
|
+
"""
|
|
88
114
|
logging.debug(f"Parsing event data: {event_data}")
|
|
89
115
|
|
|
90
116
|
output_dict = {}
|
|
@@ -98,6 +124,7 @@ def convert_to_model_output(event_data: AttributeDict) -> Dict[str, np.ndarray]:
|
|
|
98
124
|
logging.debug(f"Processing number tensor: {tensor}")
|
|
99
125
|
if isinstance(tensor, AttributeDict):
|
|
100
126
|
name = tensor.get('name')
|
|
127
|
+
shape = tensor.get('shape')
|
|
101
128
|
values = []
|
|
102
129
|
# Convert from fixed point back into np.float32
|
|
103
130
|
for v in tensor.get('values', []):
|
|
@@ -105,7 +132,7 @@ def convert_to_model_output(event_data: AttributeDict) -> Dict[str, np.ndarray]:
|
|
|
105
132
|
values.append(convert_to_float32(value=int(v.get('value')), decimals=int(v.get('decimals'))))
|
|
106
133
|
else:
|
|
107
134
|
logging.warning(f"Unexpected number type: {type(v)}")
|
|
108
|
-
output_dict[name] = np.array(values)
|
|
135
|
+
output_dict[name] = np.array(values).reshape(shape)
|
|
109
136
|
else:
|
|
110
137
|
logging.warning(f"Unexpected tensor type: {type(tensor)}")
|
|
111
138
|
|
|
@@ -114,8 +141,9 @@ def convert_to_model_output(event_data: AttributeDict) -> Dict[str, np.ndarray]:
|
|
|
114
141
|
logging.debug(f"Processing string tensor: {tensor}")
|
|
115
142
|
if isinstance(tensor, AttributeDict):
|
|
116
143
|
name = tensor.get('name')
|
|
144
|
+
shape = tensor.get('shape')
|
|
117
145
|
values = tensor.get('values', [])
|
|
118
|
-
output_dict[name] = values
|
|
146
|
+
output_dict[name] = np.array(values).reshape(shape)
|
|
119
147
|
else:
|
|
120
148
|
logging.warning(f"Unexpected tensor type: {type(tensor)}")
|
|
121
149
|
else:
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: opengradient
|
|
3
|
+
Version: 0.2.8
|
|
4
|
+
Summary: A Python SDK for OpenGradient inference services
|
|
5
|
+
Author-email: OpenGradient <oliver@opengradient.ai>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 OpenGradient
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://opengradient.ai
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Requires-Python: >=3.7
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
License-File: LICENSE
|
|
42
|
+
Requires-Dist: aiohappyeyeballs==2.4.3
|
|
43
|
+
Requires-Dist: aiohttp==3.10.8
|
|
44
|
+
Requires-Dist: aiosignal==1.3.1
|
|
45
|
+
Requires-Dist: annotated-types==0.7.0
|
|
46
|
+
Requires-Dist: attrs==24.2.0
|
|
47
|
+
Requires-Dist: bitarray==2.9.2
|
|
48
|
+
Requires-Dist: CacheControl==0.14.0
|
|
49
|
+
Requires-Dist: cachetools==5.5.0
|
|
50
|
+
Requires-Dist: certifi==2024.8.30
|
|
51
|
+
Requires-Dist: cffi==1.17.1
|
|
52
|
+
Requires-Dist: charset-normalizer==3.3.2
|
|
53
|
+
Requires-Dist: ckzg==2.0.1
|
|
54
|
+
Requires-Dist: cleo==2.1.0
|
|
55
|
+
Requires-Dist: click==8.1.7
|
|
56
|
+
Requires-Dist: cramjam==2.8.4
|
|
57
|
+
Requires-Dist: crashtest==0.4.1
|
|
58
|
+
Requires-Dist: cryptography==43.0.1
|
|
59
|
+
Requires-Dist: cytoolz==0.12.3
|
|
60
|
+
Requires-Dist: distlib==0.3.8
|
|
61
|
+
Requires-Dist: dulwich==0.21.7
|
|
62
|
+
Requires-Dist: eth-account==0.13.4
|
|
63
|
+
Requires-Dist: eth-hash==0.7.0
|
|
64
|
+
Requires-Dist: eth-keyfile==0.8.1
|
|
65
|
+
Requires-Dist: eth-keys==0.5.1
|
|
66
|
+
Requires-Dist: eth-rlp==2.1.0
|
|
67
|
+
Requires-Dist: eth-typing==5.0.0
|
|
68
|
+
Requires-Dist: eth-utils==5.0.0
|
|
69
|
+
Requires-Dist: eth-abi==5.1.0
|
|
70
|
+
Requires-Dist: fastjsonschema==2.20.0
|
|
71
|
+
Requires-Dist: fastparquet==2024.5.0
|
|
72
|
+
Requires-Dist: filelock==3.16.1
|
|
73
|
+
Requires-Dist: firebase-rest-api==1.11.0
|
|
74
|
+
Requires-Dist: frozenlist==1.4.1
|
|
75
|
+
Requires-Dist: fsspec==2024.9.0
|
|
76
|
+
Requires-Dist: google-api-core==2.20.0
|
|
77
|
+
Requires-Dist: google-auth==2.35.0
|
|
78
|
+
Requires-Dist: google-cloud-core==2.4.1
|
|
79
|
+
Requires-Dist: google-cloud-firestore==2.19.0
|
|
80
|
+
Requires-Dist: google-cloud-storage==2.18.2
|
|
81
|
+
Requires-Dist: google-crc32c==1.6.0
|
|
82
|
+
Requires-Dist: google-resumable-media==2.7.2
|
|
83
|
+
Requires-Dist: googleapis-common-protos==1.65.0
|
|
84
|
+
Requires-Dist: grpcio==1.66.2
|
|
85
|
+
Requires-Dist: grpcio-status==1.66.2
|
|
86
|
+
Requires-Dist: hexbytes==1.2.1
|
|
87
|
+
Requires-Dist: idna==3.10
|
|
88
|
+
Requires-Dist: jaraco.classes==3.4.0
|
|
89
|
+
Requires-Dist: jwcrypto==1.5.6
|
|
90
|
+
Requires-Dist: keyring==24.3.1
|
|
91
|
+
Requires-Dist: more-itertools==10.5.0
|
|
92
|
+
Requires-Dist: msgpack==1.1.0
|
|
93
|
+
Requires-Dist: multidict==6.1.0
|
|
94
|
+
Requires-Dist: numpy==2.1.1
|
|
95
|
+
Requires-Dist: packaging==24.1
|
|
96
|
+
Requires-Dist: pandas==2.2.3
|
|
97
|
+
Requires-Dist: parsimonious==0.10.0
|
|
98
|
+
Requires-Dist: pathlib==1.0.1
|
|
99
|
+
Requires-Dist: pexpect==4.9.0
|
|
100
|
+
Requires-Dist: pkce==1.0.3
|
|
101
|
+
Requires-Dist: pkginfo==1.11.1
|
|
102
|
+
Requires-Dist: platformdirs==4.3.6
|
|
103
|
+
Requires-Dist: proto-plus==1.24.0
|
|
104
|
+
Requires-Dist: protobuf==5.28.2
|
|
105
|
+
Requires-Dist: ptyprocess==0.7.0
|
|
106
|
+
Requires-Dist: pyarrow==17.0.0
|
|
107
|
+
Requires-Dist: pyasn1==0.6.1
|
|
108
|
+
Requires-Dist: pyasn1-modules==0.4.1
|
|
109
|
+
Requires-Dist: pycparser==2.22
|
|
110
|
+
Requires-Dist: pycryptodome==3.21.0
|
|
111
|
+
Requires-Dist: pydantic==2.9.2
|
|
112
|
+
Requires-Dist: pydantic-core==2.23.4
|
|
113
|
+
Requires-Dist: pyproject-hooks==1.2.0
|
|
114
|
+
Requires-Dist: python-dateutil==2.9.0.post0
|
|
115
|
+
Requires-Dist: python-jwt==4.1.0
|
|
116
|
+
Requires-Dist: pytz==2024.2
|
|
117
|
+
Requires-Dist: pyunormalize==16.0.0
|
|
118
|
+
Requires-Dist: RapidFuzz==3.10.0
|
|
119
|
+
Requires-Dist: regex==2024.9.11
|
|
120
|
+
Requires-Dist: requests==2.32.3
|
|
121
|
+
Requires-Dist: requests-toolbelt==1.0.0
|
|
122
|
+
Requires-Dist: rlp==4.0.1
|
|
123
|
+
Requires-Dist: rsa==4.9
|
|
124
|
+
Requires-Dist: shellingham==1.5.4
|
|
125
|
+
Requires-Dist: six==1.16.0
|
|
126
|
+
Requires-Dist: tomlkit==0.13.2
|
|
127
|
+
Requires-Dist: toolz==0.12.1
|
|
128
|
+
Requires-Dist: trove-classifiers==2024.9.12
|
|
129
|
+
Requires-Dist: types-requests==2.32.0.20240914
|
|
130
|
+
Requires-Dist: typing-extensions==4.12.2
|
|
131
|
+
Requires-Dist: tzdata==2024.2
|
|
132
|
+
Requires-Dist: urllib3==2.2.3
|
|
133
|
+
Requires-Dist: web3==7.3.0
|
|
134
|
+
Requires-Dist: websockets==13.1
|
|
135
|
+
Requires-Dist: xattr==1.1.0
|
|
136
|
+
Requires-Dist: yarl==1.13.1
|
|
137
|
+
|
|
138
|
+
# OpenGradient Python SDK
|
|
139
|
+
|
|
140
|
+
Python SDK for OpenGradient inference services.
|
|
141
|
+
|
|
142
|
+
## Installation
|
|
143
|
+
```python
|
|
144
|
+
pip install opengradient
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Quick Start
|
|
148
|
+
```python
|
|
149
|
+
import opengradient as og
|
|
150
|
+
og.init(private_key="x", rpc_url="y", contract_address="z")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Sign in with Email
|
|
154
|
+
```python
|
|
155
|
+
og.login(email="you@opengradient.ai", password="xyz")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Create a Model
|
|
159
|
+
```python
|
|
160
|
+
og.create_model(model_name="test-network-model", model_desc="testing upload to sdk")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Create a Version of a Model
|
|
164
|
+
```python
|
|
165
|
+
og.create_version(model_name="test-network-model", notes="test notes")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Upload Files to a Model
|
|
169
|
+
```python
|
|
170
|
+
og.upload(model_path="local_path_to_your_model.onnx", model_name="test-network-model", version="0.01")
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Run Inference
|
|
174
|
+
```python
|
|
175
|
+
inference_mode = og.InferenceMode.VANILLA
|
|
176
|
+
inference_cid = og.infer(model_cid, model_inputs, inference_mode)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
og.infer(model_id, inference_mode, model_input)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Using the CLI
|
|
184
|
+
|
|
185
|
+
#### Creating a Model
|
|
186
|
+
```bash
|
|
187
|
+
opengradient create_model "<model_name>" "<description>"
|
|
188
|
+
```
|
|
189
|
+
- creating a model automatically initializes version `v0.01`
|
|
190
|
+
|
|
191
|
+
#### Creating a Version
|
|
192
|
+
```bash
|
|
193
|
+
opengradient create_model "<model_name>" "<description>"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Upload a File
|
|
197
|
+
```bash
|
|
198
|
+
opengradient upload "path/to/model.onnx" "<model_name>" "<version>"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### CLI infer using string
|
|
202
|
+
```bash
|
|
203
|
+
opengradient infer QmbUqS93oc4JTLMHwpVxsE39mhNxy6hpf6Py3r9oANr8aZ VANILLA '{"num_input1":[1.0, 2.0, 3.0], "num_input2":10, "str_input1":["hello", "ONNX"], "str_input2":" world"}'
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### CLI infer using file path input
|
|
207
|
+
```bash
|
|
208
|
+
opengradient infer QmbUqS93oc4JTLMHwpVxsE39mhNxy6hpf6Py3r9oANr8aZ VANILLA --input_file input.json
|
|
209
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
opengradient/__init__.py,sha256=gMNHFVZRrzniZ7RrhUm02bJGFQ5U9RR7o7G2klgPQ8g,1576
|
|
2
|
+
opengradient/cli.py,sha256=bM_mROx9xbhtJ2P1uBrdsRSlphkC93zuD5q6mC6E9WA,7430
|
|
3
|
+
opengradient/client.py,sha256=9yhMLlqfRcIOk16P-9OOV2QR9UOfpkZYtaFExJQYxKw,18313
|
|
4
|
+
opengradient/defaults.py,sha256=FDVOXlceTTU1G13KDf1Gg34UYhOU9VUBemqBVu99G5Y,298
|
|
5
|
+
opengradient/exceptions.py,sha256=v4VmUGTvvtjhCZAhR24Ga42z3q-DzR1Y5zSqP_yn2Xk,3366
|
|
6
|
+
opengradient/types.py,sha256=EoJN-DkQrJ2WTUv8OenlrlWJWFY2jPGTl-T8C_OVjp8,1849
|
|
7
|
+
opengradient/utils.py,sha256=F1Nj-GMNFQFxCtbGgWQq1RP4TSurbpQxJV3yKeEo1b0,6482
|
|
8
|
+
opengradient/abi/inference.abi,sha256=u8FsW0s1YeRjUb9eLS1k_qh_5f_cwOdr0bii-tAdxh0,2683
|
|
9
|
+
opengradient-0.2.8.dist-info/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
|
|
10
|
+
opengradient-0.2.8.dist-info/METADATA,sha256=99VuVVLSZlCT9tCx697XV75uwaZUBY39WxfETdpB5YQ,6871
|
|
11
|
+
opengradient-0.2.8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
12
|
+
opengradient-0.2.8.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
|
|
13
|
+
opengradient-0.2.8.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
|
|
14
|
+
opengradient-0.2.8.dist-info/RECORD,,
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: opengradient
|
|
3
|
-
Version: 0.2.6
|
|
4
|
-
Summary: A Python SDK for OpenGradient inference services
|
|
5
|
-
Author-email: OpenGradient <oliver@opengradient.ai>
|
|
6
|
-
License: MIT License
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2024 OpenGradient
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
|
|
28
|
-
Project-URL: Homepage, https://opengradient.ai
|
|
29
|
-
Classifier: Development Status :: 3 - Alpha
|
|
30
|
-
Classifier: Intended Audience :: Developers
|
|
31
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
-
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
34
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
35
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
36
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
-
Requires-Python: >=3.7
|
|
40
|
-
Description-Content-Type: text/markdown
|
|
41
|
-
License-File: LICENSE
|
|
42
|
-
Requires-Dist: click
|
|
43
|
-
Requires-Dist: requests
|
|
44
|
-
Requires-Dist: web3
|
|
45
|
-
Requires-Dist: pyarrow
|
|
46
|
-
Requires-Dist: firebase-rest-api
|
|
47
|
-
Requires-Dist: fastparquet
|
|
48
|
-
Requires-Dist: pathlib
|
|
49
|
-
|
|
50
|
-
# OpenGradient Python SDK
|
|
51
|
-
|
|
52
|
-
Python SDK for OpenGradient inference services.
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
```
|
|
56
|
-
pip install opengradient
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Quick Start
|
|
60
|
-
```
|
|
61
|
-
import opengradient as og
|
|
62
|
-
og.init(private_key="x", rpc_url="y", contract_address="z")
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Sign in with Email
|
|
66
|
-
```
|
|
67
|
-
og.sign_in_with_email_and_password(email="test@test.com", password="Test-123")
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Create a Model
|
|
71
|
-
```
|
|
72
|
-
og.create_model("test-network-model-5", "testing sdk")
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Create a Version of a Model
|
|
76
|
-
```
|
|
77
|
-
og.create_version(model_id=11, notes="test notes")
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Upload Files to a Model
|
|
81
|
-
```
|
|
82
|
-
og.upload(model_path, model_id, version=2)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Run Inference
|
|
86
|
-
```
|
|
87
|
-
inference_mode = og.InferenceMode.VANILLA
|
|
88
|
-
inference_cid = og.infer(model_cid, model_inputs, inference_mode)
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
og.infer(model_id, inference_mode, model_input)
|
|
93
|
-
```
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
opengradient/__init__.py,sha256=sImAqtmJU03jhmPXCye37bLu_KGILDCmCRLpS8S2HcI,1783
|
|
2
|
-
opengradient/cli.py,sha256=U0hEQEab5-D-Abkxs1WmV4Qbalth80MBwBDnOCK4hWc,7354
|
|
3
|
-
opengradient/client.py,sha256=tPHTi4rZiZ5Kf_XKdfD3uJZFP2j4AO4ld2lJS38nj24,18026
|
|
4
|
-
opengradient/exceptions.py,sha256=v4VmUGTvvtjhCZAhR24Ga42z3q-DzR1Y5zSqP_yn2Xk,3366
|
|
5
|
-
opengradient/types.py,sha256=EoJN-DkQrJ2WTUv8OenlrlWJWFY2jPGTl-T8C_OVjp8,1849
|
|
6
|
-
opengradient/utils.py,sha256=95i5RVn-32MRsn00M21io8QHLtmEAoRbgueMhDh0TVk,5079
|
|
7
|
-
opengradient/abi/inference.abi,sha256=HH2SmCJ_D4O0I-CFsln0vFHd2PU-A-fxgCnUtHg0ZQg,2373
|
|
8
|
-
opengradient-0.2.6.dist-info/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
|
|
9
|
-
opengradient-0.2.6.dist-info/METADATA,sha256=au_A8g75nxOpqCoo6zuHBQmKVNwxu_9sUGBMlVI1ybY,3000
|
|
10
|
-
opengradient-0.2.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
11
|
-
opengradient-0.2.6.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
|
|
12
|
-
opengradient-0.2.6.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
|
|
13
|
-
opengradient-0.2.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|