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.
- version.py +9 -0
- yicloud/__init__.py +7 -0
- yicloud/base/__init__.py +58 -0
- yicloud/base/auth/__init__.py +10 -0
- yicloud/base/auth/credential.py +64 -0
- yicloud/base/auth/sign.py +80 -0
- yicloud/base/client.py +313 -0
- yicloud/base/config.py +62 -0
- yicloud/base/errs/__init__.py +292 -0
- yicloud/base/log/__init__.py +43 -0
- yicloud/base/log/logger.py +123 -0
- yicloud/base/log/std.py +70 -0
- yicloud/base/msgs/__init__.py +226 -0
- yicloud/base/utils/__init__.py +6 -0
- yicloud/base/utils/helps.py +110 -0
- yicloud/base/utils/retry/__init__.py +27 -0
- yicloud/base/utils/retry/retry.py +162 -0
- yicloud/services/__init__.py +24 -0
- yicloud/services/bc/__init__.py +9 -0
- yicloud/services/bc/actions.py +23 -0
- yicloud/services/bc/client.py +19 -0
- yicloud/services/bc/models.py +61 -0
- yicloud/services/fs/__init__.py +29 -0
- yicloud/services/fs/actions.py +109 -0
- yicloud/services/fs/client.py +19 -0
- yicloud/services/fs/models.py +152 -0
- yicloud/services/iam/__init__.py +27 -0
- yicloud/services/iam/actions.py +304 -0
- yicloud/services/iam/client.py +19 -0
- yicloud/services/iam/models.py +276 -0
- yicloud/services/job/__init__.py +44 -0
- yicloud/services/job/actions.py +167 -0
- yicloud/services/job/client.py +19 -0
- yicloud/services/job/models.py +268 -0
- yicloud/services/mc/__init__.py +59 -0
- yicloud/services/mc/actions.py +221 -0
- yicloud/services/mc/client.py +21 -0
- yicloud/services/mc/models.py +322 -0
- yicloud/services/modelrepo/__init__.py +33 -0
- yicloud/services/modelrepo/actions.py +163 -0
- yicloud/services/modelrepo/client.py +19 -0
- yicloud/services/modelrepo/models.py +146 -0
- yicloud/services/modelset/__init__.py +45 -0
- yicloud/services/modelset/actions.py +130 -0
- yicloud/services/modelset/client.py +19 -0
- yicloud/services/modelset/models.py +356 -0
- yicloud/services/oss/__init__.py +25 -0
- yicloud/services/oss/actions.py +83 -0
- yicloud/services/oss/client.py +19 -0
- yicloud/services/oss/models.py +113 -0
- yicloud/services/registry/__init__.py +42 -0
- yicloud/services/registry/actions.py +208 -0
- yicloud/services/registry/client.py +19 -0
- yicloud/services/registry/models.py +183 -0
- yicloud_sdk_python-0.1.0.dist-info/METADATA +145 -0
- yicloud_sdk_python-0.1.0.dist-info/RECORD +59 -0
- yicloud_sdk_python-0.1.0.dist-info/WHEEL +5 -0
- yicloud_sdk_python-0.1.0.dist-info/licenses/LICENSE +202 -0
- yicloud_sdk_python-0.1.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from yicloud.services.modelset.client import ModelSetClient as Client, client, use_client
|
|
2
|
+
from . import actions, models
|
|
3
|
+
|
|
4
|
+
from .actions import (
|
|
5
|
+
create_model_set,
|
|
6
|
+
list_model_set,
|
|
7
|
+
get_model_set,
|
|
8
|
+
update_model_set,
|
|
9
|
+
delete_model_set,
|
|
10
|
+
scale_model_set,
|
|
11
|
+
stop_model_set,
|
|
12
|
+
start_model_set,
|
|
13
|
+
list_model_set_replica,
|
|
14
|
+
)
|
|
15
|
+
from .models import (
|
|
16
|
+
EnvironmentVar,
|
|
17
|
+
PortConfig,
|
|
18
|
+
InstanceType,
|
|
19
|
+
RollingUpdateConfig,
|
|
20
|
+
GPFSMount,
|
|
21
|
+
HTTPHeader,
|
|
22
|
+
HTTPProbe,
|
|
23
|
+
TCPSocketProbe,
|
|
24
|
+
ExecProbe,
|
|
25
|
+
ProbeConfig,
|
|
26
|
+
ModelConfig,
|
|
27
|
+
AutoScalingTriggerCron,
|
|
28
|
+
AutoScalingTriggerMetrics,
|
|
29
|
+
AutoScalingPolicy,
|
|
30
|
+
AutoScalingRule,
|
|
31
|
+
AutoScalingConfig,
|
|
32
|
+
CreateModelSetRequest,
|
|
33
|
+
UpdateModelSetRequest,
|
|
34
|
+
ScaleModelSetRequest,
|
|
35
|
+
DeleteModelSetRequest,
|
|
36
|
+
StopModelSetRequest,
|
|
37
|
+
StartModelSetRequest,
|
|
38
|
+
ModelSetDetail,
|
|
39
|
+
ModelSetReplica,
|
|
40
|
+
ListModelSetRequest,
|
|
41
|
+
GetModelSetRequest,
|
|
42
|
+
ListModelSetReplicaRequest,
|
|
43
|
+
ListModelSetData,
|
|
44
|
+
ListModelSetReplicaData,
|
|
45
|
+
)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from yicloud.base import msgs
|
|
3
|
+
from yicloud.services.modelset import models
|
|
4
|
+
from yicloud.services.modelset.client import client
|
|
5
|
+
|
|
6
|
+
_PRODUCT_CODE = "modelset"
|
|
7
|
+
_LAST_VERSION = "v1alpha1"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def create_model_set(ctx: Optional[dict], req: models.CreateModelSetRequest) -> models.ModelSetDetail:
|
|
11
|
+
"""
|
|
12
|
+
POST /modelset/v1alpha1/CreateModelSet
|
|
13
|
+
Action: CreateModelSet
|
|
14
|
+
|
|
15
|
+
Returns ModelSetDetail on success.
|
|
16
|
+
|
|
17
|
+
Raises YiCloudException on error.
|
|
18
|
+
"""
|
|
19
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/CreateModelSet"
|
|
20
|
+
rsp = msgs.Rsp[models.ModelSetDetail]()
|
|
21
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
22
|
+
return rsp.get_typed_data()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def list_model_set(ctx: Optional[dict], req: models.ListModelSetRequest) -> models.ListModelSetData:
|
|
26
|
+
"""
|
|
27
|
+
GET /modelset/v1alpha1/ListModelSet
|
|
28
|
+
Action: ListModelSet
|
|
29
|
+
|
|
30
|
+
Returns ListModelSetData on success.
|
|
31
|
+
|
|
32
|
+
Raises YiCloudException on error.
|
|
33
|
+
"""
|
|
34
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListModelSet"
|
|
35
|
+
rsp = msgs.Rsp[models.ListModelSetData]()
|
|
36
|
+
client.base.get(ctx, path, req, rsp)
|
|
37
|
+
return rsp.get_typed_data()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_model_set(ctx: Optional[dict], req: models.GetModelSetRequest) -> models.ModelSetDetail:
|
|
41
|
+
"""
|
|
42
|
+
GET /modelset/v1alpha1/GetModelSet
|
|
43
|
+
Action: GetModelSet
|
|
44
|
+
|
|
45
|
+
Returns ModelSetDetail on success.
|
|
46
|
+
|
|
47
|
+
Raises YiCloudException on error.
|
|
48
|
+
"""
|
|
49
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetModelSet"
|
|
50
|
+
rsp = msgs.Rsp[models.ModelSetDetail]()
|
|
51
|
+
client.base.get(ctx, path, req, rsp)
|
|
52
|
+
return rsp.get_typed_data()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def update_model_set(ctx: Optional[dict], req: models.UpdateModelSetRequest) -> models.ModelSetDetail:
|
|
56
|
+
"""
|
|
57
|
+
POST /modelset/v1alpha1/UpdateModelSet
|
|
58
|
+
Action: UpdateModelSet
|
|
59
|
+
|
|
60
|
+
Returns ModelSetDetail on success.
|
|
61
|
+
|
|
62
|
+
Raises YiCloudException on error.
|
|
63
|
+
"""
|
|
64
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/UpdateModelSet"
|
|
65
|
+
rsp = msgs.Rsp[models.ModelSetDetail]()
|
|
66
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
67
|
+
return rsp.get_typed_data()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def delete_model_set(ctx: Optional[dict], req: models.DeleteModelSetRequest) -> None:
|
|
71
|
+
"""
|
|
72
|
+
POST /modelset/v1alpha1/DeleteModelSet
|
|
73
|
+
Action: DeleteModelSet
|
|
74
|
+
|
|
75
|
+
Raises YiCloudException on error.
|
|
76
|
+
"""
|
|
77
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/DeleteModelSet"
|
|
78
|
+
rsp = msgs.Rsp[None].empty()
|
|
79
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def scale_model_set(ctx: Optional[dict], req: models.ScaleModelSetRequest) -> None:
|
|
83
|
+
"""
|
|
84
|
+
POST /modelset/v1alpha1/ScaleModelSet
|
|
85
|
+
Action: ScaleModelSet
|
|
86
|
+
|
|
87
|
+
Raises YiCloudException on error.
|
|
88
|
+
"""
|
|
89
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ScaleModelSet"
|
|
90
|
+
rsp = msgs.Rsp[None].empty()
|
|
91
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def stop_model_set(ctx: Optional[dict], req: models.StopModelSetRequest) -> None:
|
|
95
|
+
"""
|
|
96
|
+
POST /modelset/v1alpha1/StopModelSet
|
|
97
|
+
Action: StopModelSet
|
|
98
|
+
|
|
99
|
+
Raises YiCloudException on error.
|
|
100
|
+
"""
|
|
101
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/StopModelSet"
|
|
102
|
+
rsp = msgs.Rsp[None].empty()
|
|
103
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def start_model_set(ctx: Optional[dict], req: models.StartModelSetRequest) -> None:
|
|
107
|
+
"""
|
|
108
|
+
POST /modelset/v1alpha1/StartModelSet
|
|
109
|
+
Action: StartModelSet
|
|
110
|
+
|
|
111
|
+
Raises YiCloudException on error.
|
|
112
|
+
"""
|
|
113
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/StartModelSet"
|
|
114
|
+
rsp = msgs.Rsp[None].empty()
|
|
115
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def list_model_set_replica(ctx: Optional[dict], req: models.ListModelSetReplicaRequest) -> models.ListModelSetReplicaData:
|
|
119
|
+
"""
|
|
120
|
+
GET /modelset/v1alpha1/ListModelSetReplica
|
|
121
|
+
Action: ListModelSetReplica
|
|
122
|
+
|
|
123
|
+
Returns ListModelSetReplicaData on success.
|
|
124
|
+
|
|
125
|
+
Raises YiCloudException on error.
|
|
126
|
+
"""
|
|
127
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListModelSetReplica"
|
|
128
|
+
rsp = msgs.Rsp[models.ListModelSetReplicaData]()
|
|
129
|
+
client.base.get(ctx, path, req, rsp)
|
|
130
|
+
return rsp.get_typed_data()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from yicloud.base import Client
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ModelSetClient:
|
|
5
|
+
"""ModelSet service client, matching Go SDK's services/modelset/client.go."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, base_client: Client = None):
|
|
8
|
+
self.base = base_client
|
|
9
|
+
self.product_code = "modelset"
|
|
10
|
+
self.last_version = "v1alpha1"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Singleton matching Go SDK
|
|
14
|
+
client: ModelSetClient = ModelSetClient()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def use_client(cli: Client) -> None:
|
|
18
|
+
"""Set the base client for ModelSet service."""
|
|
19
|
+
client.base = cli
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
# Code generated from Go SDK's services/modelset/models.go. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Optional, List, Dict
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Environment variables, ports, and instance types
|
|
8
|
+
@dataclass
|
|
9
|
+
class EnvironmentVar:
|
|
10
|
+
Key: str # json:"Key"
|
|
11
|
+
Value: str # json:"Value"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class PortConfig:
|
|
16
|
+
ContainerPort: int # json:"ContainerPort"
|
|
17
|
+
HostPort: int # json:"HostPort"
|
|
18
|
+
Type: str # json:"Type"
|
|
19
|
+
Path: str # json:"Path"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class InstanceType:
|
|
24
|
+
GpuCount: int # json:"GpuCount" # cores
|
|
25
|
+
CpuCount: int # json:"CpuCount" # cards
|
|
26
|
+
Memory: int # json:"Memory" # Gi
|
|
27
|
+
GpuType: str # json:"GpuType"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class RollingUpdateConfig:
|
|
32
|
+
MaxSurge: Optional[int] = None # json:"MaxSurge,omitempty" # 0~100
|
|
33
|
+
MaxUnavailable: Optional[int] = None # json:"MaxUnavailable,omitempty" # 0~100
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class GPFSMount:
|
|
38
|
+
SourceAddress: str # json:"SourceAddress"
|
|
39
|
+
MountPoint: str # json:"MountPoint"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Probes and health check configuration
|
|
43
|
+
@dataclass
|
|
44
|
+
class HTTPHeader:
|
|
45
|
+
Key: str # json:"Key"
|
|
46
|
+
Value: str # json:"Value"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class HTTPProbe:
|
|
51
|
+
Scheme: str # json:"Scheme" # http or https
|
|
52
|
+
HTTPHeaders: Optional[List[HTTPHeader]] = None # json:"HTTPHeaders,omitempty"
|
|
53
|
+
Path: str = "" # json:"Path"
|
|
54
|
+
Port: str = "" # json:"Port"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class TCPSocketProbe:
|
|
59
|
+
Port: str # json:"Port"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class ExecProbe:
|
|
64
|
+
Command: List[str] = field(default_factory=list) # json:"Command"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass
|
|
68
|
+
class ProbeConfig:
|
|
69
|
+
Enabled: bool # json:"Enabled" # switch
|
|
70
|
+
|
|
71
|
+
# Three check methods, choose one
|
|
72
|
+
HTTPGet: Optional[HTTPProbe] = None # json:"HTTPGet,omitempty"
|
|
73
|
+
TCPSocket: Optional[TCPSocketProbe] = None # json:"TCPSocket,omitempty"
|
|
74
|
+
ExecProbe: Optional[ExecProbe] = None # json:"Exec,omitempty"
|
|
75
|
+
|
|
76
|
+
# Time settings
|
|
77
|
+
InitialDelaySeconds: int = 0 # json:"InitialDelaySeconds"
|
|
78
|
+
TimeoutSeconds: int = 0 # json:"TimeoutSeconds"
|
|
79
|
+
PeriodSeconds: int = 0 # json:"PeriodSeconds"
|
|
80
|
+
|
|
81
|
+
# Thresholds
|
|
82
|
+
SuccessThreshold: int = 0 # json:"SuccessThreshold"
|
|
83
|
+
FailureThreshold: int = 0 # json:"FailureThreshold"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class ModelConfig:
|
|
88
|
+
Name: str # json:"Name"
|
|
89
|
+
Version: str # json:"Version"
|
|
90
|
+
Namespace: str # json:"Namespace"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass
|
|
94
|
+
class AutoScalingTriggerCron:
|
|
95
|
+
Start: str # json:"Start" # a cron string for start
|
|
96
|
+
End: str # json:"End" # a cron string for end
|
|
97
|
+
DesiredReplicas: str # json:"DesiredReplicas" # a string format integer
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class AutoScalingTriggerMetrics:
|
|
102
|
+
Type: str # json:"Type" # valid: gpu_utilization, cpu_utilization, memory_utilization, sm_activity, active_instance_ratio, per_instance_load
|
|
103
|
+
Threshold: str # json:"Threshold" # a string format metric value
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass
|
|
107
|
+
class AutoScalingPolicy:
|
|
108
|
+
Type: str # json:"Type" # valid values: Pods, Percent
|
|
109
|
+
Value: int # json:"Value" # percent num greater than 0 and eql 100
|
|
110
|
+
PeriodSeconds: int # json:"PeriodSeconds" # greater than zero and less than or equal to 1800
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class AutoScalingRule:
|
|
115
|
+
# StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour).
|
|
116
|
+
# default value: up: 0; down 300
|
|
117
|
+
StabilizationWindowSeconds: Optional[int] = None # json:"StabilizationWindowSeconds,omitempty"
|
|
118
|
+
Policies: Optional[List[AutoScalingPolicy]] = None # json:"Policies,omitempty"
|
|
119
|
+
SelectPolicy: Optional[str] = None # json:"SelectPolicy,omitempty"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@dataclass
|
|
123
|
+
class AutoScalingConfig:
|
|
124
|
+
Enabled: bool # json:"Enabled"
|
|
125
|
+
MinReplicaCount: Optional[int] = None # json:"MinReplicaCount,omitempty"
|
|
126
|
+
MaxReplicaCount: Optional[int] = None # json:"MaxReplicaCount,omitempty"
|
|
127
|
+
CronTriggerList: Optional[List[AutoScalingTriggerCron]] = None # json:"CronTriggerList,omitempty"
|
|
128
|
+
MetricsTriggerList: Optional[List[AutoScalingTriggerMetrics]] = None # json:"MetricsTriggerList,omitempty"
|
|
129
|
+
|
|
130
|
+
ScaleUp: Optional[AutoScalingRule] = None # json:"ScaleUp,omitempty"
|
|
131
|
+
ScaleDown: Optional[AutoScalingRule] = None # json:"ScaleDown,omitempty"
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# Request models
|
|
135
|
+
@dataclass
|
|
136
|
+
class CreateModelSetRequest:
|
|
137
|
+
Project: str # json:"Project" # project identifier
|
|
138
|
+
|
|
139
|
+
CreatorName: str # json:"CreatorName"
|
|
140
|
+
CreatorId: str # json:"CreatorId"
|
|
141
|
+
CreatorDepartment: str # json:"CreatorDepartment"
|
|
142
|
+
CreatorType: str # json:"CreatorType"
|
|
143
|
+
PrivateMachine: str # json:"PrivateMachine"
|
|
144
|
+
|
|
145
|
+
# Basic info
|
|
146
|
+
Name: str # json:"Name"
|
|
147
|
+
Description: Optional[str] = None # json:"Description,omitempty"
|
|
148
|
+
QuotaGroup: str = "" # json:"QuotaGroup"
|
|
149
|
+
IsCPUQuotaGroup: bool = False # json:"IsCPUQuotaGroup"
|
|
150
|
+
QuotaGroupAllocateScope: str = "" # json:"QuotaGroupAllocateScope"
|
|
151
|
+
IsInference: bool = False # json:"IsInference"
|
|
152
|
+
|
|
153
|
+
IsIdle: bool = False # json:"IsIdle"
|
|
154
|
+
|
|
155
|
+
# Environment configuration
|
|
156
|
+
Image: str = "" # json:"Image"
|
|
157
|
+
Command: List[str] = field(default_factory=list) # json:"Command"
|
|
158
|
+
EnvVars: Optional[List[EnvironmentVar]] = None # json:"EnvVars,omitempty"
|
|
159
|
+
|
|
160
|
+
# Instance configuration
|
|
161
|
+
Distributed: Optional[bool] = None # json:"Distributed,omitempty" # whether distributed inference is enabled
|
|
162
|
+
InstanceCount: Optional[int] = None # json:"InstanceCount,omitempty" # instance count, effective when distributed inference is enabled, otherwise defaults to 1
|
|
163
|
+
|
|
164
|
+
InstanceType: Optional[InstanceType] = None # json:"InstanceType"
|
|
165
|
+
Replicas: int = 0 # json:"Replicas" # replica count
|
|
166
|
+
RollingUpdate: Optional[RollingUpdateConfig] = None # json:"RollingUpdate,omitempty"
|
|
167
|
+
GpfsMounts: Optional[List[GPFSMount]] = None # json:"GPFSMounts,omitempty"
|
|
168
|
+
|
|
169
|
+
# Port configuration (max 5)
|
|
170
|
+
Ports: List[PortConfig] = field(default_factory=list) # json:"Ports"
|
|
171
|
+
|
|
172
|
+
# Health check
|
|
173
|
+
LivenessProbe: Optional[ProbeConfig] = None # json:"LivenessProbe,omitempty"
|
|
174
|
+
ReadinessProbe: Optional[ProbeConfig] = None # json:"ReadinessProbe,omitempty"
|
|
175
|
+
StartupProbe: Optional[ProbeConfig] = None # json:"StartupProbe,omitempty"
|
|
176
|
+
|
|
177
|
+
# Auto-scaling configuration
|
|
178
|
+
AutoScalingConfig: Optional[AutoScalingConfig] = None # json:"AutoScalingConfig,omitempty"
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@dataclass
|
|
182
|
+
class UpdateModelSetRequest:
|
|
183
|
+
# Identification info
|
|
184
|
+
Project: str # json:"Project"
|
|
185
|
+
Id: str # json:"Id"
|
|
186
|
+
|
|
187
|
+
# Basic info
|
|
188
|
+
Name: Optional[str] = None # json:"Name,omitempty" # optional
|
|
189
|
+
Description: Optional[str] = None # json:"Description,omitempty" # optional
|
|
190
|
+
QuotaGroup: Optional[str] = None # json:"QuotaGroup,omitempty"
|
|
191
|
+
|
|
192
|
+
IsInference: Optional[bool] = None # json:"IsInference,omitempty"
|
|
193
|
+
|
|
194
|
+
# Environment configuration
|
|
195
|
+
Image: Optional[str] = None # json:"Image,omitempty" # replace entire image config
|
|
196
|
+
Command: Optional[List[str]] = None # json:"Command,omitempty" # replace entire command
|
|
197
|
+
EnvVars: Optional[List[EnvironmentVar]] = None # json:"EnvVars,omitempty" # replace all environment variables
|
|
198
|
+
|
|
199
|
+
# Instance configuration
|
|
200
|
+
Distributed: Optional[bool] = None # json:"Distributed,omitempty" # whether distributed inference is enabled
|
|
201
|
+
InstanceCount: Optional[int] = None # json:"InstanceCount,omitempty" # instance count, effective when distributed inference is enabled
|
|
202
|
+
|
|
203
|
+
InstanceType: Optional[InstanceType] = None # json:"InstanceType,omitempty"
|
|
204
|
+
Replicas: Optional[int] = None # json:"Replicas,omitempty"
|
|
205
|
+
RollingUpdate: Optional[RollingUpdateConfig] = None # json:"RollingUpdate,omitempty"
|
|
206
|
+
GpfsMounts: Optional[List[GPFSMount]] = None # json:"GPFSMounts,omitempty" # replace all mounts
|
|
207
|
+
|
|
208
|
+
# Port configuration (max 5)
|
|
209
|
+
Ports: Optional[List[PortConfig]] = None # json:"Ports,omitempty" # replace all ports
|
|
210
|
+
|
|
211
|
+
# Health check (can be updated separately)
|
|
212
|
+
LivenessProbe: Optional[ProbeConfig] = None # json:"LivenessProbe,omitempty"
|
|
213
|
+
ReadinessProbe: Optional[ProbeConfig] = None # json:"ReadinessProbe,omitempty"
|
|
214
|
+
StartupProbe: Optional[ProbeConfig] = None # json:"StartupProbe,omitempty"
|
|
215
|
+
|
|
216
|
+
# Auto-scaling configuration
|
|
217
|
+
AutoScalingConfig: Optional[AutoScalingConfig] = None # json:"AutoScalingConfig,omitempty"
|
|
218
|
+
|
|
219
|
+
# Model configuration
|
|
220
|
+
Model: Optional[ModelConfig] = None # json:"Model,omitempty"
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@dataclass
|
|
224
|
+
class ScaleModelSetRequest:
|
|
225
|
+
Project: str # json:"Project"
|
|
226
|
+
Id: str # json:"Id"
|
|
227
|
+
Replicas: int # json:"Replicas"
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@dataclass
|
|
231
|
+
class DeleteModelSetRequest:
|
|
232
|
+
Project: str # json:"Project"
|
|
233
|
+
Id: str # json:"Id"
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@dataclass
|
|
237
|
+
class StopModelSetRequest:
|
|
238
|
+
Project: str # json:"Project"
|
|
239
|
+
Id: str # json:"Id"
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@dataclass
|
|
243
|
+
class StartModelSetRequest:
|
|
244
|
+
Project: str # json:"Project"
|
|
245
|
+
Id: str # json:"Id"
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
# Response models
|
|
249
|
+
@dataclass
|
|
250
|
+
class ModelSetDetail:
|
|
251
|
+
Id: str # json:"Id"
|
|
252
|
+
UId: str # json:"UId"
|
|
253
|
+
Status: str # json:"Status" # e.g., "Running", "Failed", "Updating"
|
|
254
|
+
ReadyReplicas: int # json:"ReadyReplicas"
|
|
255
|
+
TotalReplicas: int # json:"TotalReplicas"
|
|
256
|
+
Creator: str # json:"Creator"
|
|
257
|
+
CreatorId: str # json:"CreatorId"
|
|
258
|
+
|
|
259
|
+
# Basic info
|
|
260
|
+
Name: str # json:"Name"
|
|
261
|
+
Description: Optional[str] = None # json:"Description,omitempty"
|
|
262
|
+
QuotaGroup: str = "" # json:"QuotaGroup"
|
|
263
|
+
|
|
264
|
+
IsCPUQuotaGroup: bool = False # json:"IsCPUQuotaGroup"
|
|
265
|
+
QuotaGroupAllocateScope: str = "" # json:"QuotaGroupAllocateScope"
|
|
266
|
+
|
|
267
|
+
IsInference: bool = False # json:"IsInference"
|
|
268
|
+
IsIdle: bool = False # json:"IsIdle"
|
|
269
|
+
|
|
270
|
+
# Environment configuration
|
|
271
|
+
Image: str = "" # json:"Image"
|
|
272
|
+
Command: List[str] = field(default_factory=list) # json:"Command"
|
|
273
|
+
EnvVars: Optional[List[EnvironmentVar]] = None # json:"EnvVars,omitempty"
|
|
274
|
+
|
|
275
|
+
# Instance configuration
|
|
276
|
+
Distributed: bool = False # json:"Distributed" # whether distributed inference is enabled
|
|
277
|
+
InstanceCount: int = 0 # json:"InstanceCount" # instance count, effective when distributed inference is enabled
|
|
278
|
+
InstanceType: Optional[InstanceType] = None # json:"InstanceType"
|
|
279
|
+
Replicas: int = 0 # json:"Replicas" # replica count
|
|
280
|
+
RollingUpdate: Optional[RollingUpdateConfig] = None # json:"RollingUpdate,omitempty"
|
|
281
|
+
GpfsMounts: Optional[List[GPFSMount]] = None # json:"GPFSMounts,omitempty"
|
|
282
|
+
|
|
283
|
+
# Port configuration
|
|
284
|
+
Ports: List[PortConfig] = field(default_factory=list) # json:"Ports"
|
|
285
|
+
|
|
286
|
+
# Health check
|
|
287
|
+
LivenessProbe: Optional[ProbeConfig] = None # json:"LivenessProbe,omitempty"
|
|
288
|
+
ReadinessProbe: Optional[ProbeConfig] = None # json:"ReadinessProbe,omitempty"
|
|
289
|
+
StartupProbe: Optional[ProbeConfig] = None # json:"StartupProbe,omitempty"
|
|
290
|
+
|
|
291
|
+
CreationTimestamp: int = 0 # json:"CreationTimestamp" # milliseconds
|
|
292
|
+
|
|
293
|
+
# Only appears in return values, for chat
|
|
294
|
+
ServeName: str = "" # json:"ServeName"
|
|
295
|
+
PublicDomain: str = "" # json:"PublicDomain"
|
|
296
|
+
PublicIP: str = "" # json:"PublicIP"
|
|
297
|
+
ClusterDomain: str = "" # json:"ClusterDomain"
|
|
298
|
+
ClusterIP: str = "" # json:"ClusterIP"
|
|
299
|
+
APIKey: str = "" # json:"APIKey"
|
|
300
|
+
ServePorts: List[PortConfig] = field(default_factory=list) # json:"ServePorts"
|
|
301
|
+
|
|
302
|
+
AutoScalingConfig: Optional[AutoScalingConfig] = None # json:"AutoScalingConfig,omitempty"
|
|
303
|
+
|
|
304
|
+
# Model configuration
|
|
305
|
+
Model: Optional[ModelConfig] = None # json:"Model,omitempty"
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
@dataclass
|
|
309
|
+
class ModelSetReplica:
|
|
310
|
+
Id: str # json:"Id"
|
|
311
|
+
Status: str # json:"Status"
|
|
312
|
+
IP: str # json:"IP"
|
|
313
|
+
CreationTime: int # json:"CreationTime" # seconds
|
|
314
|
+
LatestCondition: str = "" # json:"LatestCondition"
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
# GET request models
|
|
318
|
+
@dataclass
|
|
319
|
+
class ListModelSetRequest:
|
|
320
|
+
Project: str # query:"Project" binding:"required"
|
|
321
|
+
Limit: int = 10 # query:"Limit" binding:"omitempty"
|
|
322
|
+
Offset: int = 0 # query:"Offset" binding:"omitempty"
|
|
323
|
+
SortBy: str = "" # query:"SortBy" binding:"omitempty"
|
|
324
|
+
SortDirection: str = "" # query:"SortDirection" binding:"omitempty"
|
|
325
|
+
Keyword: str = "" # query:"Keyword" binding:"omitempty"
|
|
326
|
+
Status: str = "" # query:"Status" binding:"omitempty"
|
|
327
|
+
LatestCondition: str = "" # query:"LatestCondition" binding:"omitempty"
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@dataclass
|
|
331
|
+
class GetModelSetRequest:
|
|
332
|
+
Project: str # query:"Project" binding:"required"
|
|
333
|
+
Id: str # query:"Id" binding:"required"
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
@dataclass
|
|
337
|
+
class ListModelSetReplicaRequest:
|
|
338
|
+
Project: str # query:"Project" binding:"required"
|
|
339
|
+
Id: str # query:"Id" binding:"required"
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
# List response models
|
|
343
|
+
@dataclass
|
|
344
|
+
class ListModelSetData:
|
|
345
|
+
Data: List[ModelSetDetail] = field(default_factory=list) # json:"Data"
|
|
346
|
+
Total: int = 0 # json:"Total"
|
|
347
|
+
Limit: int = 10 # json:"Limit"
|
|
348
|
+
Offset: int = 0 # json:"Offset"
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@dataclass
|
|
352
|
+
class ListModelSetReplicaData:
|
|
353
|
+
Items: List[ModelSetReplica] = field(default_factory=list) # json:"Items"
|
|
354
|
+
Total: int = 0 # json:"Total"
|
|
355
|
+
Limit: int = 10 # json:"Limit"
|
|
356
|
+
Offset: int = 0 # json:"Offset"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from yicloud.services.oss.client import OssClient as Client, client, use_client
|
|
2
|
+
from . import actions, models
|
|
3
|
+
|
|
4
|
+
from .actions import (
|
|
5
|
+
create_bucket,
|
|
6
|
+
delete_bucket,
|
|
7
|
+
update_bucket,
|
|
8
|
+
list_buckets,
|
|
9
|
+
get_bucket,
|
|
10
|
+
)
|
|
11
|
+
from .models import (
|
|
12
|
+
AuthType,
|
|
13
|
+
AuthMode,
|
|
14
|
+
State,
|
|
15
|
+
Auth,
|
|
16
|
+
Authorization,
|
|
17
|
+
CreateBucketRequest,
|
|
18
|
+
DeleteBucketRequest,
|
|
19
|
+
ListBucketsRequest,
|
|
20
|
+
UpdateBucketRequest,
|
|
21
|
+
GetBucketRequest,
|
|
22
|
+
MessageResponse,
|
|
23
|
+
BucketResponse,
|
|
24
|
+
ListBucketsResponse,
|
|
25
|
+
)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from yicloud.base import msgs
|
|
4
|
+
from yicloud.services.oss import models
|
|
5
|
+
from yicloud.services.oss.client import client
|
|
6
|
+
|
|
7
|
+
_PRODUCT_CODE = "oss"
|
|
8
|
+
_LAST_VERSION = "v1alpha1"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_bucket(ctx: Optional[dict], req: models.CreateBucketRequest) -> models.MessageResponse:
|
|
12
|
+
"""
|
|
13
|
+
POST /oss/v1alpha1/CreateBucket
|
|
14
|
+
Action: CreateBucket
|
|
15
|
+
|
|
16
|
+
Returns MessageResponse on success.
|
|
17
|
+
|
|
18
|
+
Raises YiCloudException on error.
|
|
19
|
+
"""
|
|
20
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/CreateBucket"
|
|
21
|
+
rsp = msgs.Rsp[models.MessageResponse]()
|
|
22
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
23
|
+
return rsp.get_typed_data()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def delete_bucket(ctx: Optional[dict], req: models.DeleteBucketRequest) -> models.MessageResponse:
|
|
27
|
+
"""
|
|
28
|
+
POST /oss/v1alpha1/DeleteBucket
|
|
29
|
+
Action: DeleteBucket
|
|
30
|
+
|
|
31
|
+
Returns MessageResponse on success.
|
|
32
|
+
|
|
33
|
+
Raises YiCloudException on error.
|
|
34
|
+
"""
|
|
35
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/DeleteBucket"
|
|
36
|
+
rsp = msgs.Rsp[models.MessageResponse]()
|
|
37
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
38
|
+
return rsp.get_typed_data()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def update_bucket(ctx: Optional[dict], req: models.UpdateBucketRequest) -> models.MessageResponse:
|
|
42
|
+
"""
|
|
43
|
+
POST /oss/v1alpha1/UpdateBucket
|
|
44
|
+
Action: UpdateBucket
|
|
45
|
+
|
|
46
|
+
Returns MessageResponse on success.
|
|
47
|
+
|
|
48
|
+
Raises YiCloudException on error.
|
|
49
|
+
"""
|
|
50
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/UpdateBucket"
|
|
51
|
+
rsp = msgs.Rsp[models.MessageResponse]()
|
|
52
|
+
client.base.post(ctx, path, req.__dict__, rsp)
|
|
53
|
+
return rsp.get_typed_data()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def list_buckets(ctx: Optional[dict], req: models.ListBucketsRequest) -> models.ListBucketsResponse:
|
|
57
|
+
"""
|
|
58
|
+
GET /oss/v1alpha1/ListBuckets
|
|
59
|
+
Action: ListBuckets
|
|
60
|
+
|
|
61
|
+
Returns ListBucketsResponse on success.
|
|
62
|
+
|
|
63
|
+
Raises YiCloudException on error.
|
|
64
|
+
"""
|
|
65
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListBuckets"
|
|
66
|
+
rsp = msgs.Rsp[models.ListBucketsResponse]()
|
|
67
|
+
client.base.get(ctx, path, req, rsp)
|
|
68
|
+
return rsp.get_typed_data()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_bucket(ctx: Optional[dict], req: models.GetBucketRequest) -> models.BucketResponse:
|
|
72
|
+
"""
|
|
73
|
+
GET /oss/v1alpha1/GetBucket
|
|
74
|
+
Action: GetBucket
|
|
75
|
+
|
|
76
|
+
Returns BucketResponse on success.
|
|
77
|
+
|
|
78
|
+
Raises YiCloudException on error.
|
|
79
|
+
"""
|
|
80
|
+
path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetBucket"
|
|
81
|
+
rsp = msgs.Rsp[models.BucketResponse]()
|
|
82
|
+
client.base.get(ctx, path, req, rsp)
|
|
83
|
+
return rsp.get_typed_data()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from yicloud.base import Client
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class OssClient:
|
|
5
|
+
"""OSS service client, matching Go SDK's services/oss/client.go."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, base_client: Client = None):
|
|
8
|
+
self.base = base_client
|
|
9
|
+
self.product_code = "oss"
|
|
10
|
+
self.last_version = "v1alpha1"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Singleton matching Go SDK
|
|
14
|
+
client: OssClient = OssClient()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def use_client(cli: Client) -> None:
|
|
18
|
+
"""Set the base client for OSS service."""
|
|
19
|
+
client.base = cli
|