opengradient 0.2.4__py3-none-any.whl → 0.2.5__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 CHANGED
@@ -2,11 +2,15 @@ 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.4"
5
+ __version__ = "0.2.5"
6
6
 
7
7
  _client = None
8
8
 
9
- def init(private_key, rpc_url, contract_address, email="test@test.com", password="Test-123"):
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"):
10
14
  global _client
11
15
  _client = Client(private_key=private_key, rpc_url=rpc_url, contract_address=contract_address, email=email, password=password)
12
16
 
@@ -30,7 +34,7 @@ def infer(model_cid, inference_mode, model_input):
30
34
  raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
31
35
  return _client.infer(model_cid, inference_mode, model_input)
32
36
 
33
- def sign_in_with_email_and_password(email: str, password: str):
37
+ def login(email: str, password: str):
34
38
  if _client is None:
35
39
  raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
36
- return _client.sign_in_with_email_and_password(email, password)
40
+ return _client.login(email, password)
opengradient/cli.py CHANGED
@@ -40,8 +40,8 @@ Dict = DictParamType()
40
40
  # Support inference modes
41
41
  InferenceModes = {
42
42
  "VANILLA": opengradient.InferenceMode.VANILLA,
43
- "ZKML": opengradient.InferenceMode.PRIVATE,
44
- "TEE": opengradient.InferenceMode.VERIFIED,
43
+ "ZKML": opengradient.InferenceMode.ZKML,
44
+ "TEE": opengradient.InferenceMode.TEE,
45
45
  }
46
46
 
47
47
  # TODO (Kyle): Once we're farther into development, we should remove the defaults for these options
@@ -89,9 +89,14 @@ def cli(ctx, api_key, rpc_url, contract_address, email, password):
89
89
  click.echo(f"Failed to create OpenGradient client: {str(e)}")
90
90
 
91
91
  @cli.command()
92
- @click.pass_obj
93
- def client_settings(client):
92
+ @click.pass_context
93
+ def client_settings(ctx):
94
94
  """Display OpenGradient client settings"""
95
+ client = ctx.obj
96
+ if not client:
97
+ click.echo("Client not initialized")
98
+ ctx.exit(1)
99
+
95
100
  click.echo("Settings for OpenGradient client:")
96
101
  click.echo(f"\tAPI key ({API_KEY_ENV}): {client.private_key}")
97
102
  click.echo(f"\tRPC URL ({RPC_URL_ENV}): {client.rpc_url}")
@@ -140,14 +145,14 @@ def create_version(client, model_id, notes, is_major):
140
145
  click.echo(f"Error creating version: {str(e)}")
141
146
 
142
147
  @cli.command()
143
- @click.argument('model_id', type=str)
148
+ @click.argument('model_cid', type=str)
144
149
  @click.argument('inference_mode', type=click.Choice(InferenceModes.keys()), default="VANILLA")
145
150
  @click.argument('input_data', type=Dict, required=False)
146
151
  @click.option('--input_file',
147
152
  type=click.Path(exists=True, file_okay=True, dir_okay=False, readable=True, path_type=Path),
148
153
  help="Optional file input for model inference -- must be JSON")
149
154
  @click.pass_context
150
- def infer(ctx, model_id, inference_mode, input_data, input_file):
155
+ def infer(ctx, model_cid, inference_mode, input_data, input_file):
151
156
  """Run inference on a model"""
152
157
  client = ctx.obj
153
158
  try:
@@ -169,8 +174,8 @@ def infer(ctx, model_id, inference_mode, input_data, input_file):
169
174
  model_input = json.load(file)
170
175
 
171
176
  # Parse input data from string to dict
172
- click.echo(f"Running {inference_mode} inference for {model_id}...")
173
- tx_hash, model_output = client.infer(model_cid=model_id, inference_mode=InferenceModes[inference_mode], model_input=model_input)
177
+ click.echo(f"Running {inference_mode} inference for {model_cid}...")
178
+ tx_hash, model_output = client.infer(model_cid=model_cid, inference_mode=InferenceModes[inference_mode], model_input=model_input)
174
179
  click.secho("Success!", fg="green")
175
180
  click.echo(f"\nTransaction Hash: \n{tx_hash}")
176
181
  click.echo(f"\nInference result: \n{model_output}")
opengradient/client.py CHANGED
@@ -49,7 +49,7 @@ class Client:
49
49
  inference_abi = json.load(abi_file)
50
50
  self.abi = inference_abi
51
51
 
52
- self.sign_in_with_email_and_password(email, password)
52
+ self.login(email, password)
53
53
 
54
54
  def _initialize_web3(self):
55
55
  """
@@ -104,20 +104,20 @@ class Client:
104
104
  response.raise_for_status()
105
105
 
106
106
  json_response = response.json()
107
- res_model_name = json_response.get('name')
108
- if not res_model_name:
109
- raise Exception(f"Model creation response missing 'name'. Full response: {json_response}")
110
- logging.info(f"Model creation successful. Model name: {res_model_name}")
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}")
111
111
 
112
112
  # Create the specified version for the newly created model
113
113
  try:
114
- version_response = self.create_version(res_model_name, version)
115
- logging.info(f"Version creation successful. Version String: {version_response['versionString']}")
114
+ version_response = self.create_version(model_id, version)
115
+ logging.info(f"Version creation successful. Version ID: {version_response['version_id']}")
116
116
  except Exception as ve:
117
117
  logging.error(f"Version creation failed, but model was created. Error: {str(ve)}")
118
- return {"id": res_model_name, "versionString": None, "version_error": str(ve)}
118
+ return {"id": model_id, "version_id": None, "version_error": str(ve)}
119
119
 
120
- return {"name": res_model_name, "versionString": version_response["versionString"]}
120
+ return {"id": model_id, "version_id": version_response["version_id"]}
121
121
 
122
122
  except requests.RequestException as e:
123
123
  logging.error(f"Model creation failed: {str(e)}")
@@ -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 {"versionString": "Unknown", "note": "Created based on empty response"}
175
+ return {"version_id": "Unknown", "note": "Created based on empty response"}
176
176
  elif isinstance(json_response, dict):
177
- version_string = json_response.get('versionString')
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}
177
+ version_id = json_response.get('version_id') or json_response.get('id')
178
+ if not version_id:
179
+ logging.warning(f"'version_id' not found in response. Response: {json_response}")
180
+ return {"version_id": "Unknown", "note": "Version ID not provided in response"}
181
+ logging.info(f"Version creation successful. Version ID: {version_id}")
182
+ return {"version_id": version_id}
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)}")
@@ -394,7 +394,7 @@ class Client:
394
394
  logging.error(f"Error in infer method: {str(e)}", exc_info=True)
395
395
  raise OpenGradientError(f"Inference failed: {str(e)}")
396
396
 
397
- def sign_in_with_email_and_password(self, email, password):
397
+ def login(self, email, password):
398
398
  try:
399
399
  self.user = self.auth.sign_in_with_email_and_password(email, password)
400
400
  return self.user
opengradient/types.py CHANGED
@@ -23,8 +23,8 @@ class ModelInput:
23
23
 
24
24
  class InferenceMode:
25
25
  VANILLA = 0
26
- PRIVATE = 1
27
- VERIFIED = 2
26
+ ZKML = 1
27
+ TEE = 2
28
28
 
29
29
  @dataclass
30
30
  class ModelOutput:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opengradient
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: A Python SDK for OpenGradient inference services
5
5
  Author-email: OpenGradient <oliver@opengradient.ai>
6
6
  License: MIT License
@@ -0,0 +1,13 @@
1
+ opengradient/__init__.py,sha256=KEs28Cnki2uQk3XMb2z2U0wPI7q5JXn0HToJMUmQDZI,1783
2
+ opengradient/cli.py,sha256=U0hEQEab5-D-Abkxs1WmV4Qbalth80MBwBDnOCK4hWc,7354
3
+ opengradient/client.py,sha256=hmBIb_UXMfcAXIfDAd9Baxwd9SDsLzPLBFaH8efS1IY,17978
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.5.dist-info/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
9
+ opengradient-0.2.5.dist-info/METADATA,sha256=VaOmJ1SXmpooKgm1zJKTgXjkSOI4r5YBG4-qs3qxAKs,3000
10
+ opengradient-0.2.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
+ opengradient-0.2.5.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
12
+ opengradient-0.2.5.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
13
+ opengradient-0.2.5.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- opengradient/__init__.py,sha256=Q53D-yMmIiLZm_ccS_Ut2uBr_5Fj7VfYenPxveT47fI,1658
2
- opengradient/cli.py,sha256=pj1iU2AdL1R4MtQHehdQMacAXWw5pP5vJRF6CusP7jg,7243
3
- opengradient/client.py,sha256=X9CR4zYHxBJCOC29kYO7wlL6n6Vpjp4eLihGeJHd3Yc,18102
4
- opengradient/exceptions.py,sha256=v4VmUGTvvtjhCZAhR24Ga42z3q-DzR1Y5zSqP_yn2Xk,3366
5
- opengradient/types.py,sha256=NTWQ0HvglQA7d8y6OQDkymToSdCq4NnrVtwQwm_NMMU,1857
6
- opengradient/utils.py,sha256=95i5RVn-32MRsn00M21io8QHLtmEAoRbgueMhDh0TVk,5079
7
- opengradient/abi/inference.abi,sha256=HH2SmCJ_D4O0I-CFsln0vFHd2PU-A-fxgCnUtHg0ZQg,2373
8
- opengradient-0.2.4.dist-info/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
9
- opengradient-0.2.4.dist-info/METADATA,sha256=zHWlqZPiVqIO8qsUeEGBPqsQJ2RkBoj2ZGyt-9SDbs4,3000
10
- opengradient-0.2.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
- opengradient-0.2.4.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
12
- opengradient-0.2.4.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
13
- opengradient-0.2.4.dist-info/RECORD,,