| @@ -8,4 +8,5 @@ const ( | |||||
| BadArgument = "BadArgument" | BadArgument = "BadArgument" | ||||
| TaskNotFound = "TaskNotFound" | TaskNotFound = "TaskNotFound" | ||||
| Unauthorized = "Unauthorized" | Unauthorized = "Unauthorized" | ||||
| UnknownError = "UnknownError" | |||||
| ) | ) | ||||
| @@ -2,11 +2,12 @@ package cloud | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "net/url" | |||||
| "strings" | |||||
| schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | ||||
| "gitlink.org.cn/cloudream/common/utils/http2" | "gitlink.org.cn/cloudream/common/utils/http2" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| "net/url" | |||||
| "strings" | |||||
| ) | ) | ||||
| //type CreateParam struct { | //type CreateParam struct { | ||||
| @@ -40,6 +41,7 @@ type CreateCloudJobReq struct { | |||||
| MountPath string `json:"mountPath,omitempty"` | MountPath string `json:"mountPath,omitempty"` | ||||
| Args []string `json:"args,omitempty"` | Args []string `json:"args,omitempty"` | ||||
| Envs []interface{} `json:"envs,omitempty"` | Envs []interface{} `json:"envs,omitempty"` | ||||
| Capacity int32 `json:"capacity,omitempty"` | |||||
| } | } | ||||
| // type T2 struct { | // type T2 struct { | ||||
| @@ -2,11 +2,12 @@ package hpc | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "net/url" | |||||
| "strings" | |||||
| schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | ||||
| "gitlink.org.cn/cloudream/common/utils/http2" | "gitlink.org.cn/cloudream/common/utils/http2" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| "net/url" | |||||
| "strings" | |||||
| ) | ) | ||||
| type CreateHPCJobReq struct { | type CreateHPCJobReq struct { | ||||
| @@ -81,3 +82,39 @@ func (c *Client) CreateJob(req CreateHPCJobReq, token string) (*CreateJobResp, e | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| func (c *Client) GetHPCAppClusters(app string, token string) (*AppClusterResp, error) { | |||||
| targetUrl, err := url.JoinPath(c.baseURL, "/hpc/getHpcAppCluster") | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| resp, err := http2.GetForm(targetUrl, http2.RequestParam{ | |||||
| Query: map[string]string{ | |||||
| "app": app, | |||||
| }, | |||||
| Header: map[string]string{ | |||||
| "Authorization": token, | |||||
| }, | |||||
| }) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| contType := resp.Header.Get("Content-Type") | |||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | |||||
| var codeResp respons2[AppClusterResp] | |||||
| if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { | |||||
| return nil, fmt.Errorf("parsing response: %w", err) | |||||
| } | |||||
| if codeResp.Code == ResponseCodeOK { | |||||
| return &codeResp.Data, nil | |||||
| } | |||||
| return nil, fmt.Errorf("error: %s", codeResp.Message) | |||||
| } | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | |||||
| } | |||||
| @@ -1,11 +1,12 @@ | |||||
| package hpc | package hpc | ||||
| import ( | import ( | ||||
| "time" | |||||
| "gitlink.org.cn/cloudream/common/pkgs/types" | "gitlink.org.cn/cloudream/common/pkgs/types" | ||||
| schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | ||||
| cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| "time" | |||||
| ) | ) | ||||
| type ResourceType string | type ResourceType string | ||||
| @@ -523,3 +524,12 @@ type PublicLevel struct { | |||||
| Type string `json:"type" binding:"required"` | Type string `json:"type" binding:"required"` | ||||
| Info DataBinding `json:"info"` // 可选,用于精细筛选,功能暂未实现 | Info DataBinding `json:"info"` // 可选,用于精细筛选,功能暂未实现 | ||||
| } | } | ||||
| type AppClusterResp struct { | |||||
| List []struct { | |||||
| Id string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| Nickname string `json:"nickname"` | |||||
| Region string `json:"region"` | |||||
| } `json:"list"` | |||||
| } | |||||
| @@ -12,6 +12,7 @@ type PCMJob struct { | |||||
| UserID cdssdk.UserID `gorm:"column:user_id" json:"userID"` | UserID cdssdk.UserID `gorm:"column:user_id" json:"userID"` | ||||
| JobSetID schsdk.JobSetID `gorm:"column:jobset_id" json:"jobSetID"` | JobSetID schsdk.JobSetID `gorm:"column:jobset_id" json:"jobSetID"` | ||||
| LocalJobID string `gorm:"column:local_job_id" json:"localJobID"` | LocalJobID string `gorm:"column:local_job_id" json:"localJobID"` | ||||
| Info string `gorm:"column:info" json:"info"` | |||||
| Param string `gorm:"column:param" json:"param"` | Param string `gorm:"column:param" json:"param"` | ||||
| Token string `gorm:"column:token" json:"token"` | Token string `gorm:"column:token" json:"token"` | ||||
| CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` | CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` | ||||
| @@ -10,9 +10,11 @@ import ( | |||||
| ) | ) | ||||
| type QueryTasksReq struct { | type QueryTasksReq struct { | ||||
| PageNum int64 `form:"pageNum"` | |||||
| PageSize int64 `form:"pageSize"` | |||||
| Type int64 `form:"type"` | |||||
| PageNum int64 `form:"pageNum"` | |||||
| PageSize int64 `form:"pageSize"` | |||||
| Type int64 `form:"type"` | |||||
| Name string `form:"name"` | |||||
| Status string `form:"status"` | |||||
| } | } | ||||
| type QueryTasksResp struct { | type QueryTasksResp struct { | ||||
| @@ -236,9 +238,6 @@ func (c *Client) QueryAITrainLog(req QueryAITrainLogReq, token string) (*QueryAI | |||||
| return nil, err | return nil, err | ||||
| } | } | ||||
| //req.AdapterID = "1777144940459986944" | |||||
| //req.InstanceNum = "0" | |||||
| resp, err := http2.GetJSON(targetUrl, http2.RequestParam{ | resp, err := http2.GetJSON(targetUrl, http2.RequestParam{ | ||||
| Query: req, | Query: req, | ||||
| Header: map[string]string{ | Header: map[string]string{ | ||||
| @@ -249,6 +248,9 @@ func (c *Client) QueryAITrainLog(req QueryAITrainLogReq, token string) (*QueryAI | |||||
| return nil, err | return nil, err | ||||
| } | } | ||||
| //all, err := io.ReadAll(resp.Body) | |||||
| //println(string(all)) | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | if strings.Contains(contType, http2.ContentTypeJSON) { | ||||
| var codeResp response[QueryAITrainLogResp] | var codeResp response[QueryAITrainLogResp] | ||||
| @@ -2,12 +2,15 @@ package sch | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "io" | |||||
| "net/url" | |||||
| "strings" | |||||
| "gitlink.org.cn/cloudream/common/pkgs/logger" | |||||
| schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | ||||
| cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | ||||
| "gitlink.org.cn/cloudream/common/utils/http2" | "gitlink.org.cn/cloudream/common/utils/http2" | ||||
| "gitlink.org.cn/cloudream/common/utils/serder" | "gitlink.org.cn/cloudream/common/utils/serder" | ||||
| "net/url" | |||||
| "strings" | |||||
| ) | ) | ||||
| type GetClusterInfoReq struct { | type GetClusterInfoReq struct { | ||||
| @@ -226,6 +229,9 @@ func (c *Client) CreateJob(req CreateAIJobReq, token string) (*CreateJobResp, er | |||||
| return nil, err | return nil, err | ||||
| } | } | ||||
| //all, err := io.ReadAll(resp.Body) | |||||
| //println(string(all)) | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | if strings.Contains(contType, http2.ContentTypeJSON) { | ||||
| var codeResp response2[CreateJobResp] | var codeResp response2[CreateJobResp] | ||||
| @@ -329,11 +335,12 @@ func (c *Client) CancelJob(req CancelJobReq) error { | |||||
| } | } | ||||
| type GetResourceSpecReq struct { | type GetResourceSpecReq struct { | ||||
| ClusterID schsdk.ClusterID `form:"clusterId"` | |||||
| Tag string `form:"tag"` | |||||
| PageNum int64 `form:"pageNum"` | |||||
| PageSize int64 `form:"pageSize"` | |||||
| Status string `form:"status"` | |||||
| ClusterID schsdk.ClusterID `form:"clusterId"` | |||||
| Tag string `form:"tag"` | |||||
| PageNum int64 `form:"pageNum"` | |||||
| PageSize int64 `form:"pageSize"` | |||||
| Status string `form:"status"` | |||||
| ClusterType string `form:"clusterType"` | |||||
| } | } | ||||
| type GetResourceSpecResp struct { | type GetResourceSpecResp struct { | ||||
| @@ -459,6 +466,9 @@ func (c *Client) BindModel(req BindReq, token string) (*BindResp, error) { | |||||
| return nil, err | return nil, err | ||||
| } | } | ||||
| //all, err := io.ReadAll(resp.Body) | |||||
| //println(string(all)) | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | if strings.Contains(contType, http2.ContentTypeJSON) { | ||||
| var codeResp response2[BindResp] | var codeResp response2[BindResp] | ||||
| @@ -492,6 +502,9 @@ func (c *Client) BindDataSet(req BindReq, token string) (*BindResp, error) { | |||||
| return nil, err | return nil, err | ||||
| } | } | ||||
| //all, err := io.ReadAll(resp.Body) | |||||
| //println(string(all)) | |||||
| contType := resp.Header.Get("Content-Type") | contType := resp.Header.Get("Content-Type") | ||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | if strings.Contains(contType, http2.ContentTypeJSON) { | ||||
| var codeResp response2[BindResp] | var codeResp response2[BindResp] | ||||
| @@ -506,6 +519,9 @@ func (c *Client) BindDataSet(req BindReq, token string) (*BindResp, error) { | |||||
| return nil, fmt.Errorf("error: %s", codeResp.Message) | return nil, fmt.Errorf("error: %s", codeResp.Message) | ||||
| } | } | ||||
| all, err := io.ReadAll(resp.Body) | |||||
| logger.Errorf("BindDataSet error: %s, url: %s", string(all), targetUrl) | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | return nil, fmt.Errorf("unknow response content type: %s", contType) | ||||
| } | } | ||||
| @@ -66,6 +66,10 @@ const ( | |||||
| ChildrenType = "children" | ChildrenType = "children" | ||||
| ParentType = "parent" | ParentType = "parent" | ||||
| CreateType = "create" | |||||
| CloneType = "clone" | |||||
| InsertType = "insert" | |||||
| PlatformSugon = "sugon" | PlatformSugon = "sugon" | ||||
| PlatformOpenI = "OpenI" | PlatformOpenI = "OpenI" | ||||
| PlatformModelArts = "ModelArts" | PlatformModelArts = "ModelArts" | ||||
| @@ -154,24 +158,24 @@ type ResourceDetail struct { | |||||
| CostPerUnit float64 `json:"costPerUnit"` | CostPerUnit float64 `json:"costPerUnit"` | ||||
| CostType string `json:"costType"` | CostType string `json:"costType"` | ||||
| Tag string `json:"tag"` | Tag string `json:"tag"` | ||||
| UserID cdssdk.UserID `json:"userId"` | |||||
| UserID string `json:"userId"` | |||||
| CreateTime string `json:"createTime"` | CreateTime string `json:"createTime"` | ||||
| UpdateTime string `json:"updateTime"` | UpdateTime string `json:"updateTime"` | ||||
| BaseResourceSpecs []ResourceSpec `json:"baseResourceSpecs"` | BaseResourceSpecs []ResourceSpec `json:"baseResourceSpecs"` | ||||
| } | } | ||||
| type ResourceSpec struct { | type ResourceSpec struct { | ||||
| ID DataID `json:"id"` | |||||
| ResourceSpecId DataID `json:"resourceSpecId"` | |||||
| Type ResourceType `json:"type"` | |||||
| Name string `json:"name"` | |||||
| TotalValue float64 `json:"totalValue"` | |||||
| TotalUnit string `json:"totalUnit"` | |||||
| AvailableValue float64 `json:"availableValue"` | |||||
| AvailableUnit string `json:"availableUnit"` | |||||
| UserID cdssdk.UserID `json:"userId"` | |||||
| CreateTime string `json:"createTime"` | |||||
| UpdateTime string `json:"updateTime"` | |||||
| ID DataID `json:"id"` | |||||
| ResourceSpecId DataID `json:"resourceSpecId"` | |||||
| Type ResourceType `json:"type"` | |||||
| Name string `json:"name"` | |||||
| TotalValue float64 `json:"totalValue"` | |||||
| TotalUnit string `json:"totalUnit"` | |||||
| AvailableValue float64 `json:"availableValue"` | |||||
| AvailableUnit string `json:"availableUnit"` | |||||
| UserID string `json:"userId"` | |||||
| CreateTime string `json:"createTime"` | |||||
| UpdateTime string `json:"updateTime"` | |||||
| } | } | ||||
| type ResourceData interface { | type ResourceData interface { | ||||
| @@ -520,8 +524,9 @@ func (ClusterImageCard) TableName() string { | |||||
| } | } | ||||
| type QueryBindingFilters struct { | type QueryBindingFilters struct { | ||||
| Status string `json:"status"` | |||||
| Name string `json:"name"` | |||||
| Status string `json:"status"` | |||||
| Name string `json:"name"` | |||||
| ClusterIDs []schsdk.ClusterID `json:"clusterIDs"` | |||||
| } | } | ||||
| type QueryBindingDataParam interface { | type QueryBindingDataParam interface { | ||||
| @@ -532,6 +537,7 @@ var QueryBindingDataParamTypeUnion = types.NewTypeUnion[QueryBindingDataParam]( | |||||
| (*PrivateLevel)(nil), | (*PrivateLevel)(nil), | ||||
| (*ApplyLevel)(nil), | (*ApplyLevel)(nil), | ||||
| (*PublicLevel)(nil), | (*PublicLevel)(nil), | ||||
| (*CommonDataParam)(nil), | |||||
| ) | ) | ||||
| var _ = serder.UseTypeUnionInternallyTagged(&QueryBindingDataParamTypeUnion, "type") | var _ = serder.UseTypeUnionInternallyTagged(&QueryBindingDataParamTypeUnion, "type") | ||||
| @@ -564,3 +570,11 @@ type PublicLevel struct { | |||||
| Type string `json:"type" binding:"required"` | Type string `json:"type" binding:"required"` | ||||
| Info schsdk.DataBinding `json:"info"` // 可选,用于精细筛选,功能暂未实现 | Info schsdk.DataBinding `json:"info"` // 可选,用于精细筛选,功能暂未实现 | ||||
| } | } | ||||
| type CommonDataParam struct { | |||||
| serder.Metadata `union:"common"` | |||||
| QueryBindingDataParamBase | |||||
| Type string `json:"type" binding:"required"` | |||||
| UserID cdssdk.UserID `json:"userID" binding:"required"` | |||||
| BindingIDs []int64 `json:"bindingIDs" binding:"required"` | |||||
| } | |||||
| @@ -91,6 +91,11 @@ type Folder struct { | |||||
| CreateTime time.Time `gorm:"column:create_time" json:"createTime"` | CreateTime time.Time `gorm:"column:create_time" json:"createTime"` | ||||
| } | } | ||||
| type BindingCount struct { | |||||
| Count int64 `gorm:"column:count" json:"count"` | |||||
| DataType string `gorm:"column:data_type" json:"dataType"` | |||||
| } | |||||
| func (Folder) TableName() string { | func (Folder) TableName() string { | ||||
| return "folders" | return "folders" | ||||
| } | } | ||||
| @@ -0,0 +1,34 @@ | |||||
| package schsdk | |||||
| import ( | |||||
| "gitlink.org.cn/cloudream/common/pkgs/types" | |||||
| "gitlink.org.cn/cloudream/common/utils/serder" | |||||
| ) | |||||
| type JCWNodeInfos struct { | |||||
| Jobs []JobInfo `json:"jobs"` | |||||
| } | |||||
| type JCWNode interface { | |||||
| } | |||||
| var JCWNodeTypeUnion = types.NewTypeUnion[JCWNode]( | |||||
| (*JCWAITrainNode)(nil), | |||||
| ) | |||||
| var _ = serder.UseTypeUnionInternallyTagged(&JCWNodeTypeUnion, "type") | |||||
| type JCWNodeBase struct { | |||||
| LocalJobID string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| } | |||||
| type JCWAITrainNode struct { | |||||
| serder.Metadata `union:"Normal"` | |||||
| JobInfoBase | |||||
| Type string `json:"type"` | |||||
| Files JobFilesInfo `json:"files"` | |||||
| Runtime JobRuntimeInfo `json:"runtime"` | |||||
| Resources JobResourcesInfo `json:"resources"` | |||||
| Services JobServicesInfo `json:"services"` | |||||
| ModelJobInfo ModelJobInfo `json:"modelJobInfo"` | |||||
| } | |||||
| @@ -228,6 +228,7 @@ type CloudJobInfo struct { | |||||
| MountPath string `json:"mountPath,omitempty"` | MountPath string `json:"mountPath,omitempty"` | ||||
| Args []string `json:"args,omitempty"` | Args []string `json:"args,omitempty"` | ||||
| Envs []interface{} `json:"envs,omitempty"` | Envs []interface{} `json:"envs,omitempty"` | ||||
| Capacity int32 `json:"capacity,omitempty"` | |||||
| } | } | ||||
| type NotifyJobInfo struct { | type NotifyJobInfo struct { | ||||
| @@ -97,6 +97,14 @@ func ObjectToJSON(obj any) ([]byte, error) { | |||||
| return json.Marshal(obj) | return json.Marshal(obj) | ||||
| } | } | ||||
| func ObjectToJSONString(obj any) string { | |||||
| marshal, err := json.Marshal(obj) | |||||
| if err != nil { | |||||
| return err.Error() | |||||
| } | |||||
| return string(marshal) | |||||
| } | |||||
| // 将对象转为JSON字符串。如果需要支持解析TypeUnion类型,则使用"Ex"结尾的同名函数。 | // 将对象转为JSON字符串。如果需要支持解析TypeUnion类型,则使用"Ex"结尾的同名函数。 | ||||
| func ObjectToJSONStream(obj any) io.ReadCloser { | func ObjectToJSONStream(obj any) io.ReadCloser { | ||||
| pr, pw := io.Pipe() | pr, pw := io.Pipe() | ||||