gmicloud 0.1.5__py3-none-any.whl → 0.1.7__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,246 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: gmicloud
3
- Version: 0.1.5
4
- Summary: GMI Cloud Python SDK
5
- Author-email: GMI <gmi@gmitec.net>
6
- License: MIT
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.6
11
- Description-Content-Type: text/markdown
12
-
13
- # GMICloud SDK (Beta)
14
-
15
- ## Overview
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.
17
-
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.
19
-
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.
21
-
22
- ## Features
23
-
24
- - Artifact Management: Easily create, update, and manage ML model artifacts.
25
- - Task Management: Quickly create, schedule, and manage deployment tasks for model inference.
26
- - Usage Data Retrieval : Fetch and analyze usage data to optimize resource allocation.
27
-
28
- ## Installation
29
-
30
- To install the SDK, use pip:
31
-
32
- ```bash
33
- pip install gmicloud
34
- ```
35
-
36
- ## Setup
37
-
38
- You must configure authentication credentials for accessing the GMI Cloud API. There are two ways to configure the SDK:
39
-
40
- ### Option 1: Using Environment Variables
41
-
42
- Set the following environment variables:
43
-
44
- ```shell
45
- export GMI_CLOUD_CLIENT_ID=<YOUR_CLIENT_ID>
46
- export GMI_CLOUD_EMAIL=<YOUR_EMAIL>
47
- export GMI_CLOUD_PASSWORD=<YOUR_PASSWORD>
48
- export GMI_CLOUD_API_KEY=<YOUR_API_KEY>
49
- ```
50
-
51
- ### Option 2: Passing Credentials as Parameters
52
-
53
- Pass `client_id`, `email`, and `password` directly to the Client object when initializing it in your script:
54
-
55
- ```python
56
- from gmicloud import Client
57
-
58
- client = Client(client_id="<YOUR_CLIENT_ID>", email="<YOUR_EMAIL>", password="<YOUR_PASSWORD>")
59
- ```
60
-
61
- ## Quick Start
62
-
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
75
-
76
- This is the simplest example to deploy an existing artifact template:
77
-
78
- ```python
79
- from datetime import datetime
80
- from gmicloud import Client, TaskScheduling, OneOffScheduling
81
- from examples.completion import call_chat_completion
82
-
83
- # Initialize the client
84
- client = Client()
85
-
86
- # Schedule and start a task from an artifact template
87
- task = client.create_task_from_artifact_template(
88
- "qwen_2.5_14b_instruct_template_001",
89
- TaskScheduling(
90
- scheduling_oneoff=OneOffScheduling(
91
- trigger_timestamp=int(datetime.now().timestamp()) + 10, # Delay by 10 seconds
92
- min_replicas=1,
93
- max_replicas=10,
94
- )
95
- )
96
- )
97
-
98
- # Make a chat completion request via the task endpoint
99
- response = call_chat_completion(client, task.task_id)
100
- print(response)
101
- ```
102
-
103
- ### 3. Step-by-Step Example: Create Artifact, Task, and Query the Endpoint
104
-
105
- #### (a) Create an Artifact from a Template
106
-
107
- First, you’ll retrieve all templates and create an artifact based on the desired template (e.g., "Llama3.1 8B"):
108
-
109
- ```python
110
- from gmicloud import *
111
-
112
-
113
- def create_artifact_from_template(client: Client) -> str:
114
- artifact_manager = client.artifact_manager
115
-
116
- # Get all artifact templates
117
- templates = artifact_manager.get_public_templates()
118
- for template in templates:
119
- if template.artifact_template_id == "qwen_2.5_14b_instruct_template_001":
120
- # Create an artifact from a template
121
- artifact_id = artifact_manager.create_artifact_from_template(
122
- artifact_template_id=template.artifact_template_id,
123
- )
124
-
125
- return artifact_id
126
-
127
- return ""
128
- ```
129
-
130
- #### (b) Create a Task from the Artifact
131
-
132
- Wait until the artifact becomes "ready" and then deploy it using task scheduling:
133
-
134
- ```python
135
- from gmicloud import *
136
- import time
137
- from datetime import datetime
138
-
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
142
- while True:
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
152
- time.sleep(2)
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
- )
175
- ),
176
- ),
177
- ))
178
-
179
- # Start the task
180
- task_manager.start_task(task.task_id)
181
- except Exception as e:
182
- raise e
183
-
184
- return task.task_id
185
- ```
186
-
187
- ### (c) Query the Model Endpoint
188
-
189
- Once the task is running, use the endpoint for inference:
190
-
191
- ```python
192
- from gmicloud import *
193
- from examples.completion import call_chat_completion
194
-
195
- # Initialize the Client
196
- cli = Client()
197
-
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))
206
- ```
207
-
208
- ## API Reference
209
-
210
- ### Client
211
-
212
- Represents the entry point to interact with GMI Cloud APIs.
213
- Client(
214
- client_id: Optional[str] = "",
215
- email: Optional[str] = "",
216
- password: Optional[str] = ""
217
- )
218
-
219
- ### Artifact Management
220
-
221
- * get_artifact_templates(): Fetch a list of available artifact templates.
222
- * create_artifact_from_template(template_id: str): Create a model artifact from a given template.
223
- * get_artifact(artifact_id: str): Get details of a specific artifact.
224
-
225
- ### Task Management
226
-
227
- * create_task_from_artifact_template(template_id: str, scheduling: TaskScheduling): Create and schedule a task using an
228
- artifact template.
229
- * start_task(task_id: str): Start a task.
230
- * get_task(task_id: str): Retrieve the status and details of a specific task.
231
-
232
- ## Notes & Troubleshooting
233
-
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.
238
-
239
- ## Contributing
240
-
241
- We welcome contributions to enhance the SDK. Please follow these steps:
242
-
243
- 1. Fork the repository.
244
- 2. Create a new branch for your feature or bugfix.
245
- 3. Commit changes with clear messages.
246
- 4. Submit a pull request for review.
@@ -1,27 +0,0 @@
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,,