| @@ -64,6 +64,11 @@ type CreateJobReq struct { | |||||
| DataDistribute DataDistribute `json:"dataDistributes"` | DataDistribute DataDistribute `json:"dataDistributes"` | ||||
| } | } | ||||
| type CommonJsonData struct { | |||||
| ID string `json:"id"` | |||||
| Name string `json:"name"` | |||||
| } | |||||
| type DataDistribute struct { | type DataDistribute struct { | ||||
| Dataset []DatasetDistribute `json:"dataset"` | Dataset []DatasetDistribute `json:"dataset"` | ||||
| Code []CodeDistribute `json:"code"` | Code []CodeDistribute `json:"code"` | ||||
| @@ -90,9 +95,10 @@ type CodeDistribute struct { | |||||
| } | } | ||||
| type ImageDistribute struct { | type ImageDistribute struct { | ||||
| DataName string `json:"dataName"` | |||||
| PackageID cdssdk.PackageID `json:"packageID"` | |||||
| Clusters []DataDetail `json:"clusters"` | |||||
| DataName string `json:"dataName"` | |||||
| //PackageID cdssdk.PackageID `json:"packageID"` | |||||
| ImageID schsdk.ImageID `json:"imageID"` | |||||
| Clusters []DataDetail `json:"clusters"` | |||||
| } | } | ||||
| type ModelDistribute struct { | type ModelDistribute struct { | ||||
| @@ -58,9 +58,13 @@ const ( | |||||
| PlatformSugon = "sugon" | PlatformSugon = "sugon" | ||||
| PlatformOpenI = "openi" | PlatformOpenI = "openi" | ||||
| PlatformModelArts = "modelarts" | PlatformModelArts = "modelarts" | ||||
| URL = "url" | |||||
| ID = "id" | |||||
| ) | ) | ||||
| type TaskID int64 | type TaskID int64 | ||||
| type DataID int64 | |||||
| type ClusterDetail struct { | type ClusterDetail struct { | ||||
| // 集群ID | // 集群ID | ||||
| @@ -395,14 +399,15 @@ type ModelBinding struct { | |||||
| type CodeBinding struct { | type CodeBinding struct { | ||||
| serder.Metadata `union:"code"` | serder.Metadata `union:"code"` | ||||
| DataBindingBase | DataBindingBase | ||||
| Type string `json:"type"` | |||||
| Name string `json:"name"` | |||||
| ClusterIDs []schsdk.ClusterID `json:"clusterIDs"` | |||||
| Description string `json:"description"` | |||||
| ImageID int64 `json:"imageID"` | |||||
| ObjectID cdssdk.ObjectID `json:"objectID"` | |||||
| FilePath string `json:"filePath"` | |||||
| PackageID cdssdk.PackageID `json:"packageID"` | |||||
| Type string `json:"type"` | |||||
| Name string `json:"name"` | |||||
| //ClusterIDs []schsdk.ClusterID `json:"clusterIDs"` | |||||
| ClusterID schsdk.ClusterID `json:"clusterID"` | |||||
| Description string `json:"description"` | |||||
| ImageID schsdk.ImageID `json:"imageID"` | |||||
| BootstrapObjectID cdssdk.ObjectID `json:"bootstrapObjectID"` | |||||
| //FilePath string `json:"filePath"` | |||||
| PackageID cdssdk.PackageID `json:"packageID"` | |||||
| } | } | ||||
| //type ImageBinding struct { | //type ImageBinding struct { | ||||
| @@ -115,7 +115,7 @@ type PCMJobRuntimeInfo struct { | |||||
| //} | //} | ||||
| type JobResource interface { | type JobResource interface { | ||||
| Noop2() | |||||
| Noop() | |||||
| } | } | ||||
| var JobResourceTypeUnion = types.NewTypeUnion[JobResource]( | var JobResourceTypeUnion = types.NewTypeUnion[JobResource]( | ||||
| @@ -132,7 +132,7 @@ var _ = serder.UseTypeUnionInternallyTagged(&JobResourceTypeUnion, "type") | |||||
| type JobResourceBase struct{} | type JobResourceBase struct{} | ||||
| func (d *JobResourceBase) Noop2() {} | |||||
| func (d *JobResourceBase) Noop() {} | |||||
| type CPU struct { | type CPU struct { | ||||
| serder.Metadata `union:"CPU"` | serder.Metadata `union:"CPU"` | ||||
| @@ -25,14 +25,24 @@ func (BlockChain) TableName() string { | |||||
| } | } | ||||
| type Binding struct { | type Binding struct { | ||||
| ID DataID `gorm:"column:id;primaryKey;autoIncrement" json:"ID"` | |||||
| UserID cdssdk.UserID `gorm:"column:user_id" json:"userID"` | |||||
| Name string `gorm:"column:name" json:"Name"` | |||||
| DataType string `gorm:"column:data_type" json:"dataType"` | |||||
| //JsonData string `gorm:"column:json_data" json:"jsonData"` | |||||
| Content string `gorm:"column:content" json:"Content"` | |||||
| AccessLevel string `gorm:"column:access_level" json:"accessLevel"` | |||||
| CreateTime time.Time `gorm:"column:created_at" json:"createTime"` | |||||
| ID DataID `gorm:"column:id;primaryKey;autoIncrement" json:"ID"` | |||||
| UserID cdssdk.UserID `gorm:"column:user_id" json:"userID"` | |||||
| Name string `gorm:"column:name" json:"Name"` | |||||
| DataType string `gorm:"column:data_type" json:"dataType"` | |||||
| Content string `gorm:"column:content" json:"Content"` | |||||
| AccessLevel string `gorm:"column:access_level" json:"accessLevel"` | |||||
| CreateTime time.Time `gorm:"column:created_at" json:"createTime"` | |||||
| } | |||||
| type BindingDAO struct { | |||||
| ID DataID `gorm:"column:id;primaryKey;autoIncrement" json:"ID"` | |||||
| UserID cdssdk.UserID `gorm:"column:user_id" json:"userID"` | |||||
| Name string `gorm:"column:name" json:"Name"` | |||||
| DataType string `gorm:"column:data_type" json:"dataType"` | |||||
| Content string `gorm:"column:content" json:"Content"` | |||||
| AccessLevel string `gorm:"column:access_level" json:"accessLevel"` | |||||
| CreateTime time.Time `gorm:"column:created_at" json:"createTime"` | |||||
| BindingCluster []BindingCluster `gorm:"foreignKey:binding_id;references:id" json:"bindingCluster"` | |||||
| } | } | ||||
| type BindingAccessData struct { | type BindingAccessData struct { | ||||
| @@ -73,6 +83,10 @@ type BindingCluster struct { | |||||
| JsonData string `gorm:"column:json_data" json:"jsonData"` | JsonData string `gorm:"column:json_data" json:"jsonData"` | ||||
| } | } | ||||
| func (BindingCluster) TableName() string { | |||||
| return "bindingCluster" // 确保和数据库中的表名一致 | |||||
| } | |||||
| type Folder struct { | type Folder struct { | ||||
| PackageID cdssdk.PackageID `gorm:"column:package_id" json:"packageID"` | PackageID cdssdk.PackageID `gorm:"column:package_id" json:"packageID"` | ||||
| Path string `gorm:"column:path_name" json:"path"` | Path string `gorm:"column:path_name" json:"path"` | ||||
| @@ -136,6 +150,7 @@ type PackageCloneDAO struct { | |||||
| ClusterID schsdk.ClusterID `gorm:"column:cluster_id" json:"clusterID"` | ClusterID schsdk.ClusterID `gorm:"column:cluster_id" json:"clusterID"` | ||||
| ParentImageID schsdk.ImageID `gorm:"column:parent_image_id" json:"parentImageID"` | ParentImageID schsdk.ImageID `gorm:"column:parent_image_id" json:"parentImageID"` | ||||
| ImageID string `gorm:"column:image_id" json:"imageID"` | ImageID string `gorm:"column:image_id" json:"imageID"` | ||||
| BindingID DataID `gorm:"column:binding_id" json:"bindingID"` | |||||
| CreateTime time.Time `gorm:"column:created_at" json:"createTime"` | CreateTime time.Time `gorm:"column:created_at" json:"createTime"` | ||||
| } | } | ||||
| @@ -3,7 +3,6 @@ package uploadersdk | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "gitlink.org.cn/cloudream/common/pkgs/types" | "gitlink.org.cn/cloudream/common/pkgs/types" | ||||
| sch "gitlink.org.cn/cloudream/common/sdks/pcmscheduler" | |||||
| cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | ||||
| "gitlink.org.cn/cloudream/common/sdks/storage/cdsapi" | "gitlink.org.cn/cloudream/common/sdks/storage/cdsapi" | ||||
| "gitlink.org.cn/cloudream/common/utils/http2" | "gitlink.org.cn/cloudream/common/utils/http2" | ||||
| @@ -12,65 +11,65 @@ import ( | |||||
| "strings" | "strings" | ||||
| ) | ) | ||||
| type DataScheduleReq struct { | |||||
| PackageID cdssdk.PackageID `json:"packageID"` | |||||
| DataType string `json:"dataType"` | |||||
| ScheduleTarget ScheduleTarget `json:"scheduleTarget"` | |||||
| } | |||||
| //type DataScheduleReq struct { | |||||
| // PackageID cdssdk.PackageID `json:"packageID"` | |||||
| // DataType string `json:"dataType"` | |||||
| // ScheduleTarget ScheduleTarget `json:"scheduleTarget"` | |||||
| //} | |||||
| //type DataScheduleResp struct { | //type DataScheduleResp struct { | ||||
| // Results []sch.DataScheduleResult `json:"data"` | // Results []sch.DataScheduleResult `json:"data"` | ||||
| //} | //} | ||||
| type TmpDataScheduleResult struct { | |||||
| Cluster sch.DataDetail `json:"cluster"` | |||||
| PackageID cdssdk.PackageID `json:"packageID"` | |||||
| Status bool `json:"status"` | |||||
| Msg string `json:"msg"` | |||||
| } | |||||
| func (c *Client) DataSchedule(req DataScheduleReq) ([]sch.DataScheduleResult, error) { | |||||
| targetUrl, err := url.JoinPath(c.baseURL, "/dataSchedule") | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| resp, err := http2.PostJSON(targetUrl, http2.RequestParam{ | |||||
| Body: req, | |||||
| }) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| println(resp.Body) | |||||
| contType := resp.Header.Get("Content-Type") | |||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | |||||
| var codeResp response[[]TmpDataScheduleResult] | |||||
| if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { | |||||
| return nil, fmt.Errorf("parsing response: %w", err) | |||||
| } | |||||
| if codeResp.Code == ResponseCodeOK { | |||||
| var results []sch.DataScheduleResult | |||||
| for _, tmpResult := range codeResp.Data { | |||||
| result := sch.DataScheduleResult{ | |||||
| PackageID: tmpResult.PackageID, | |||||
| Status: tmpResult.Status, | |||||
| Msg: tmpResult.Msg, | |||||
| Clusters: []sch.DataDetail{ | |||||
| tmpResult.Cluster, | |||||
| }, | |||||
| } | |||||
| results = append(results, result) | |||||
| } | |||||
| return results, nil | |||||
| } | |||||
| return nil, codeResp.ToError() | |||||
| } | |||||
| //type TmpDataScheduleResult struct { | |||||
| // Cluster sch.DataDetail `json:"cluster"` | |||||
| // PackageID cdssdk.PackageID `json:"packageID"` | |||||
| // Status bool `json:"status"` | |||||
| // Msg string `json:"msg"` | |||||
| //} | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | |||||
| } | |||||
| //func (c *Client) DataSchedule(req DataScheduleReq) ([]sch.DataScheduleResult, error) { | |||||
| // targetUrl, err := url.JoinPath(c.baseURL, "/dataSchedule") | |||||
| // if err != nil { | |||||
| // return nil, err | |||||
| // } | |||||
| // | |||||
| // resp, err := http2.PostJSON(targetUrl, http2.RequestParam{ | |||||
| // Body: req, | |||||
| // }) | |||||
| // if err != nil { | |||||
| // return nil, err | |||||
| // } | |||||
| // println(resp.Body) | |||||
| // | |||||
| // contType := resp.Header.Get("Content-Type") | |||||
| // if strings.Contains(contType, http2.ContentTypeJSON) { | |||||
| // var codeResp response[[]TmpDataScheduleResult] | |||||
| // if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { | |||||
| // return nil, fmt.Errorf("parsing response: %w", err) | |||||
| // } | |||||
| // | |||||
| // if codeResp.Code == ResponseCodeOK { | |||||
| // var results []sch.DataScheduleResult | |||||
| // for _, tmpResult := range codeResp.Data { | |||||
| // result := sch.DataScheduleResult{ | |||||
| // PackageID: tmpResult.PackageID, | |||||
| // Status: tmpResult.Status, | |||||
| // Msg: tmpResult.Msg, | |||||
| // Clusters: []sch.DataDetail{ | |||||
| // tmpResult.Cluster, | |||||
| // }, | |||||
| // } | |||||
| // results = append(results, result) | |||||
| // } | |||||
| // return results, nil | |||||
| // } | |||||
| // | |||||
| // return nil, codeResp.ToError() | |||||
| // } | |||||
| // | |||||
| // return nil, fmt.Errorf("unknow response content type: %s", contType) | |||||
| //} | |||||
| type UploadReq struct { | type UploadReq struct { | ||||
| DataType string `json:"dataType"` | DataType string `json:"dataType"` | ||||