gmicloud 0.1.3__py3-none-any.whl → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gmicloud
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: GMI Cloud Python SDK
5
5
  Author-email: GMI <gmi@gmitec.net>
6
6
  License: MIT
@@ -13,16 +13,11 @@ Description-Content-Type: text/markdown
13
13
  # GMICloud SDK (Beta)
14
14
 
15
15
  ## Overview
16
-
17
16
  Before you start: Our service and GPU resource is currenly invite-only so please contact our team (getstarted@gmicloud.ai) to get invited if you don't have one yet.
18
17
 
19
- The GMI Inference Engine SDK provides a Python interface for deploying and managing machine learning models in
20
- production environments. It allows users to create model artifacts, schedule tasks for serving models, and call
21
- inference APIs easily.
18
+ The GMI Inference Engine SDK provides a Python interface for deploying and managing machine learning models in production environments. It allows users to create model artifacts, schedule tasks for serving models, and call inference APIs easily.
22
19
 
23
- This SDK streamlines the process of utilizing GMI Cloud capabilities such as deploying models with Kubernetes-based Ray
24
- services, managing resources automatically, and accessing model inference endpoints. With minimal setup, developers can
25
- focus on building ML solutions instead of infrastructure.
20
+ This SDK streamlines the process of utilizing GMI Cloud capabilities such as deploying models with Kubernetes-based Ray services, managing resources automatically, and accessing model inference endpoints. With minimal setup, developers can focus on building ML solutions instead of infrastructure.
26
21
 
27
22
  ## Features
28
23
 
@@ -50,6 +45,7 @@ Set the following environment variables:
50
45
  export GMI_CLOUD_CLIENT_ID=<YOUR_CLIENT_ID>
51
46
  export GMI_CLOUD_EMAIL=<YOUR_EMAIL>
52
47
  export GMI_CLOUD_PASSWORD=<YOUR_PASSWORD>
48
+ export GMI_CLOUD_API_KEY=<YOUR_API_KEY>
53
49
  ```
54
50
 
55
51
  ### Option 2: Passing Credentials as Parameters
@@ -64,7 +60,18 @@ client = Client(client_id="<YOUR_CLIENT_ID>", email="<YOUR_EMAIL>", password="<Y
64
60
 
65
61
  ## Quick Start
66
62
 
67
- ### 1. Create a Task from an Artifact Template
63
+ ### 1. How to run the code in the example folder
64
+ ```bash
65
+ cd path/to/gmicloud-sdk
66
+ # Create a virtual environment
67
+ python -m venv venv
68
+ source venv/bin/activate
69
+
70
+ pip install -r requirements.txt
71
+ python -m examples.create_task_from_artifact_template.py
72
+ ```
73
+
74
+ ### 2. Create a Task from an Artifact Template
68
75
 
69
76
  This is the simplest example to deploy an existing artifact template:
70
77
 
@@ -93,24 +100,31 @@ response = call_chat_completion(client, task.task_id)
93
100
  print(response)
94
101
  ```
95
102
 
96
- ### 2. Step-by-Step Example: Create Artifact, Task, and Query the Endpoint
103
+ ### 3. Step-by-Step Example: Create Artifact, Task, and Query the Endpoint
97
104
 
98
105
  #### (a) Create an Artifact from a Template
99
106
 
100
107
  First, you’ll retrieve all templates and create an artifact based on the desired template (e.g., "Llama3.1 8B"):
101
108
 
102
109
  ```python
103
- def create_artifact_from_template(client):
110
+ from gmicloud import *
111
+
112
+
113
+ def create_artifact_from_template(client: Client) -> str:
104
114
  artifact_manager = client.artifact_manager
105
115
 
106
- # List all available templates
107
- templates = artifact_manager.get_artifact_templates()
116
+ # Get all artifact templates
117
+ templates = artifact_manager.get_public_templates()
108
118
  for template in templates:
109
119
  if template.artifact_template_id == "qwen_2.5_14b_instruct_template_001":
110
- return artifact_manager.create_artifact_from_template(
111
- artifact_template_id=template.artifact_template_id
120
+ # Create an artifact from a template
121
+ artifact_id = artifact_manager.create_artifact_from_template(
122
+ artifact_template_id=template.artifact_template_id,
112
123
  )
113
- return None
124
+
125
+ return artifact_id
126
+
127
+ return ""
114
128
  ```
115
129
 
116
130
  #### (b) Create a Task from the Artifact
@@ -118,43 +132,55 @@ def create_artifact_from_template(client):
118
132
  Wait until the artifact becomes "ready" and then deploy it using task scheduling:
119
133
 
120
134
  ```python
121
- def create_task_and_start(client, artifact_id):
122
- artifact_manager = client.artifact_manager
135
+ from gmicloud import *
136
+ import time
137
+ from datetime import datetime
123
138
 
124
- # Wait until the artifact is ready
139
+ def create_task_and_start(client: Client, artifact_id: str) -> str:
140
+ artifact_manager = client.artifact_manager
141
+ # Wait for the artifact to be ready
125
142
  while True:
126
- artifact = artifact_manager.get_artifact(artifact_id)
127
- if artifact.build_status == "SUCCESS":
128
- break
129
- print("Waiting for artifact to be ready...")
143
+ try:
144
+ artifact = artifact_manager.get_artifact(artifact_id)
145
+ print(f"Artifact status: {artifact.build_status}")
146
+ # Wait until the artifact is ready
147
+ if artifact.build_status == BuildStatus.SUCCESS:
148
+ break
149
+ except Exception as e:
150
+ raise e
151
+ # Wait for 2 seconds
130
152
  time.sleep(2)
131
-
132
- # Configure and start the task
133
- task_manager = client.task_manager
134
- task = task_manager.create_task(Task(
135
- config=TaskConfig(
136
- ray_task_config=RayTaskConfig(
137
- ray_version="2.40.0-py310-gpu",
138
- file_path="serve",
139
- artifact_id=artifact_id,
140
- deployment_name="app",
141
- replica_resource=ReplicaResource(
142
- cpu=10,
143
- ram_gb=100,
144
- gpu=1,
153
+ try:
154
+ task_manager = client.task_manager
155
+ # Create a task
156
+ task = task_manager.create_task(Task(
157
+ config=TaskConfig(
158
+ ray_task_config=RayTaskConfig(
159
+ ray_version="2.40.0-py310-gpu",
160
+ file_path="serve",
161
+ artifact_id=artifact_id,
162
+ deployment_name="app",
163
+ replica_resource=ReplicaResource(
164
+ cpu=10,
165
+ ram_gb=100,
166
+ gpu=1,
167
+ ),
168
+ ),
169
+ task_scheduling=TaskScheduling(
170
+ scheduling_oneoff=OneOffScheduling(
171
+ trigger_timestamp=int(datetime.now().timestamp()) + 10,
172
+ min_replicas=1,
173
+ max_replicas=10,
174
+ )
145
175
  ),
146
176
  ),
147
- task_scheduling=TaskScheduling(
148
- scheduling_oneoff=OneOffScheduling(
149
- trigger_timestamp=int(datetime.now().timestamp()) + 10,
150
- min_replicas=1,
151
- max_replicas=10,
152
- )
153
- ),
154
- ),
155
- ))
177
+ ))
178
+
179
+ # Start the task
180
+ task_manager.start_task(task.task_id)
181
+ except Exception as e:
182
+ raise e
156
183
 
157
- task_manager.start_task(task.task_id)
158
184
  return task.task_id
159
185
  ```
160
186
 
@@ -163,14 +189,20 @@ def create_task_and_start(client, artifact_id):
163
189
  Once the task is running, use the endpoint for inference:
164
190
 
165
191
  ```python
192
+ from gmicloud import *
166
193
  from examples.completion import call_chat_completion
167
194
 
168
- client = Client()
169
- artifact_id = create_artifact_from_template(client)
170
- task_id = create_task_and_start(client, artifact_id)
195
+ # Initialize the Client
196
+ cli = Client()
171
197
 
172
- response = call_chat_completion(client, task_id)
173
- print(response)
198
+ # Create an artifact from a template
199
+ artifact_id = create_artifact_from_template(cli)
200
+
201
+ # Create a task and start it
202
+ task_id = create_task_and_start(cli, artifact_id)
203
+
204
+ # Call chat completion
205
+ print(call_chat_completion(cli, task_id))
174
206
  ```
175
207
 
176
208
  ## API Reference
@@ -199,10 +231,10 @@ password: Optional[str] = ""
199
231
 
200
232
  ## Notes & Troubleshooting
201
233
 
202
- Ensure Credentials are Correct: Double-check your environment variables or parameters passed into the Client object.
203
- Artifact Status: It may take a few minutes for an artifact or task to transition to the "running" state.
204
- Inference Endpoint Readiness: Use the task endpoint only after the task status changes to "running".
205
- Default OpenAI Key: By default, the OpenAI API base URL is derived from the endpoint provided by GMI.
234
+ * Ensure Credentials are Correct: Double-check your environment variables or parameters passed into the Client object.
235
+ * Artifact Status: It may take a few minutes for an artifact or task to transition to the "running" state.
236
+ * Inference Endpoint Readiness: Use the task endpoint only after the task status changes to "running".
237
+ * Default OpenAI Key: By default, the OpenAI API base URL is derived from the endpoint provided by GMI.
206
238
 
207
239
  ## Contributing
208
240
 
@@ -0,0 +1,27 @@
1
+ gmicloud/__init__.py,sha256=aIgu4MAw4nExv781-pzSZLG8MscqAMZ5lM5fGyqg7QU,984
2
+ gmicloud/client.py,sha256=RzI-T5FHMxb_OrDFadmi_WJ5EP6S1on3tR-z1ajyuPo,5598
3
+ gmicloud/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ gmicloud/_internal/_config.py,sha256=qIH76TSyS3MQWe62LHI46RJhDnklNFisdajY75oUAqE,218
5
+ gmicloud/_internal/_constants.py,sha256=Y085dwFlqdFkCf39iBfxz39QiiB7lX59ayNJjB86_m4,378
6
+ gmicloud/_internal/_enums.py,sha256=5Z0MZksO1rjHVu24ZF29yYorYJjrYR45WKGL7_EGKUE,686
7
+ gmicloud/_internal/_exceptions.py,sha256=hScBq7n2fOit4_umlkabZJchY8zVbWSRfWM2Y0rLCbw,306
8
+ gmicloud/_internal/_models.py,sha256=OsgRTdzFaMC8EdqLZGH9g66vPjgntV6Jg2eJo-P7SZE,16962
9
+ gmicloud/_internal/_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ gmicloud/_internal/_client/_artifact_client.py,sha256=-CyMdTauVovuv3whs8yUqmv3-WW2e9m2GoEG9D6eNbc,8374
11
+ gmicloud/_internal/_client/_decorator.py,sha256=sy4gxzsUB6ORXHw5pqmMf7TTlK41Nmu1fhIhK2AIsbY,670
12
+ gmicloud/_internal/_client/_file_upload_client.py,sha256=1JRs4X57S3EScPIP9w2DC1Uo6_Wbcjumcw3nVM7uIGM,4667
13
+ gmicloud/_internal/_client/_http_client.py,sha256=j--3emTjJ_l9CTdnkTbcpf7gYcUEl341pv2O5cU67l0,5741
14
+ gmicloud/_internal/_client/_iam_client.py,sha256=pgOXIqp9aJvcIUCEVkYPEyMUyxBftecojHAbs8Gbl94,7013
15
+ gmicloud/_internal/_client/_task_client.py,sha256=69OqZC_kwSDkTSVVyi51Tn_OyUV6R0nin4z4gLfZ-Lg,6141
16
+ gmicloud/_internal/_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ gmicloud/_internal/_manager/_artifact_manager.py,sha256=yHNAcCPd-tFerSzDojdDuFDzk6SldbzLPGAW_hyDeF4,12568
18
+ gmicloud/_internal/_manager/_iam_manager.py,sha256=nAqPCaUfSXTnx2MEQa8e0YUOBFYWDRiETgK1PImdf4o,1167
19
+ gmicloud/_internal/_manager/_task_manager.py,sha256=6dQ4yr22F3vljWkpa5hR5PQ3QuFGVU-pOnN1XwZQEBY,8304
20
+ gmicloud/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ gmicloud/tests/test_artifacts.py,sha256=q1jiTk5DN4G3LCLCO_8KbWArdc6RG3sETe1MCEt-vbI,16979
22
+ gmicloud/tests/test_tasks.py,sha256=yL-aFf80ShgTyxEONTWh-xbWDf5XnUNtIeA5hYvhKM0,10963
23
+ gmicloud/utils/uninstall_packages.py,sha256=zzuuaJPf39oTXWZ_7tUAGseoxocuCbbkoglJSD5yDrE,1127
24
+ gmicloud-0.1.5.dist-info/METADATA,sha256=0lXsAQuoEisnxbuT9EfUbi42qlDL6IcZl7fggJNwIx4,7757
25
+ gmicloud-0.1.5.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
26
+ gmicloud-0.1.5.dist-info/top_level.txt,sha256=AZimLw3y0WPpLiSiOidZ1gD0dxALh-jQNk4fxC05hYE,9
27
+ gmicloud-0.1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,26 +0,0 @@
1
- gmicloud/__init__.py,sha256=AJP9Z3Ba-AClp5P49YL32qH5-XzDTbEXhWZFF1iLP8Q,750
2
- gmicloud/client.py,sha256=G3sgH7zzODhdW_Ad56xgomDWXKAhnjzZuj1_mEBGYCI,4733
3
- gmicloud/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- gmicloud/_internal/_config.py,sha256=qIH76TSyS3MQWe62LHI46RJhDnklNFisdajY75oUAqE,218
5
- gmicloud/_internal/_constants.py,sha256=Y085dwFlqdFkCf39iBfxz39QiiB7lX59ayNJjB86_m4,378
6
- gmicloud/_internal/_enums.py,sha256=C4oy6Ps7OGdYd3tK-Wcpi6uXMyAKbOZW8_KykYAKsgw,510
7
- gmicloud/_internal/_exceptions.py,sha256=hScBq7n2fOit4_umlkabZJchY8zVbWSRfWM2Y0rLCbw,306
8
- gmicloud/_internal/_models.py,sha256=1yUk1yIyfXybIeR8guwYLbXc8gAKzXRpIZ7_6SOId28,13212
9
- gmicloud/_internal/_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- gmicloud/_internal/_client/_artifact_client.py,sha256=py6SQ1tVoK365hIIxnla433mpCapActZ6KE6Yakds-8,5588
11
- gmicloud/_internal/_client/_decorator.py,sha256=sy4gxzsUB6ORXHw5pqmMf7TTlK41Nmu1fhIhK2AIsbY,670
12
- gmicloud/_internal/_client/_file_upload_client.py,sha256=1JRs4X57S3EScPIP9w2DC1Uo6_Wbcjumcw3nVM7uIGM,4667
13
- gmicloud/_internal/_client/_http_client.py,sha256=F7qpq6WLp6PJkqusWojdi483LijWBsSIY43NjJcyXNU,5704
14
- gmicloud/_internal/_client/_iam_client.py,sha256=D7PhQerSzjGGerXsd5Si-e-Wa5f-fJpOACkfWOnkPJg,2979
15
- gmicloud/_internal/_client/_task_client.py,sha256=JgYewfDy2iblRVrc9sdA8RbcooXyAho79ESuCK8PRWI,3842
16
- gmicloud/_internal/_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- gmicloud/_internal/_manager/_artifact_manager.py,sha256=cc367Kd-W9Zn2d_wUcG6tT06544HRItIZ5IsFfA5_RQ,12201
18
- gmicloud/_internal/_manager/_task_manager.py,sha256=QQfpYXFKAAI_FSI--Nxvjlgf_jeVZuVnTuRGTQzrZso,8034
19
- gmicloud/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- gmicloud/tests/test_artifacts.py,sha256=YiC1HBMS7g491Ra4acTLI9AdwyjXZfnY9f-fNKn2azQ,17108
21
- gmicloud/tests/test_tasks.py,sha256=AY90zTJdsXk1cxn6Jxhi4TDdwXRiGxz_r_aRk_Jkl8Y,10956
22
- gmicloud/utils/uninstall_packages.py,sha256=zzuuaJPf39oTXWZ_7tUAGseoxocuCbbkoglJSD5yDrE,1127
23
- gmicloud-0.1.3.dist-info/METADATA,sha256=OuNXnrFTE_tTDuArqevbW81fKwB--E23YUv6-uj91u0,6808
24
- gmicloud-0.1.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
- gmicloud-0.1.3.dist-info/top_level.txt,sha256=AZimLw3y0WPpLiSiOidZ1gD0dxALh-jQNk4fxC05hYE,9
26
- gmicloud-0.1.3.dist-info/RECORD,,