gmicloud 0.1.6__py3-none-any.whl → 0.1.9__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.
@@ -2,7 +2,7 @@ from typing import Optional, List, Union
2
2
  from datetime import datetime
3
3
 
4
4
  from pydantic import BaseModel
5
- from gmicloud._internal._enums import BuildStatus, TaskStatus, TaskEndpointStatus, ModelParameterType
5
+ from gmicloud._internal._enums import *
6
6
 
7
7
 
8
8
  class BigFileMetadata(BaseModel):
@@ -22,9 +22,13 @@ class ArtifactMetadata(BaseModel):
22
22
  user_id: Optional[str] = "" # The user ID associated with this artifact.
23
23
  artifact_name: Optional[str] = "" # Name of the artifact.
24
24
  artifact_description: Optional[str] = "" # Description of the artifact.
25
- artifact_tags: Optional[List[str]] = "" # Comma-separated tags for categorizing the artifact.
25
+ artifact_tags: Optional[List[str]] = None # Changed from List[str] with default to Optional[List[str]]
26
26
  artifact_volume_path: Optional[str] = "" # Path to the volume where the artifact is stored.
27
27
  artifact_template_id: Optional[str] = "" # The template ID used to create this artifact.
28
+ artifact_icon_link: Optional[str] = "" # Link to the icon for the artifact.
29
+ is_public: Optional[bool] = False # Indicates if the artifact is public.
30
+ org_id: Optional[str] = "" # Organization ID associated with this artifact.
31
+ update_by: Optional[str] = "" # User ID who last updated the artifact.
28
32
 
29
33
 
30
34
  class ArtifactData(BaseModel):
@@ -43,6 +47,29 @@ class ArtifactData(BaseModel):
43
47
  update_at: Optional[datetime] # Timestamp when the artifact was last updated.
44
48
 
45
49
 
50
+ class EnvParameter(BaseModel):
51
+ """
52
+ Environment parameter for an artifact.
53
+ """
54
+ key: str # Key for the environment parameter.
55
+ value: str # Value for the environment parameter.
56
+
57
+
58
+ class ArtifactDetails(BaseModel):
59
+ """
60
+ Additional details for an artifact.
61
+ """
62
+ model_description: Optional[str] = "" # Description of the model.
63
+
64
+
65
+ class ArtifactParameters(BaseModel):
66
+ """
67
+ Parameters for an artifact.
68
+ """
69
+ env_parameters: Optional[List[EnvParameter]] = None # Environment parameters.
70
+ model_parameters: Optional[List["ModelParameter"]] = None # Model parameters.
71
+
72
+
46
73
  class Artifact(BaseModel):
47
74
  """
48
75
  Representation of an artifact, including its data and metadata.
@@ -53,6 +80,7 @@ class Artifact(BaseModel):
53
80
  build_status: Optional[BuildStatus] = None # Status of the artifact build (e.g., in progress, succeeded, failed).
54
81
  artifact_data: Optional[ArtifactData] = None # Data associated with the artifact.
55
82
  artifact_metadata: Optional[ArtifactMetadata] = None # Metadata describing the artifact.
83
+ artifact_parameters: Optional[ArtifactParameters] = None # Parameters for the artifact.
56
84
  big_files_metadata: Optional[List[BigFileMetadata]] = None # Metadata for large files associated with the artifact.
57
85
 
58
86
 
@@ -69,8 +97,13 @@ class CreateArtifactRequest(BaseModel):
69
97
  """
70
98
  artifact_name: str # The name of the artifact to create.
71
99
  artifact_description: Optional[str] = "" # Description of the artifact.
72
- artifact_tags: Optional[List[str]] = None # Tags for the artifact, separated by commas.
100
+ artifact_tags: Optional[List[str]] = None # Tags for the artifact.
101
+ deployment_type: Optional[str] = "" # Deployment type
102
+ template_id: Optional[str] = "" # Template ID
103
+ env_parameters: Optional[List["EnvParameter"]] = None # Environment parameters.
104
+ model_description: Optional[str] = "" # Description of the model.
73
105
  model_parameters: Optional[List["ModelParameter"]] = None # Parameters for the artifact.
106
+ artifact_volume_path: Optional[str] = "" # Path to the volume where the artifact is stored.
74
107
 
75
108
 
76
109
  class CreateArtifactResponse(BaseModel):
@@ -79,9 +112,10 @@ class CreateArtifactResponse(BaseModel):
79
112
  """
80
113
  artifact_id: str # ID of the newly created artifact.
81
114
  upload_link: str # URL to upload the artifact data.
115
+ artifact_icon_link: Optional[str] = "" # Link to the icon for the artifact.
82
116
 
83
117
 
84
- class GetBigFileUploadUrlRequest(BaseModel):
118
+ class ResumableUploadLinkRequest(BaseModel):
85
119
  """
86
120
  Request to generate a pre-signed URL for uploading large files.
87
121
  """
@@ -90,7 +124,7 @@ class GetBigFileUploadUrlRequest(BaseModel):
90
124
  file_type: Optional[str] = "" # MIME type of the file.
91
125
 
92
126
 
93
- class GetBigFileUploadUrlResponse(BaseModel):
127
+ class ResumableUploadLinkResponse(BaseModel):
94
128
  """
95
129
  Response containing a pre-signed upload URL for large files.
96
130
  """
@@ -98,6 +132,13 @@ class GetBigFileUploadUrlResponse(BaseModel):
98
132
  upload_link: str # Pre-signed upload URL for the file.
99
133
 
100
134
 
135
+ class RebuildArtifactRequest(BaseModel):
136
+ """
137
+ Request object for rebuilding an artifact.
138
+ """
139
+ artifact_id: str # ID of the artifact to rebuild.
140
+
141
+
101
142
  class RebuildArtifactResponse(BaseModel):
102
143
  """
103
144
  Response object after rebuilding an artifact.
@@ -106,6 +147,91 @@ class RebuildArtifactResponse(BaseModel):
106
147
  build_status: BuildStatus # Status of the artifact build (e.g., in progress, succeeded, failed).
107
148
 
108
149
 
150
+ class EndpointInfo(BaseModel):
151
+ """
152
+ Additional information about the task endpoint.
153
+ """
154
+ endpoint_status: Optional[TaskEndpointStatus] = None # Current status of the task (e.g., running, stopped).
155
+ endpoint_url: Optional[str] = "" # URL for accessing the task endpoint.
156
+
157
+
158
+ class GetAllArtifactsWithEndpointsResponse(BaseModel):
159
+ """
160
+ Response containing a list of all artifacts with their endpoints.
161
+ """
162
+ artifact_id: str # Unique identifier for the artifact.
163
+ artifact_data: Optional[ArtifactData] = None # Data associated with the artifact.
164
+ artifact_metadata: Optional[ArtifactMetadata] = None # Metadata describing the artifact.
165
+ artifact_details: Optional[ArtifactDetails] = None # Additional details about the artifact.
166
+ artifact_parameters: Optional[ArtifactParameters] = None # Parameters for the artifact.
167
+ big_files_metadata: Optional[List[BigFileMetadata]] = None # Metadata for large files.
168
+ endpoints: Optional[List[EndpointInfo]] = None # Endpoints associated with the artifact.
169
+
170
+
171
+ class GetArtifactResponse(BaseModel):
172
+ """
173
+ Response containing the details of an artifact.
174
+ """
175
+ artifact_id: str # Unique identifier for the artifact.
176
+ artifact_link: Optional[str] = "" # Link to access the artifact.
177
+ artifact_resource: Optional[str] = "" # Resource associated with the artifact.
178
+ build_file_name: Optional[str] = "" # Name of the file used for the build.
179
+ build_status: Optional[str] = "" # Status of the artifact build.
180
+ artifact_metadata: Optional[ArtifactMetadata] = None # Metadata describing the artifact.
181
+ artifact_parameters: Optional[ArtifactParameters] = None # Parameters for the artifact.
182
+ big_files_metadata: Optional[List[BigFileMetadata]] = None # Metadata for large files.
183
+
184
+
185
+ class GetPublicArtifactsResponse(BaseModel):
186
+ """
187
+ Response containing public artifact details.
188
+ """
189
+ artifact_id: str # Unique identifier for the artifact.
190
+ artifact_data: Optional[ArtifactData] = None # Data associated with the artifact.
191
+ artifact_metadata: Optional[ArtifactMetadata] = None # Metadata describing the artifact.
192
+ artifact_details: Optional[ArtifactDetails] = None # Additional details about the artifact.
193
+ artifact_parameters: Optional[ArtifactParameters] = None # Parameters for the artifact.
194
+ endpoints: Optional[List[EndpointInfo]] = None # Endpoints associated with the artifact.
195
+
196
+
197
+ class UpdateArtifactRequestBody(BaseModel):
198
+ """
199
+ Request object for updating an artifact.
200
+ """
201
+ artifact_name: Optional[str] = "" # The name of the artifact.
202
+ artifact_description: Optional[str] = "" # Description of the artifact.
203
+ artifact_tags: Optional[List[str]] = None # Tags for the artifact.
204
+ env_parameters: Optional[List[EnvParameter]] = None # Environment parameters.
205
+ model_description: Optional[str] = "" # Description of the model.
206
+ model_parameters: Optional[List["ModelParameter"]] = None # Parameters for the artifact.
207
+ need_update_icon: Optional[bool] = False # Whether to update the artifact icon.
208
+
209
+
210
+ class UpdateArtifactResponse(BaseModel):
211
+ """
212
+ Response object after updating an artifact.
213
+ """
214
+ artifact_id: str # ID of the updated artifact.
215
+ status: str # Status of the update operation.
216
+ artifact_icon_link: Optional[str] = "" # Link to the icon for the artifact.
217
+
218
+
219
+ class GetTemplatesResponse(BaseModel):
220
+ """
221
+ Response containing a list of artifact templates.
222
+ """
223
+ artifact_templates: list["Template"] # List of artifact templates.
224
+
225
+
226
+ class Template(BaseModel):
227
+ """
228
+ Template for creating an artifact.
229
+ """
230
+ template_id: str # Unique identifier for the artifact template.
231
+ template_data: Optional["TemplateData"] = None # Data for the artifact template.
232
+ template_metadata: Optional["TemplateMetadata"] = None # Metadata for the artifact template.
233
+
234
+
109
235
  class DeleteArtifactResponse(BaseModel):
110
236
  """
111
237
  Response object after deleting an artifact.
@@ -132,22 +258,6 @@ class DeleteBigfileResponse(BaseModel):
132
258
  status: Optional[str] = "" # Status of the deletion process.
133
259
 
134
260
 
135
- class GetPublicTemplatesResponse(BaseModel):
136
- """
137
- Response containing a list of artifact templates.
138
- """
139
- artifact_templates: list["ArtifactTemplate"] # List of artifact templates.
140
-
141
-
142
- class ArtifactTemplate(BaseModel):
143
- """
144
- Template for creating an artifact.
145
- """
146
- template_id: str # Unique identifier for the artifact template.
147
- template_data: Optional["TemplateData"] = None # Data for the artifact template.
148
- template_metadata: Optional["TemplateMetadata"] = None # Metadata for the artifact template.
149
-
150
-
151
261
  class TemplateMetadata(BaseModel):
152
262
  """
153
263
  Metadata for an artifact template.
@@ -158,6 +268,7 @@ class TemplateMetadata(BaseModel):
158
268
  is_public: Optional[bool] = False # Indicates if the template is public.
159
269
  update_at: Optional[str] = None # Timestamp when the template was last updated.
160
270
  update_by: Optional[str] = "" # ID of the user who last updated the template.
271
+ status: Optional[str] = "" # Status of the template.
161
272
 
162
273
 
163
274
  class TemplateData(BaseModel):
@@ -173,6 +284,7 @@ class TemplateData(BaseModel):
173
284
  resources: Optional["ResourcesTemplate"] = None # Resource allocation template.
174
285
  tags: Optional[List[str]] = None # Tags associated with the artifact template.
175
286
  volume_path: Optional[str] = "" # Path to the volume where the artifact is stored.
287
+ env_parameters: Optional[List["EnvParameter"]] = None # Added missing field
176
288
 
177
289
 
178
290
  class ModelParameter(BaseModel):
@@ -204,8 +316,9 @@ class CreateArtifactFromTemplateRequest(BaseModel):
204
316
  """
205
317
  Request object to create a new artifact from a template.
206
318
  """
207
- user_id: str # The user ID creating the artifact.
319
+ # user_id: str # The user ID creating the artifact.
208
320
  artifact_template_id: str # The ID of the artifact template to use.
321
+ env_parameters: Optional[List["EnvParameter"]] = None # Environment parameters.
209
322
 
210
323
 
211
324
  class CreateArtifactFromTemplateResponse(BaseModel):
@@ -304,14 +417,6 @@ class TaskConfig(BaseModel):
304
417
  last_update_timestamp: Optional[int] = 0 # Timestamp when the task was last updated.
305
418
 
306
419
 
307
- class EndpointInfo(BaseModel):
308
- """
309
- Additional information about the task endpoint.
310
- """
311
- endpoint_status: Optional[TaskEndpointStatus] = None # Current status of the task (e.g., running, stopped).
312
- endpoint_url: Optional[str] = "" # URL for accessing the task endpoint.
313
-
314
-
315
420
  class UserPreference(BaseModel):
316
421
  """
317
422
  User preference for a task.
@@ -329,8 +434,8 @@ class Task(BaseModel):
329
434
  config: Optional[TaskConfig] = None # Configuration data for the task.
330
435
  endpoint_info: Optional[EndpointInfo] = None # Additional information about the task endpoint.
331
436
  cluster_endpoints: Optional[List[EndpointInfo]] = None # Endpoints for the task cluster.
332
- task_status: Optional[TaskStatus] = "" # Status of the task.
333
- readiness_status: Optional[str] = "" # Readiness status of the task.
437
+ task_status: Optional[TaskStatus] = None # Status of the task.
438
+ readiness_status: Optional[str] = None # Readiness status of the task.
334
439
  user_preference: Optional[UserPreference] = None # User preference for the task.
335
440
 
336
441
 
@@ -482,3 +587,85 @@ class GetSelfAPIKeyResponse(BaseModel):
482
587
  """
483
588
  key: APIKey # The API key of the current user.
484
589
  organization: Optional[Organization] = None # Organization information.
590
+
591
+
592
+
593
+ # ----------------- video models -----------------
594
+
595
+ class SubmitRequestRequest(BaseModel):
596
+ """
597
+ The request body for submits a new asynchronous request
598
+ """
599
+ model: str
600
+ payload: dict
601
+
602
+
603
+ class SubmitRequestResponse(BaseModel):
604
+ """
605
+ Represents the response body for a submitted request.
606
+ """
607
+ created_at: Optional[int] = 0
608
+ model: Optional[str] = ""
609
+ queued_at: Optional[int] = 0
610
+ request_id: Optional[str] = ""
611
+ status: Optional[RequestStatus] = None
612
+ updated_at: Optional[int] = 0
613
+
614
+
615
+ class GetRequestResponse(BaseModel):
616
+ """
617
+ Response object for getting a specific request.
618
+ """
619
+ created_at: Optional[int] = 0
620
+ is_public: Optional[bool] = False
621
+ model: Optional[str] = ""
622
+ org_id: Optional[str] = ""
623
+ outcome: Optional[dict] = {}
624
+ payload: Optional[dict] = {}
625
+ queued_at: Optional[int] = 0
626
+ qworker_id: Optional[str] = ""
627
+ request_id: Optional[str] = ""
628
+ status: Optional[RequestStatus] = None
629
+ updated_at: Optional[int] = 0
630
+
631
+
632
+ class ListUserRequestsResponse(BaseModel):
633
+ """
634
+ Represents the response body for listing user requests.
635
+ """
636
+ requests: List[GetRequestResponse]
637
+ total: Optional[int] = 0 # Total number of requests available for the user.
638
+
639
+
640
+ class PriceInfo(BaseModel):
641
+ """
642
+ Represents pricing information for a model.
643
+ """
644
+ price: Optional[int] = 0
645
+ pricing_type: Optional[str] = ""
646
+ unit: Optional[str] = ""
647
+
648
+
649
+ class GetModelResponse(BaseModel):
650
+ """
651
+ Represents the response body for a specific model.
652
+ """
653
+ background_image_url: Optional[str] = ""
654
+ brief_description: Optional[str] = ""
655
+ created_at: Optional[int] = 0
656
+ detailed_description: Optional[str] = ""
657
+ external_api_endpoint: Optional[str] = ""
658
+ external_api_url: Optional[str] = ""
659
+ external_provider: Optional[str] = ""
660
+ host_type: Optional[HostType] = HostType.DEFAULT
661
+ icon_link: Optional[str] = ""
662
+ internal_parameters: Optional[dict] = {}
663
+ modalities: Optional[dict] = {}
664
+ model: Optional[str] = ""
665
+ model_type: Optional[str] = ""
666
+ org_id: Optional[str] = ""
667
+ parameters: Optional[list] = []
668
+ price_info: Optional[PriceInfo] = None
669
+ qworkers: Optional[int] = 0
670
+ tags: Optional[list[str]] = []
671
+ updated_at: Optional[int] = 0
gmicloud/client.py CHANGED
@@ -8,6 +8,7 @@ from ._internal._client._iam_client import IAMClient
8
8
  from ._internal._manager._artifact_manager import ArtifactManager
9
9
  from ._internal._manager._task_manager import TaskManager
10
10
  from ._internal._manager._iam_manager import IAMManager
11
+ from ._internal._manager._video_manager import VideoManager
11
12
  from ._internal._enums import BuildStatus, TaskStatus, TaskEndpointStatus
12
13
  from ._internal._models import Task, TaskConfig, RayTaskConfig, TaskScheduling, ReplicaResource
13
14
 
@@ -37,6 +38,7 @@ class Client:
37
38
  self._artifact_manager = None
38
39
  self._task_manager = None
39
40
  self._iam_manager = None
41
+ self._video_manager = None
40
42
 
41
43
  @property
42
44
  def artifact_manager(self):
@@ -58,6 +60,16 @@ class Client:
58
60
  self._task_manager = TaskManager(self.iam_client)
59
61
  return self._task_manager
60
62
 
63
+ @property
64
+ def video_manager(self):
65
+ """
66
+ Lazy initialization for VideoManager.
67
+ Ensures the Client instance controls its lifecycle.
68
+ """
69
+ if self._video_manager is None:
70
+ self._video_manager = VideoManager(self.iam_client)
71
+ return self._video_manager
72
+
61
73
  @property
62
74
  def iam_manager(self):
63
75
  """
@@ -131,34 +131,18 @@ class TestArtifactManager(unittest.TestCase):
131
131
  upload_link = "http://upload-link"
132
132
  bigfile_upload_link = "http://bigfile-upload-link"
133
133
  artifact_file_path = "./testdata/test.zip"
134
- model_file_path = "./testdata/model.zip"
134
+ model_directory= "./testdata"
135
135
 
136
136
  mock_create_artifact.return_value = CreateArtifactResponse(artifact_id="1", upload_link=upload_link)
137
- mock_get_bigfile_upload_url.return_value = GetBigFileUploadUrlResponse(artifact_id="1",
137
+ mock_get_bigfile_upload_url.return_value = ResumableUploadLinkResponse(artifact_id="1",
138
138
  upload_link=bigfile_upload_link)
139
139
 
140
140
  artifact_id = self.artifact_manager.create_artifact_with_model_files(artifact_name="artifact_name",
141
141
  artifact_file_path=artifact_file_path,
142
- model_file_paths=[model_file_path])
142
+ model_directory=model_directory)
143
143
  self.assertEqual(artifact_id, "1")
144
144
  mock_upload_small_file.assert_called_once_with(upload_link, artifact_file_path, "application/zip")
145
- mock_upload_large_file.assert_called_once_with(bigfile_upload_link, model_file_path)
146
-
147
- @patch('gmicloud._internal._client._artifact_client.ArtifactClient.create_artifact')
148
- @patch('gmicloud._internal._client._file_upload_client.FileUploadClient.upload_small_file')
149
- def test_create_artifact_with_model_files_raises_file_not_found_error_for_model_file(self, mock_create_artifact,
150
- mock_upload_small_file):
151
- upload_link = "http://upload-link"
152
- artifact_file_path = "./testdata/test.zip"
153
- model_file_path = "./testdata/nonexistent.zip"
154
-
155
- mock_create_artifact.return_value = CreateArtifactResponse(artifact_id="1", upload_link=upload_link)
156
-
157
- with self.assertRaises(FileNotFoundError) as context:
158
- self.artifact_manager.create_artifact_with_model_files(artifact_name="artifact_name",
159
- artifact_file_path=artifact_file_path,
160
- model_file_paths=[model_file_path])
161
- self.assertTrue(f"File not found: {model_file_path}" in str(context.exception))
145
+ self.assertEqual(mock_upload_large_file.call_count, 6) # 6 files in testdata directory
162
146
 
163
147
  @patch('gmicloud._internal._client._artifact_client.ArtifactClient.rebuild_artifact')
164
148
  def test_rebuild_artifact_rebuilds_successfully(self, mock_rebuild_artifact):
@@ -203,7 +187,7 @@ class TestArtifactManager(unittest.TestCase):
203
187
  upload_link = "http://upload-link"
204
188
  model_file_path = "./testdata/model.zip"
205
189
 
206
- mock_get_bigfile_upload_url.return_value = GetBigFileUploadUrlResponse(artifact_id="1", upload_link=upload_link)
190
+ mock_get_bigfile_upload_url.return_value = ResumableUploadLinkResponse(artifact_id="1", upload_link=upload_link)
207
191
  upload_link = self.artifact_manager.get_bigfile_upload_url("1", model_file_path)
208
192
  self.assertEqual(upload_link, upload_link)
209
193
 
@@ -253,7 +237,7 @@ class TestArtifactManager(unittest.TestCase):
253
237
 
254
238
  @patch('gmicloud._internal._client._artifact_client.ArtifactClient.get_public_templates')
255
239
  def test_get_artifact_templates_returns_templates(self, mock_get_public_templates):
256
- mock_get_public_templates.return_value = [ArtifactTemplate(template_id="1", template_data=TemplateData(name="Template1"))]
240
+ mock_get_public_templates.return_value = [Template(template_id="1", template_data=TemplateData(name="Template1"))]
257
241
  templates = self.artifact_manager.get_public_templates()
258
242
  self.assertEqual(len(templates), 1)
259
243
  self.assertEqual(templates[0].template_id, "1")