opengradient 0.2.6__tar.gz → 0.2.8__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.
Files changed (28) hide show
  1. opengradient-0.2.8/PKG-INFO +209 -0
  2. opengradient-0.2.8/README.md +72 -0
  3. opengradient-0.2.8/pyproject.toml +142 -0
  4. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient/__init__.py +8 -8
  5. opengradient-0.2.8/src/opengradient/abi/inference.abi +1 -0
  6. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient/cli.py +27 -21
  7. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient/client.py +14 -8
  8. opengradient-0.2.8/src/opengradient/defaults.py +7 -0
  9. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient/utils.py +37 -9
  10. opengradient-0.2.8/src/opengradient.egg-info/PKG-INFO +209 -0
  11. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient.egg-info/SOURCES.txt +1 -0
  12. opengradient-0.2.8/src/opengradient.egg-info/requires.txt +95 -0
  13. opengradient-0.2.6/PKG-INFO +0 -93
  14. opengradient-0.2.6/README.md +0 -44
  15. opengradient-0.2.6/pyproject.toml +0 -54
  16. opengradient-0.2.6/src/opengradient/abi/inference.abi +0 -1
  17. opengradient-0.2.6/src/opengradient.egg-info/PKG-INFO +0 -93
  18. opengradient-0.2.6/src/opengradient.egg-info/requires.txt +0 -7
  19. {opengradient-0.2.6 → opengradient-0.2.8}/LICENSE +0 -0
  20. {opengradient-0.2.6 → opengradient-0.2.8}/setup.cfg +0 -0
  21. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient/exceptions.py +0 -0
  22. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient/types.py +0 -0
  23. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient.egg-info/dependency_links.txt +0 -0
  24. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient.egg-info/entry_points.txt +0 -0
  25. {opengradient-0.2.6 → opengradient-0.2.8}/src/opengradient.egg-info/top_level.txt +0 -0
  26. {opengradient-0.2.6 → opengradient-0.2.8}/tests/test_api.py +0 -0
  27. {opengradient-0.2.6 → opengradient-0.2.8}/tests/test_exceptions.py +0 -0
  28. {opengradient-0.2.6 → opengradient-0.2.8}/tests/test_integration.py +0 -0
@@ -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,72 @@
1
+ # OpenGradient Python SDK
2
+
3
+ Python SDK for OpenGradient inference services.
4
+
5
+ ## Installation
6
+ ```python
7
+ pip install opengradient
8
+ ```
9
+
10
+ ## Quick Start
11
+ ```python
12
+ import opengradient as og
13
+ og.init(private_key="x", rpc_url="y", contract_address="z")
14
+ ```
15
+
16
+ ### Sign in with Email
17
+ ```python
18
+ og.login(email="you@opengradient.ai", password="xyz")
19
+ ```
20
+
21
+ ### Create a Model
22
+ ```python
23
+ og.create_model(model_name="test-network-model", model_desc="testing upload to sdk")
24
+ ```
25
+
26
+ ### Create a Version of a Model
27
+ ```python
28
+ og.create_version(model_name="test-network-model", notes="test notes")
29
+ ```
30
+
31
+ ### Upload Files to a Model
32
+ ```python
33
+ og.upload(model_path="local_path_to_your_model.onnx", model_name="test-network-model", version="0.01")
34
+ ```
35
+
36
+ ### Run Inference
37
+ ```python
38
+ inference_mode = og.InferenceMode.VANILLA
39
+ inference_cid = og.infer(model_cid, model_inputs, inference_mode)
40
+ ```
41
+
42
+ ```python
43
+ og.infer(model_id, inference_mode, model_input)
44
+ ```
45
+
46
+ ## Using the CLI
47
+
48
+ #### Creating a Model
49
+ ```bash
50
+ opengradient create_model "<model_name>" "<description>"
51
+ ```
52
+ - creating a model automatically initializes version `v0.01`
53
+
54
+ #### Creating a Version
55
+ ```bash
56
+ opengradient create_model "<model_name>" "<description>"
57
+ ```
58
+
59
+ #### Upload a File
60
+ ```bash
61
+ opengradient upload "path/to/model.onnx" "<model_name>" "<version>"
62
+ ```
63
+
64
+ #### CLI infer using string
65
+ ```bash
66
+ opengradient infer QmbUqS93oc4JTLMHwpVxsE39mhNxy6hpf6Py3r9oANr8aZ VANILLA '{"num_input1":[1.0, 2.0, 3.0], "num_input2":10, "str_input1":["hello", "ONNX"], "str_input2":" world"}'
67
+ ```
68
+
69
+ #### CLI infer using file path input
70
+ ```bash
71
+ opengradient infer QmbUqS93oc4JTLMHwpVxsE39mhNxy6hpf6Py3r9oANr8aZ VANILLA --input_file input.json
72
+ ```
@@ -0,0 +1,142 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "opengradient"
7
+ version = "0.2.8"
8
+ description = "A Python SDK for OpenGradient inference services"
9
+ authors = [{name = "OpenGradient", email = "oliver@opengradient.ai"}]
10
+ license = {file = "LICENSE"}
11
+ readme = "README.md"
12
+ requires-python = ">=3.7"
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.7",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ ]
25
+ dependencies = [
26
+ "aiohappyeyeballs==2.4.3",
27
+ "aiohttp==3.10.8",
28
+ "aiosignal==1.3.1",
29
+ "annotated-types==0.7.0",
30
+ "attrs==24.2.0",
31
+ "bitarray==2.9.2",
32
+ "CacheControl==0.14.0",
33
+ "cachetools==5.5.0",
34
+ "certifi==2024.8.30",
35
+ "cffi==1.17.1",
36
+ "charset-normalizer==3.3.2",
37
+ "ckzg==2.0.1",
38
+ "cleo==2.1.0",
39
+ "click==8.1.7",
40
+ "cramjam==2.8.4",
41
+ "crashtest==0.4.1",
42
+ "cryptography==43.0.1",
43
+ "cytoolz==0.12.3",
44
+ "distlib==0.3.8",
45
+ "dulwich==0.21.7",
46
+ "eth-account==0.13.4",
47
+ "eth-hash==0.7.0",
48
+ "eth-keyfile==0.8.1",
49
+ "eth-keys==0.5.1",
50
+ "eth-rlp==2.1.0",
51
+ "eth-typing==5.0.0",
52
+ "eth-utils==5.0.0",
53
+ "eth_abi==5.1.0",
54
+ "fastjsonschema==2.20.0",
55
+ "fastparquet==2024.5.0",
56
+ "filelock==3.16.1",
57
+ "firebase-rest-api==1.11.0",
58
+ "frozenlist==1.4.1",
59
+ "fsspec==2024.9.0",
60
+ "google-api-core==2.20.0",
61
+ "google-auth==2.35.0",
62
+ "google-cloud-core==2.4.1",
63
+ "google-cloud-firestore==2.19.0",
64
+ "google-cloud-storage==2.18.2",
65
+ "google-crc32c==1.6.0",
66
+ "google-resumable-media==2.7.2",
67
+ "googleapis-common-protos==1.65.0",
68
+ "grpcio==1.66.2",
69
+ "grpcio-status==1.66.2",
70
+ "hexbytes==1.2.1",
71
+ "idna==3.10",
72
+ "jaraco.classes==3.4.0",
73
+ "jwcrypto==1.5.6",
74
+ "keyring==24.3.1",
75
+ "more-itertools==10.5.0",
76
+ "msgpack==1.1.0",
77
+ "multidict==6.1.0",
78
+ "numpy==2.1.1",
79
+ "packaging==24.1",
80
+ "pandas==2.2.3",
81
+ "parsimonious==0.10.0",
82
+ "pathlib==1.0.1",
83
+ "pexpect==4.9.0",
84
+ "pkce==1.0.3",
85
+ "pkginfo==1.11.1",
86
+ "platformdirs==4.3.6",
87
+ "proto-plus==1.24.0",
88
+ "protobuf==5.28.2",
89
+ "ptyprocess==0.7.0",
90
+ "pyarrow==17.0.0",
91
+ "pyasn1==0.6.1",
92
+ "pyasn1_modules==0.4.1",
93
+ "pycparser==2.22",
94
+ "pycryptodome==3.21.0",
95
+ "pydantic==2.9.2",
96
+ "pydantic_core==2.23.4",
97
+ "pyproject_hooks==1.2.0",
98
+ "python-dateutil==2.9.0.post0",
99
+ "python-jwt==4.1.0",
100
+ "pytz==2024.2",
101
+ "pyunormalize==16.0.0",
102
+ "RapidFuzz==3.10.0",
103
+ "regex==2024.9.11",
104
+ "requests==2.32.3",
105
+ "requests-toolbelt==1.0.0",
106
+ "rlp==4.0.1",
107
+ "rsa==4.9",
108
+ "shellingham==1.5.4",
109
+ "six==1.16.0",
110
+ "tomlkit==0.13.2",
111
+ "toolz==0.12.1",
112
+ "trove-classifiers==2024.9.12",
113
+ "types-requests==2.32.0.20240914",
114
+ "typing_extensions==4.12.2",
115
+ "tzdata==2024.2",
116
+ "urllib3==2.2.3",
117
+ "web3==7.3.0",
118
+ "websockets==13.1",
119
+ "xattr==1.1.0",
120
+ "yarl==1.13.1",
121
+ ]
122
+
123
+ [project.scripts]
124
+ opengradient = "opengradient.cli:cli"
125
+
126
+ [project.urls]
127
+ Homepage = "https://opengradient.ai"
128
+
129
+ [tool.setuptools]
130
+ package-dir = {"" = "src"}
131
+ include-package-data = true
132
+
133
+ [tool.setuptools.packages.find]
134
+ where = ["src"]
135
+ exclude = ["tests*"]
136
+
137
+ [tool.setuptools.package-data]
138
+ "*" = ["*.py", "*.abi"]
139
+ "opengradient" = ["abi/*.abi"]
140
+
141
+ [tool.setuptools.exclude-package-data]
142
+ "*" = ["*.ipynb", "*.pyc", "*.pyo", ".gitignore", "requirements.txt", "conftest.py"]
@@ -1,16 +1,16 @@
1
1
  from .client import Client
2
- from .exceptions import OpenGradientError, FileNotFoundError, UploadError, InferenceError, ResultRetrievalError
3
- from .types import ModelInput, InferenceMode, Number, NumberTensor, StringTensor, ModelOutput
2
+ from .defaults import *
3
+ from .types import InferenceMode
4
4
 
5
- __version__ = "0.2.6"
5
+ __version__ = "0.2.8"
6
6
 
7
7
  _client = None
8
8
 
9
- def init(private_key="cd09980ef6e280afc3900d2d6801f9e9c5d858a5deaeeab74a65643f5ff1a4c1",
10
- rpc_url="http://18.218.115.248:8545",
11
- contract_address="0x350E0A430b2B1563481833a99523Cfd17a530e4e",
12
- email="test@test.com",
13
- password="Test-123"):
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
 
@@ -0,0 +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 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"}]
@@ -5,10 +5,11 @@ import json
5
5
  import ast
6
6
  from pathlib import Path
7
7
  from .client import Client
8
- from opengradient.types import InferenceMode, ModelInput
8
+ from .defaults import *
9
+ from .types import InferenceMode, ModelInput
9
10
 
10
11
  # Environment variable names
11
- API_KEY_ENV = 'OPENGRADIENT_API_KEY'
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": opengradient.InferenceMode.VANILLA,
43
- "ZKML": opengradient.InferenceMode.ZKML,
44
- "TEE": opengradient.InferenceMode.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('--api_key',
50
- envvar=API_KEY_ENV,
50
+ @click.option('--private_key',
51
+ envvar=PRIVATE_KEY_ENV,
51
52
  help='Your OpenGradient private key',
52
- default="cd09980ef6e280afc3900d2d6801f9e9c5d858a5deaeeab74a65643f5ff1a4c1")
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="http://18.218.115.248:8545")
57
+ default=DEFAULT_RPC_URL)
57
58
  @click.option('--contract_address',
58
59
  envvar=CONTRACT_ADDRESS_ENV,
59
- help='OpenGradient contract address',
60
- default="0x350E0A430b2B1563481833a99523Cfd17a530e4e")
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 hub email address -- not required for inference',
64
- default="test@test.com")
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 hub password -- not required for inference',
68
- default="Test-123")
68
+ help='Your OpenGradient Hub password -- not required for inference',
69
+ default=DEFAULT_HUB_PASSWORD)
69
70
  @click.pass_context
70
- def cli(ctx, api_key, rpc_url, contract_address, email, password):
71
+ def cli(ctx, private_key, rpc_url, contract_address, email, password):
71
72
  """CLI for OpenGradient SDK"""
72
- if not api_key:
73
- click.echo("Please provide an API key via flag or setting environment variable OPENGRADIENT_API_KEY")
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 api_key or not rpc_url or not contract_address:
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=api_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"\tAPI key ({API_KEY_ENV}): {client.private_key}")
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()
@@ -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
- model_id = json_response.get('id')
108
- if not model_id:
109
- raise Exception(f"Model creation response missing 'id'. Full response: {json_response}")
110
- logging.info(f"Model creation successful. Model ID: {model_id}")
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(model_id, version)
115
- logging.info(f"Version creation successful. Version ID: {version_response['versionString']}")
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 {"id": model_id, "versionString": None, "version_error": str(ve)}
124
+ return {"name": model_name, "versionString": None, "version_error": str(ve)}
119
125
 
120
- return {"id": model_id, "versionString": version_response["versionString"]}
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)}")
@@ -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"