yicloud-sdk-python 0.1.0__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.
Files changed (59) hide show
  1. version.py +9 -0
  2. yicloud/__init__.py +7 -0
  3. yicloud/base/__init__.py +58 -0
  4. yicloud/base/auth/__init__.py +10 -0
  5. yicloud/base/auth/credential.py +64 -0
  6. yicloud/base/auth/sign.py +80 -0
  7. yicloud/base/client.py +313 -0
  8. yicloud/base/config.py +62 -0
  9. yicloud/base/errs/__init__.py +292 -0
  10. yicloud/base/log/__init__.py +43 -0
  11. yicloud/base/log/logger.py +123 -0
  12. yicloud/base/log/std.py +70 -0
  13. yicloud/base/msgs/__init__.py +226 -0
  14. yicloud/base/utils/__init__.py +6 -0
  15. yicloud/base/utils/helps.py +110 -0
  16. yicloud/base/utils/retry/__init__.py +27 -0
  17. yicloud/base/utils/retry/retry.py +162 -0
  18. yicloud/services/__init__.py +24 -0
  19. yicloud/services/bc/__init__.py +9 -0
  20. yicloud/services/bc/actions.py +23 -0
  21. yicloud/services/bc/client.py +19 -0
  22. yicloud/services/bc/models.py +61 -0
  23. yicloud/services/fs/__init__.py +29 -0
  24. yicloud/services/fs/actions.py +109 -0
  25. yicloud/services/fs/client.py +19 -0
  26. yicloud/services/fs/models.py +152 -0
  27. yicloud/services/iam/__init__.py +27 -0
  28. yicloud/services/iam/actions.py +304 -0
  29. yicloud/services/iam/client.py +19 -0
  30. yicloud/services/iam/models.py +276 -0
  31. yicloud/services/job/__init__.py +44 -0
  32. yicloud/services/job/actions.py +167 -0
  33. yicloud/services/job/client.py +19 -0
  34. yicloud/services/job/models.py +268 -0
  35. yicloud/services/mc/__init__.py +59 -0
  36. yicloud/services/mc/actions.py +221 -0
  37. yicloud/services/mc/client.py +21 -0
  38. yicloud/services/mc/models.py +322 -0
  39. yicloud/services/modelrepo/__init__.py +33 -0
  40. yicloud/services/modelrepo/actions.py +163 -0
  41. yicloud/services/modelrepo/client.py +19 -0
  42. yicloud/services/modelrepo/models.py +146 -0
  43. yicloud/services/modelset/__init__.py +45 -0
  44. yicloud/services/modelset/actions.py +130 -0
  45. yicloud/services/modelset/client.py +19 -0
  46. yicloud/services/modelset/models.py +356 -0
  47. yicloud/services/oss/__init__.py +25 -0
  48. yicloud/services/oss/actions.py +83 -0
  49. yicloud/services/oss/client.py +19 -0
  50. yicloud/services/oss/models.py +113 -0
  51. yicloud/services/registry/__init__.py +42 -0
  52. yicloud/services/registry/actions.py +208 -0
  53. yicloud/services/registry/client.py +19 -0
  54. yicloud/services/registry/models.py +183 -0
  55. yicloud_sdk_python-0.1.0.dist-info/METADATA +145 -0
  56. yicloud_sdk_python-0.1.0.dist-info/RECORD +59 -0
  57. yicloud_sdk_python-0.1.0.dist-info/WHEEL +5 -0
  58. yicloud_sdk_python-0.1.0.dist-info/licenses/LICENSE +202 -0
  59. yicloud_sdk_python-0.1.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,322 @@
1
+ # Code generated from Go SDK's services/mc/models.go. DO NOT EDIT.
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Optional, List, Dict
5
+
6
+ # === Enums ===
7
+
8
+ class Role:
9
+ """Role enum matching Go SDK's Role."""
10
+ MANAGER = "manager"
11
+ OPERATOR = "operator"
12
+
13
+
14
+ class ProjectStatus:
15
+ """ProjectStatus enum matching Go SDK's ProjectStatus."""
16
+ CREATING = "Creating"
17
+ SUCCEEDED = "Succeeded"
18
+
19
+
20
+ class UsageType:
21
+ """UsageType enum matching Go SDK's UsageType."""
22
+ WORKSPACE = "workspace"
23
+ WORKLOAD = "workload"
24
+
25
+
26
+ class MachineType:
27
+ """MachineType enum matching Go SDK's MachineType."""
28
+ CPU = "CPU"
29
+ GPU = "GPU"
30
+
31
+ # === Request/Response Models ===
32
+
33
+
34
+ @dataclass
35
+ class ResourceDetail:
36
+ """Resource detail matching Go SDK's ResourceDetail."""
37
+ Releasing: int = 0 # 释放中
38
+ System: int = 0 # 系统资源
39
+ Total: int = 0 # 总量
40
+ Usable: int = 0 # 可使用
41
+ Used: int = 0 # 已使用
42
+
43
+
44
+ @dataclass
45
+ class NodeConfig:
46
+ """Node config matching Go SDK's NodeConfig."""
47
+ CPU: Optional[ResourceDetail] = None # CPU配置
48
+ GPU: Optional[ResourceDetail] = None # GPU配置
49
+ LocalStorage: Optional[ResourceDetail] = None # 本地盘配置
50
+ Memory: Optional[ResourceDetail] = None # 内存配置
51
+
52
+
53
+ @dataclass
54
+ class NodeData:
55
+ """Node data matching Go SDK's NodeData."""
56
+ Maintenance: bool = False # 维护状态
57
+ NodeConfig: Optional[NodeConfig] = None # 节点配置
58
+ NodeName: str = "" # 基本信息
59
+ PodCount: int = 0 # 系统信息
60
+ Project: str = "" # 项目名称
61
+ QuotaGroup: str = "" # 配额组
62
+ Ready: bool = False # 状态信息
63
+ Schedulable: bool = False # 可调度
64
+
65
+
66
+ @dataclass
67
+ class ListNodesData:
68
+ """List nodes response data matching Go SDK's ListNodesData."""
69
+ Items: List[NodeData] = field(default_factory=list) # 节点列表
70
+ Limit: int = 0 # 分页大小
71
+ Offset: int = 0 # 分页偏移量
72
+ Total: int = 0 # 总条数
73
+ TotalNodeConfig: Optional[NodeConfig] = None # 总节点配置
74
+
75
+
76
+ @dataclass
77
+ class SKUData:
78
+ """SKU data matching Go SDK's SKUData."""
79
+ Batch: str = "" # 批次
80
+ CardType: str = "" # 卡类型
81
+ CpuCores: str = "" # CPU 核数
82
+ GpuCores: str = "" # GPU 核数
83
+ GpuMemBytes: str = "" # GPU 显存字节数
84
+ MemBytes: str = "" # 内存字节数
85
+ SKUId: str = "" # SKU ID
86
+ Vendor: str = "" # 厂商
87
+
88
+
89
+ @dataclass
90
+ class ListSKUsData:
91
+ """List SKUs response data matching Go SDK's ListSKUsData."""
92
+ Items: List[SKUData] = field(default_factory=list) # SKU列表
93
+ Total: int = 0 # 总条数
94
+
95
+
96
+ @dataclass
97
+ class AssignNodeReq:
98
+ """Assign node request matching Go SDK's AssignNodeReq."""
99
+ NodeNames: List[str] = field(default_factory=list) # 节点名称列表
100
+ Project: str = "" # 项目名
101
+ QuotaGroup: str = "" # 配额组名(可选)
102
+
103
+
104
+ @dataclass
105
+ class BindProjectUserReq:
106
+ """Bind project user request matching Go SDK's BindProjectUserReq."""
107
+ Project: str = "" # 项目名
108
+ Role: str = "" # 角色 枚举值:manager (管理员), operator (操作员)
109
+ UserName: str = "" # 用户名
110
+
111
+
112
+ @dataclass
113
+ class Quota:
114
+ """Quota matching Go SDK's Quota."""
115
+ CPU: int = 0 # CPU 核数(Core)
116
+ GPU: int = 0 # GPU 数量(Card)
117
+ HDDStorage: int = 0 # HDD 存储 (Gi)
118
+ LocalStorage: int = 0 # 本地 存储 (Gi)
119
+ Memory: int = 0 # 内存 (Gi)
120
+ SSDStorage: int = 0 # SSD 存储 (Gi)
121
+
122
+
123
+ @dataclass
124
+ class CreateProjectReq:
125
+ """Create project request matching Go SDK's CreateProjectReq."""
126
+ Project: str = "" # 项目名
127
+ Quota: Optional[Quota] = None # 配额
128
+
129
+
130
+ @dataclass
131
+ class DeleteProjectReq:
132
+ """Delete project request matching Go SDK's DeleteProjectReq."""
133
+ Project: str = "" # 项目名
134
+
135
+
136
+ @dataclass
137
+ class QuotaStatus:
138
+ """Quota status matching Go SDK's QuotaStatus."""
139
+ AllocatedQuota: Optional[Quota] = None # 已分配配额
140
+ TotalQuota: Optional[Quota] = None # 总配额
141
+ UsedQuota: Optional[Quota] = None # 已使用配额
142
+
143
+
144
+ @dataclass
145
+ class ProjectData:
146
+ """Project data matching Go SDK's ProjectData."""
147
+ CreationTime: str = "" # 创建时间(RFC3339,UTC)
148
+ Project: str = "" # 项目名
149
+ QuotaStatus: Optional[QuotaStatus] = None # 配额状态
150
+ Status: str = "" # 状态(Creating, Succeeded)
151
+
152
+
153
+ @dataclass
154
+ class ProjectUser:
155
+ """Project user matching Go SDK's ProjectUser."""
156
+ CreationTime: str = "" # 创建时间(RFC3339,UTC)
157
+ Role: str = "" # 角色 枚举值:manager (管理员), operator (操作员)
158
+ UserName: str = "" # 用户名
159
+
160
+
161
+ @dataclass
162
+ class ListProjectUsersData:
163
+ """List project users response data matching Go SDK's ListProjectUsersData."""
164
+ Items: List[ProjectUser] = field(default_factory=list) # 用户列表
165
+ Limit: int = 0 # 分页大小
166
+ Offset: int = 0 # 分页偏移量
167
+ Total: int = 0 # 总条数
168
+
169
+
170
+ @dataclass
171
+ class ListProjectsData:
172
+ """List projects response data matching Go SDK's ListProjectsData."""
173
+ Items: List[ProjectData] = field(default_factory=list) # 项目列表
174
+ Limit: int = 0 # 分页大小
175
+ Offset: int = 0 # 分页偏移量
176
+ Total: int = 0 # 总条数(过滤后)
177
+
178
+
179
+ @dataclass
180
+ class RemoveProjectUserReq:
181
+ """Remove project user request matching Go SDK's RemoveProjectUserReq."""
182
+ Project: str = "" # 项目名
183
+ Role: str = "" # 角色 枚举值:manager (管理员), operator (操作员)
184
+ UserName: str = "" # 用户名
185
+
186
+
187
+ @dataclass
188
+ class UpdateProjectReq:
189
+ """Update project request matching Go SDK's UpdateProjectReq."""
190
+ Project: str = "" # 项目名
191
+ Quota: Optional[Quota] = None # 配额
192
+
193
+
194
+ @dataclass
195
+ class QuotaGroupUser:
196
+ """Quota group user matching Go SDK's QuotaGroupUser."""
197
+ Role: str = "" # 角色 枚举值:manager (管理员), operator (操作员)
198
+ UserName: str = "" # 用户名
199
+
200
+
201
+ @dataclass
202
+ class CreateQuotaGroupReq:
203
+ """Create quota group request matching Go SDK's CreateQuotaGroupReq."""
204
+ MachineType: str = "" # CPU or GPU
205
+ NodeNames: List[str] = field(default_factory=list)
206
+ Project: str = "" # 项目名
207
+ Quota: Optional[Quota] = None # 配额
208
+ QuotaGroup: str = "" # 配额组名
209
+ QuotaGroupUsers: List[QuotaGroupUser] = field(default_factory=list) # 配额组角色列表(指针用于判断是否传参)
210
+ UsageType: str = "" # workspace or workload
211
+
212
+
213
+ @dataclass
214
+ class QuotaGroupData:
215
+ """Quota group data matching Go SDK's QuotaGroupData."""
216
+ CreationTime: str = "" # 创建时间(RFC3339,UTC)
217
+ MachineType: str = "" # CPU or GPU
218
+ NodeNames: List[str] = field(default_factory=list)
219
+ Project: str = "" # 项目名
220
+ QuotaGroup: str = "" # 配额组名
221
+ QuotaGroupId: str = "" # 配额组ID
222
+ QuotaGroupUsers: List[QuotaGroupUser] = field(default_factory=list) # 配额组角色列表
223
+ UsageType: str = "" # workspace or workload
224
+
225
+
226
+ @dataclass
227
+ class QuotaGroupBasicData:
228
+ """Quota group basic data matching Go SDK's QuotaGroupBasicData."""
229
+ CreationTime: str = "" # 创建时间(RFC3339,UTC)
230
+ MachineType: str = "" # CPU or GPU
231
+ NodeNames: List[str] = field(default_factory=list)
232
+ Project: str = "" # 项目名
233
+ QuotaGroup: str = "" # 配额组名
234
+ QuotaGroupId: str = "" # 配额组ID
235
+ UsageType: str = "" # workspace or workload
236
+
237
+
238
+ @dataclass
239
+ class ListQuotaGroupData:
240
+ """List quota groups response data matching Go SDK's ListQuotaGroupData."""
241
+ Items: List[QuotaGroupBasicData] = field(default_factory=list) # 配额组列表
242
+ Limit: int = 0 # 分页大小
243
+ Offset: int = 0 # 分页偏移量
244
+ Total: int = 0 # 总条数
245
+
246
+
247
+ @dataclass
248
+ class UpdateQuotaGroupReq:
249
+ """Update quota group request matching Go SDK's UpdateQuotaGroupReq."""
250
+ NodeNames: List[str] = field(default_factory=list) # 节点名称列表(可选,nil=不更新,[]或["a"]=更新)
251
+ Project: str = "" # 项目名
252
+ Quota: Optional[Quota] = None # 配额(可选,nil=不更新)
253
+ QuotaGroup: str = "" # 配额组名
254
+ QuotaGroupUsers: List[QuotaGroupUser] = field(default_factory=list) # 配额组角色列表
255
+ UpdateOption: str = "" # 更新选项:quota-更新配额,user-更新用户,quota_nodes-更新配额和节点
256
+
257
+
258
+ @dataclass
259
+ class ListNodesReq:
260
+ """List nodes request matching Go SDK's ListNodesReq."""
261
+ AdminUsage: str = "" # 管理用途
262
+ Limit: int = 0 # 分页大小(min=1,max=100) 默认10
263
+ NodeType: str = "" # 节点类型
264
+ Offset: int = 0 # 分页偏移量(min=0) 默认0
265
+ Project: str = "" # 项目名(可选,不传则查询租户级别)
266
+ QuotaGroup: str = "" # 配额组名(可选,当同时传入ProjectName时查询配额组节点列表)
267
+
268
+
269
+ @dataclass
270
+ class ListSKUsReq:
271
+ """List SKUs request matching Go SDK's ListSKUsReq."""
272
+ Keyword: str = "" # 关键字搜索
273
+ Limit: int = 0 # 分页大小
274
+ Offset: int = 0 # 分页偏移量
275
+ ResourceType: str = "" # 资源类型:用于过滤SKU适用的资源类型(如job、workspace、ray),空表示所有类型
276
+ SKUType: str = "" # SKU类型:cpu或gpu
277
+ Scope: str = "" # SKU可见范围:public(公域)、tenant(租域)、project(项目域),空默认为public
278
+
279
+
280
+ @dataclass
281
+ class GetProjectReq:
282
+ """Get project request matching Go SDK's GetProjectReq."""
283
+ Project: str = "" # 项目名
284
+
285
+
286
+ @dataclass
287
+ class ListProjectUsersReq:
288
+ """List project users request matching Go SDK's ListProjectUsersReq."""
289
+ Limit: int = 0 # 分页大小(min=1,max=100) 默认10
290
+ Offset: int = 0 # 分页偏移量(min=0) 默认0
291
+ Project: str = "" # 项目名
292
+ Role: str = "" # 角色 枚举值:manager (管理员), operator (操作员)
293
+
294
+
295
+ @dataclass
296
+ class ListProjectsReq:
297
+ """List projects request matching Go SDK's ListProjectsReq."""
298
+ Limit: int = 0 # 分页大小(min=1,max=100) 默认10
299
+ Offset: int = 0 # 分页偏移量(min=0) 默认0
300
+ Project: str = "" # 按完整项目名过滤,为空返回全部
301
+
302
+
303
+ @dataclass
304
+ class DeleteQuotaGroupReq:
305
+ """Delete quota group request matching Go SDK's DeleteQuotaGroupReq."""
306
+ Project: str = "" # 项目名
307
+ QuotaGroup: str = "" # 配额组名
308
+
309
+
310
+ @dataclass
311
+ class GetQuotaGroupReq:
312
+ """Get quota group request matching Go SDK's GetQuotaGroupReq."""
313
+ Project: str = "" # 项目名
314
+ QuotaGroup: str = "" # 配额组名
315
+
316
+
317
+ @dataclass
318
+ class ListQuotaGroupsReq:
319
+ """List quota groups request matching Go SDK's ListQuotaGroupsReq."""
320
+ Limit: int = 0 # 分页大小(min=1,max=100) 默认10
321
+ Offset: int = 0 # 分页偏移量(min=0) 默认0
322
+ Project: str = "" # 项目名
@@ -0,0 +1,33 @@
1
+ from yicloud.services.modelrepo.client import ModelRepoClient as Client, client, use_client
2
+ from . import actions, models
3
+
4
+ from .actions import (
5
+ create_model,
6
+ update_model,
7
+ delete_model,
8
+ list_model,
9
+ get_model,
10
+ list_base_model,
11
+ create_model_version,
12
+ update_model_version,
13
+ delete_model_version,
14
+ list_model_version,
15
+ get_model_version,
16
+ )
17
+ from .models import (
18
+ ModelInfo,
19
+ VersionInfo,
20
+ CreateModelReq,
21
+ UpdateModelReq,
22
+ CreateModelVersionReq,
23
+ UpdateModelVersionReq,
24
+ DeleteModelReq,
25
+ DeleteModelVersionReq,
26
+ GetModelReq,
27
+ ListModelReq,
28
+ ListModelVersionReq,
29
+ GetModelVersionReq,
30
+ ModelDetailData,
31
+ VersionInfoData,
32
+ ListModelData,
33
+ )
@@ -0,0 +1,163 @@
1
+ from typing import Optional, List
2
+ from yicloud.base import msgs
3
+ from yicloud.services.modelrepo import models
4
+ from yicloud.services.modelrepo.client import client
5
+
6
+ _PRODUCT_CODE = "modelrepo"
7
+ _LAST_VERSION = "v1alpha1"
8
+
9
+
10
+ def create_model(ctx: Optional[dict], req: models.CreateModelReq) -> models.ModelDetailData:
11
+ """
12
+ POST /modelrepo/v1alpha1/CreateModel
13
+ Action: CreateModel
14
+
15
+ Returns ModelDetailData on success.
16
+
17
+ Raises YiCloudException on error.
18
+ """
19
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/CreateModel"
20
+ rsp = msgs.Rsp[models.ModelDetailData]()
21
+ client.base.post(ctx, path, req.__dict__, rsp)
22
+ return rsp.get_typed_data()
23
+
24
+
25
+ def update_model(ctx: Optional[dict], req: models.UpdateModelReq) -> None:
26
+ """
27
+ POST /modelrepo/v1alpha1/UpdateModel
28
+ Action: UpdateModel
29
+
30
+ Raises YiCloudException on error.
31
+ """
32
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/UpdateModel"
33
+ rsp = msgs.Rsp[None].empty()
34
+ client.base.post(ctx, path, req.__dict__, rsp)
35
+
36
+
37
+ def delete_model(ctx: Optional[dict], req: models.DeleteModelReq) -> None:
38
+ """
39
+ POST /modelrepo/v1alpha1/DeleteModel
40
+ Action: DeleteModel
41
+
42
+ Raises YiCloudException on error.
43
+ """
44
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/DeleteModel"
45
+ rsp = msgs.Rsp[None].empty()
46
+ client.base.post(ctx, path, req.__dict__, rsp)
47
+
48
+
49
+ def list_model(ctx: Optional[dict], req: models.ListModelReq) -> models.ListModelData:
50
+ """
51
+ GET /modelrepo/v1alpha1/ListModel
52
+ Action: ListModel
53
+
54
+ Returns ListModelData on success.
55
+
56
+ Raises YiCloudException on error.
57
+ """
58
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListModel"
59
+ rsp = msgs.Rsp[models.ListModelData]()
60
+ client.base.get(ctx, path, req, rsp)
61
+ return rsp.get_typed_data()
62
+
63
+
64
+ def get_model(ctx: Optional[dict], req: models.GetModelReq) -> models.ModelDetailData:
65
+ """
66
+ GET /modelrepo/v1alpha1/GetModel
67
+ Action: GetModel
68
+
69
+ Returns ModelDetailData on success.
70
+
71
+ Raises YiCloudException on error.
72
+ """
73
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetModel"
74
+ rsp = msgs.Rsp[models.ModelDetailData]()
75
+ client.base.get(ctx, path, req, rsp)
76
+ return rsp.get_typed_data()
77
+
78
+
79
+ def list_base_model(ctx: Optional[dict], req: models.ListModelReq) -> models.ListModelData:
80
+ """
81
+ GET /modelrepo/v1alpha1/ListBaseModel
82
+ Action: ListBaseModel
83
+
84
+ Returns ListModelData on success.
85
+
86
+ Raises YiCloudException on error.
87
+ """
88
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListBaseModel"
89
+ rsp = msgs.Rsp[models.ListModelData]()
90
+ client.base.get(ctx, path, req, rsp)
91
+ return rsp.get_typed_data()
92
+
93
+
94
+ def create_model_version(ctx: Optional[dict], req: models.CreateModelVersionReq) -> models.VersionInfoData:
95
+ """
96
+ POST /modelrepo/v1alpha1/CreateModelVersion
97
+ Action: CreateModelVersion
98
+
99
+ Returns VersionInfoData on success.
100
+
101
+ Raises YiCloudException on error.
102
+ """
103
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/CreateModelVersion"
104
+ rsp = msgs.Rsp[models.VersionInfoData]()
105
+ client.base.post(ctx, path, req.__dict__, rsp)
106
+ return rsp.get_typed_data()
107
+
108
+
109
+ def update_model_version(ctx: Optional[dict], req: models.UpdateModelVersionReq) -> None:
110
+ """
111
+ POST /modelrepo/v1alpha1/UpdateModelVersion
112
+ Action: UpdateModelVersion
113
+
114
+ Raises YiCloudException on error.
115
+ """
116
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/UpdateModelVersion"
117
+ rsp = msgs.Rsp[None].empty()
118
+ client.base.post(ctx, path, req.__dict__, rsp)
119
+
120
+
121
+ def delete_model_version(ctx: Optional[dict], req: models.DeleteModelVersionReq) -> None:
122
+ """
123
+ POST /modelrepo/v1alpha1/DeleteModelVersion
124
+ Action: DeleteModelVersion
125
+
126
+ Raises YiCloudException on error.
127
+ """
128
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/DeleteModelVersion"
129
+ rsp = msgs.Rsp[None].empty()
130
+ client.base.post(ctx, path, req.__dict__, rsp)
131
+
132
+
133
+ def list_model_version(ctx: Optional[dict], req: models.ListModelVersionReq) -> List[models.VersionInfoData]:
134
+ """
135
+ GET /modelrepo/v1alpha1/ListModelVersion
136
+ Action: ListModelVersion
137
+
138
+ Returns List of VersionInfoData.
139
+
140
+ Raises YiCloudException on error.
141
+ """
142
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListModelVersion"
143
+ rsp = msgs.Rsp[List[models.VersionInfoData]]()
144
+ client.base.get(ctx, path, req, rsp)
145
+ data = rsp.get_typed_data()
146
+ if data is None:
147
+ return []
148
+ return data
149
+
150
+
151
+ def get_model_version(ctx: Optional[dict], req: models.GetModelVersionReq) -> models.VersionInfoData:
152
+ """
153
+ GET /modelrepo/v1alpha1/GetModelVersion
154
+ Action: GetModelVersion
155
+
156
+ Returns VersionInfoData on success.
157
+
158
+ Raises YiCloudException on error.
159
+ """
160
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetModelVersion"
161
+ rsp = msgs.Rsp[models.VersionInfoData]()
162
+ client.base.get(ctx, path, req, rsp)
163
+ return rsp.get_typed_data()
@@ -0,0 +1,19 @@
1
+ from yicloud.base import Client
2
+
3
+
4
+ class ModelRepoClient:
5
+ """ModelRepo service client, matching Go SDK's services/modelrepo/client.go."""
6
+
7
+ def __init__(self, base_client: Client = None):
8
+ self.base = base_client
9
+ self.product_code = "modelrepo"
10
+ self.last_version = "v1alpha1"
11
+
12
+
13
+ # Singleton matching Go SDK
14
+ client: ModelRepoClient = ModelRepoClient()
15
+
16
+
17
+ def use_client(cli: Client) -> None:
18
+ """Set the base client for ModelRepo service."""
19
+ client.base = cli
@@ -0,0 +1,146 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+
4
+
5
+ # Model Info
6
+ @dataclass
7
+ class ModelInfo:
8
+ Name: str # json:"Name"
9
+ Description: str # json:"Description"
10
+ BaseModelName: str # json:"BaseModelName"
11
+ Visibility: str # json:"Visibility"
12
+
13
+
14
+ # Version Info
15
+ @dataclass
16
+ class VersionInfo:
17
+ Version: int # json:"Version"
18
+ Description: str # json:"Description"
19
+ Type: str # json:"Type"
20
+ Format: str # json:"Format"
21
+ ModelPath: str # json:"ModelPath"
22
+ StorageType: str # json:"StorageType"
23
+ SourceType: str # json:"SourceType"
24
+ TensorConfig: str # json:"TensorConfig"
25
+ ParamNum: float # json:"ParamNum"
26
+
27
+
28
+ # Request Models (POST body)
29
+ @dataclass
30
+ class CreateModelReq:
31
+ Project: str # json:"Project"
32
+ Model: ModelInfo # json:"Model"
33
+ Version: VersionInfo # json:"Version"
34
+
35
+
36
+ @dataclass
37
+ class UpdateModelReq:
38
+ Project: str # json:"Project"
39
+ ModelId: str # json:"ModelId"
40
+ DisplayName: Optional[str] = None # json:"DisplayName"
41
+ Visibility: Optional[str] = None # json:"Visibility"
42
+ Description: Optional[str] = None # json:"Description"
43
+
44
+
45
+ @dataclass
46
+ class CreateModelVersionReq:
47
+ Project: str # json:"Project"
48
+ ModelId: str # json:"ModelId"
49
+ Version: int # json:"Version"
50
+ Description: str # json:"Description"
51
+ Type: str # json:"Type"
52
+ Format: str # json:"Format"
53
+ ModelPath: str # json:"ModelPath"
54
+ StorageType: str # json:"StorageType"
55
+ SourceType: str # json:"SourceType"
56
+ TensorConfig: str # json:"TensorConfig"
57
+ ParamNum: float # json:"ParamNum"
58
+
59
+
60
+ @dataclass
61
+ class UpdateModelVersionReq:
62
+ Project: str # json:"Project"
63
+ ModelId: str # json:"ModelId"
64
+ Version: str # json:"Version"
65
+ Description: Optional[str] = None # json:"Description,omitempty"
66
+ TensorConfig: Optional[str] = None # json:"TensorConfig,omitempty"
67
+
68
+
69
+ @dataclass
70
+ class DeleteModelReq:
71
+ Project: str # json:"Project"
72
+ ModelId: str # json:"ModelId"
73
+
74
+
75
+ @dataclass
76
+ class DeleteModelVersionReq:
77
+ Project: str # json:"Project"
78
+ ModelId: str # json:"ModelId"
79
+ Version: str # json:"Version"
80
+
81
+
82
+ # Request Models (Query params)
83
+ @dataclass
84
+ class GetModelReq:
85
+ Project: str # query:"Project"
86
+ ModelId: str # query:"ModelId"
87
+
88
+
89
+ @dataclass
90
+ class ListModelReq:
91
+ Project: str # query:"Project"
92
+ Limit: int = 10 # query:"Limit"
93
+ Offset: int = 0 # query:"Offset"
94
+ Keyword: str = "" # query:"Keyword"
95
+ Visibility: str = "" # query:"Visibility"
96
+ SortBy: str = "" # query:"SortBy"
97
+ SortDirection: str = "" # query:"SortDirection"
98
+
99
+
100
+ @dataclass
101
+ class ListModelVersionReq:
102
+ Project: str # query:"Project"
103
+ ModelId: str # query:"ModelId"
104
+
105
+
106
+ @dataclass
107
+ class GetModelVersionReq:
108
+ Project: str # query:"Project"
109
+ ModelId: str # query:"ModelId"
110
+ Version: str # query:"Version"
111
+
112
+
113
+ # Response Data Models
114
+ @dataclass
115
+ class ModelDetailData:
116
+ Name: str # json:"Name"
117
+ Description: str # json:"Description"
118
+ CustomId: str # json:"CustomID"
119
+ BaseModelName: str # json:"BaseModelName"
120
+ Visibility: str # json:"Visibility"
121
+ LatestVersion: int # json:"LatestVersion"
122
+ VersionCount: int # json:"VersionCount"
123
+ CreatedAt: str # json:"CreatedAt"
124
+ Creator: str # json:"Creator"
125
+ UpdateAt: str # json:"UpdateAt"
126
+ CanEdit: bool # json:"CanEdit"
127
+
128
+
129
+ @dataclass
130
+ class VersionInfoData:
131
+ Version: int # json:"Version"
132
+ Description: str # json:"Description"
133
+ Type: str # json:"Type"
134
+ Format: str # json:"Format"
135
+ ModelPath: str # json:"ModelPath"
136
+ TensorConfig: str # json:"TensorConfig"
137
+ CreatedAt: str # json:"CreatedAt"
138
+ Creator: str # json:"Creator"
139
+
140
+
141
+ @dataclass
142
+ class ListModelData:
143
+ Total: int # json:"Total"
144
+ Items: Optional[list] = None # json:"Items"
145
+ Limit: int = 10 # json:"Limit"
146
+ Offset: int = 0 # json:"Offset"