| @@ -64,6 +64,11 @@ type CreateJobReq struct { | |||
| DataDistribute DataDistribute `json:"dataDistributes"` | |||
| } | |||
| type CommonJsonData struct { | |||
| ID string `json:"id"` | |||
| Name string `json:"name"` | |||
| } | |||
| type DataDistribute struct { | |||
| Dataset []DatasetDistribute `json:"dataset"` | |||
| Code []CodeDistribute `json:"code"` | |||
| @@ -90,9 +95,10 @@ type CodeDistribute 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 { | |||
| @@ -58,9 +58,13 @@ const ( | |||
| PlatformSugon = "sugon" | |||
| PlatformOpenI = "openi" | |||
| PlatformModelArts = "modelarts" | |||
| URL = "url" | |||
| ID = "id" | |||
| ) | |||
| type TaskID int64 | |||
| type DataID int64 | |||
| type ClusterDetail struct { | |||
| // 集群ID | |||
| @@ -395,14 +399,15 @@ type ModelBinding struct { | |||
| type CodeBinding struct { | |||
| serder.Metadata `union:"code"` | |||
| 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 { | |||
| @@ -115,7 +115,7 @@ type PCMJobRuntimeInfo struct { | |||
| //} | |||
| type JobResource interface { | |||
| Noop2() | |||
| Noop() | |||
| } | |||
| var JobResourceTypeUnion = types.NewTypeUnion[JobResource]( | |||
| @@ -132,7 +132,7 @@ var _ = serder.UseTypeUnionInternallyTagged(&JobResourceTypeUnion, "type") | |||
| type JobResourceBase struct{} | |||
| func (d *JobResourceBase) Noop2() {} | |||
| func (d *JobResourceBase) Noop() {} | |||
| type CPU struct { | |||
| serder.Metadata `union:"CPU"` | |||
| @@ -25,14 +25,24 @@ func (BlockChain) TableName() string { | |||
| } | |||
| 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 { | |||
| @@ -73,6 +83,10 @@ type BindingCluster struct { | |||
| JsonData string `gorm:"column:json_data" json:"jsonData"` | |||
| } | |||
| func (BindingCluster) TableName() string { | |||
| return "bindingCluster" // 确保和数据库中的表名一致 | |||
| } | |||
| type Folder struct { | |||
| PackageID cdssdk.PackageID `gorm:"column:package_id" json:"packageID"` | |||
| Path string `gorm:"column:path_name" json:"path"` | |||
| @@ -136,6 +150,7 @@ type PackageCloneDAO struct { | |||
| ClusterID schsdk.ClusterID `gorm:"column:cluster_id" json:"clusterID"` | |||
| ParentImageID schsdk.ImageID `gorm:"column:parent_image_id" json:"parentImageID"` | |||
| 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"` | |||
| } | |||
| @@ -3,7 +3,6 @@ package uploadersdk | |||
| import ( | |||
| "fmt" | |||
| "gitlink.org.cn/cloudream/common/pkgs/types" | |||
| sch "gitlink.org.cn/cloudream/common/sdks/pcmscheduler" | |||
| cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" | |||
| "gitlink.org.cn/cloudream/common/sdks/storage/cdsapi" | |||
| "gitlink.org.cn/cloudream/common/utils/http2" | |||
| @@ -12,65 +11,65 @@ import ( | |||
| "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 { | |||
| // 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 { | |||
| DataType string `json:"dataType"` | |||