opengradient 0.2.0__tar.gz → 0.2.1__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.
- {opengradient-0.2.0/src/opengradient.egg-info → opengradient-0.2.1}/PKG-INFO +1 -1
- {opengradient-0.2.0 → opengradient-0.2.1}/pyproject.toml +1 -1
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/__init__.py +8 -8
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/client.py +22 -22
- {opengradient-0.2.0 → opengradient-0.2.1/src/opengradient.egg-info}/PKG-INFO +1 -1
- {opengradient-0.2.0 → opengradient-0.2.1}/LICENSE +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/README.md +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/setup.cfg +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/abi/inference.abi +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/cli.py +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/exceptions.py +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/types.py +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient/utils.py +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient.egg-info/SOURCES.txt +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient.egg-info/dependency_links.txt +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient.egg-info/entry_points.txt +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient.egg-info/requires.txt +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/src/opengradient.egg-info/top_level.txt +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/tests/test_api.py +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/tests/test_exceptions.py +0 -0
- {opengradient-0.2.0 → opengradient-0.2.1}/tests/test_integration.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "opengradient"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "A Python SDK for OpenGradient inference services"
|
|
9
9
|
authors = [{name = "OpenGradient", email = "oliver@opengradient.ai"}]
|
|
10
10
|
license = {file = "LICENSE"}
|
|
@@ -2,7 +2,7 @@ from .client import Client
|
|
|
2
2
|
from .exceptions import OpenGradientError, FileNotFoundError, UploadError, InferenceError, ResultRetrievalError
|
|
3
3
|
from .types import ModelInput, InferenceMode, Number, NumberTensor, StringTensor, ModelOutput
|
|
4
4
|
|
|
5
|
-
__version__ = "0.2.
|
|
5
|
+
__version__ = "0.2.1"
|
|
6
6
|
|
|
7
7
|
_client = None
|
|
8
8
|
|
|
@@ -10,25 +10,25 @@ def init(private_key, rpc_url, contract_address, email="test@test.com", password
|
|
|
10
10
|
global _client
|
|
11
11
|
_client = Client(private_key=private_key, rpc_url=rpc_url, contract_address=contract_address, email=email, password=password)
|
|
12
12
|
|
|
13
|
-
def upload(model_path,
|
|
13
|
+
def upload(model_path, model_name, version):
|
|
14
14
|
if _client is None:
|
|
15
15
|
raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
|
|
16
|
-
return _client.upload(model_path,
|
|
16
|
+
return _client.upload(model_path, model_name, version)
|
|
17
17
|
|
|
18
18
|
def create_model(model_name, model_desc):
|
|
19
19
|
if _client is None:
|
|
20
20
|
raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
|
|
21
|
-
return _client.create_model(model_name,model_desc)
|
|
21
|
+
return _client.create_model(model_name, model_desc)
|
|
22
22
|
|
|
23
|
-
def create_version(
|
|
23
|
+
def create_version(model_name, notes=None, is_major=False):
|
|
24
24
|
if _client is None:
|
|
25
25
|
raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
|
|
26
|
-
return _client.create_version(
|
|
26
|
+
return _client.create_version(model_name, notes, is_major)
|
|
27
27
|
|
|
28
|
-
def infer(
|
|
28
|
+
def infer(model_cid, inference_mode, model_input):
|
|
29
29
|
if _client is None:
|
|
30
30
|
raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
|
|
31
|
-
return _client.infer(
|
|
31
|
+
return _client.infer(model_cid, inference_mode, model_input)
|
|
32
32
|
|
|
33
33
|
def sign_in_with_email_and_password(email: str, password: str):
|
|
34
34
|
if _client is None:
|
|
@@ -67,14 +67,14 @@ class Client:
|
|
|
67
67
|
else:
|
|
68
68
|
logging.error("No user is currently signed in")
|
|
69
69
|
|
|
70
|
-
def create_model(self, model_name: str, model_desc: str,
|
|
70
|
+
def create_model(self, model_name: str, model_desc: str, version: str = "1.00") -> dict:
|
|
71
71
|
"""
|
|
72
|
-
Create a new model with the given model_name and model_desc, and a specified version
|
|
72
|
+
Create a new model with the given model_name and model_desc, and a specified version.
|
|
73
73
|
|
|
74
74
|
Args:
|
|
75
75
|
model_name (str): The name of the model.
|
|
76
76
|
model_desc (str): The description of the model.
|
|
77
|
-
|
|
77
|
+
version (str): The version identifier (default is "1.00").
|
|
78
78
|
|
|
79
79
|
Returns:
|
|
80
80
|
dict: The server response containing model details.
|
|
@@ -111,13 +111,13 @@ class Client:
|
|
|
111
111
|
|
|
112
112
|
# Create the specified version for the newly created model
|
|
113
113
|
try:
|
|
114
|
-
version_response = self.create_version(model_id,
|
|
115
|
-
logging.info(f"Version creation successful. Version
|
|
114
|
+
version_response = self.create_version(model_id, version)
|
|
115
|
+
logging.info(f"Version creation successful. Version String: {version_response['versionString']}")
|
|
116
116
|
except Exception as ve:
|
|
117
117
|
logging.error(f"Version creation failed, but model was created. Error: {str(ve)}")
|
|
118
|
-
return {"id": model_id, "
|
|
118
|
+
return {"id": model_id, "versionString": None, "version_error": str(ve)}
|
|
119
119
|
|
|
120
|
-
return {"id": model_id, "
|
|
120
|
+
return {"id": model_id, "versionString": version_response["versionString"]}
|
|
121
121
|
|
|
122
122
|
except requests.RequestException as e:
|
|
123
123
|
logging.error(f"Model creation failed: {str(e)}")
|
|
@@ -130,12 +130,12 @@ class Client:
|
|
|
130
130
|
logging.error(f"Unexpected error during model creation: {str(e)}")
|
|
131
131
|
raise
|
|
132
132
|
|
|
133
|
-
def create_version(self,
|
|
133
|
+
def create_version(self, model_name: str, notes: str = None, is_major: bool = False) -> dict:
|
|
134
134
|
"""
|
|
135
135
|
Create a new version for the specified model.
|
|
136
136
|
|
|
137
137
|
Args:
|
|
138
|
-
|
|
138
|
+
model_name (str): The unique identifier for the model.
|
|
139
139
|
notes (str, optional): Notes for the new version.
|
|
140
140
|
is_major (bool, optional): Whether this is a major version update. Defaults to False.
|
|
141
141
|
|
|
@@ -148,7 +148,7 @@ class Client:
|
|
|
148
148
|
if not self.user:
|
|
149
149
|
raise ValueError("User not authenticated")
|
|
150
150
|
|
|
151
|
-
url = f"https://api.opengradient.ai/api/v0/models/{
|
|
151
|
+
url = f"https://api.opengradient.ai/api/v0/models/{model_name}/versions"
|
|
152
152
|
headers = {
|
|
153
153
|
'Authorization': f'Bearer {self.user["idToken"]}',
|
|
154
154
|
'Content-Type': 'application/json'
|
|
@@ -172,14 +172,14 @@ class Client:
|
|
|
172
172
|
|
|
173
173
|
if isinstance(json_response, list) and not json_response:
|
|
174
174
|
logging.info(f"Server returned an empty list. Assuming version was created successfully.")
|
|
175
|
-
return {"
|
|
175
|
+
return {"versionString": "Unknown", "note": "Created based on empty response"}
|
|
176
176
|
elif isinstance(json_response, dict):
|
|
177
|
-
|
|
178
|
-
if not
|
|
179
|
-
logging.warning(f"'
|
|
180
|
-
return {"
|
|
181
|
-
logging.info(f"Version creation successful. Version
|
|
182
|
-
return {"
|
|
177
|
+
version_string = json_response.get('versionString') or json_response.get('id')
|
|
178
|
+
if not version_string:
|
|
179
|
+
logging.warning(f"'versionString' not found in response. Response: {json_response}")
|
|
180
|
+
return {"versionString": "Unknown", "note": "Version String not provided in response"}
|
|
181
|
+
logging.info(f"Version creation successful. Version String: {version_string}")
|
|
182
|
+
return {"versionString": version_string}
|
|
183
183
|
else:
|
|
184
184
|
logging.error(f"Unexpected response type: {type(json_response)}. Content: {json_response}")
|
|
185
185
|
raise Exception(f"Unexpected response type: {type(json_response)}")
|
|
@@ -195,14 +195,14 @@ class Client:
|
|
|
195
195
|
logging.error(f"Unexpected error during version creation: {str(e)}")
|
|
196
196
|
raise
|
|
197
197
|
|
|
198
|
-
def upload(self, model_path: str,
|
|
198
|
+
def upload(self, model_path: str, model_name: str, version: str) -> dict:
|
|
199
199
|
"""
|
|
200
200
|
Upload a model file to the server.
|
|
201
201
|
|
|
202
202
|
Args:
|
|
203
203
|
model_path (str): The path to the model file.
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
model_name (str): The unique identifier for the model.
|
|
205
|
+
version (str): The version identifier for the model.
|
|
206
206
|
|
|
207
207
|
Returns:
|
|
208
208
|
dict: The server response containing the model CID and size.
|
|
@@ -218,7 +218,7 @@ class Client:
|
|
|
218
218
|
if not os.path.exists(model_path):
|
|
219
219
|
raise FileNotFoundError(f"Model file not found: {model_path}")
|
|
220
220
|
|
|
221
|
-
url = f"https://api.opengradient.ai/api/v0/models/{
|
|
221
|
+
url = f"https://api.opengradient.ai/api/v0/models/{model_name}/versions/{version}/files"
|
|
222
222
|
headers = {
|
|
223
223
|
'Authorization': f'Bearer {self.user["idToken"]}'
|
|
224
224
|
}
|
|
@@ -284,7 +284,7 @@ class Client:
|
|
|
284
284
|
Perform inference on a model.
|
|
285
285
|
|
|
286
286
|
Args:
|
|
287
|
-
|
|
287
|
+
model_cid (str): The unique content identifier for the model from IPFS.
|
|
288
288
|
inference_mode (InferenceMode): The inference mode.
|
|
289
289
|
model_input (Dict[str, Union[str, int, float, List, np.ndarray]]): The input data for the model.
|
|
290
290
|
|
|
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
|