| @@ -163,11 +163,14 @@ func (c *Client) CreateInferenceJob(req CreateAIJobReq, token string) (*CreateIn | |||||
| } | } | ||||
| type StopInferenceJobReq struct { | type StopInferenceJobReq struct { | ||||
| TaskId string `json:"taskId"` | |||||
| AdapterID string `json:"adapterId"` | |||||
| ClusterID schsdk.ClusterID `json:"clusterId"` | |||||
| ID string `json:"id"` | |||||
| InstanceID string `json:"instanceId"` | |||||
| } | } | ||||
| func (c *Client) StopInferenceJob(req StopInferenceJobReq, token string) error { | func (c *Client) StopInferenceJob(req StopInferenceJobReq, token string) error { | ||||
| targetUrl, err := url.JoinPath(c.baseURL, "inference/createTask") | |||||
| targetUrl, err := url.JoinPath(c.baseURL, "inference/stopDeployInstance") | |||||
| if err != nil { | if err != nil { | ||||
| return err | return err | ||||
| } | } | ||||
| @@ -86,13 +86,15 @@ const ( | |||||
| Complete = "Complete" | Complete = "Complete" | ||||
| NodeTypeBinding = "binding" | |||||
| NodeTypeUpload = "upload" | |||||
| NodeTypeDataReturn = "data_return" | |||||
| NodeTypeHPCCreate = "hpc_create" | |||||
| NodeTypeInference = "inference" | |||||
| NodeTypeAICreate = "ai_job_create" | |||||
| NodeTypeAIJobRun = "ai_job_run" | |||||
| NodeTypeBinding = "binding" | |||||
| NodeTypeUpload = "upload" | |||||
| NodeTypeDataReturn = "data_return" | |||||
| NodeTypeHPCCreate = "hpc_create" | |||||
| NodeTypeInference = "inference" | |||||
| NodeTypeInferenceStop = "inference_stop" | |||||
| NodeTypeAICreate = "ai_job_create" | |||||
| NodeTypeAIJobRun = "ai_job_run" | |||||
| NodeTypeNotify = "notify" | |||||
| ) | ) | ||||
| type TaskID int64 | type TaskID int64 | ||||
| @@ -27,8 +27,8 @@ const ( | |||||
| GPUUtilization = "GPUUtilization" | GPUUtilization = "GPUUtilization" | ||||
| CPUUtilization = "CPUUtilization" | CPUUtilization = "CPUUtilization" | ||||
| MethodPost = "POST" | |||||
| MethodGet = "GET" | |||||
| MethodPost = "post" | |||||
| MethodGet = "get" | |||||
| CodeSuccess = 200 | CodeSuccess = 200 | ||||
| ) | ) | ||||
| @@ -682,6 +682,8 @@ var JobOutputTypeUnion = types.NewTypeUnion[JobOutput]( | |||||
| (*AIJobOutput)(nil), | (*AIJobOutput)(nil), | ||||
| (*BindingJobOutput)(nil), | (*BindingJobOutput)(nil), | ||||
| (*UploadJobOutput)(nil), | (*UploadJobOutput)(nil), | ||||
| (*HPCJobOutput)(nil), | |||||
| (*NotifyJobOutput)(nil), | |||||
| ) | ) | ||||
| var _ = serder.UseTypeUnionInternallyTagged(&JobOutputTypeUnion, "type") | var _ = serder.UseTypeUnionInternallyTagged(&JobOutputTypeUnion, "type") | ||||
| @@ -693,10 +695,18 @@ func (d *JobOutputBase) Output2() {} | |||||
| type PublicOutput struct { | type PublicOutput struct { | ||||
| serder.Metadata `union:"object"` | serder.Metadata `union:"object"` | ||||
| JobOutputBase | JobOutputBase | ||||
| Type string `json:"type"` | |||||
| Type string `json:"type"` | |||||
| Output string `json:"output"` | |||||
| } | |||||
| type NotifyJobOutput struct { | |||||
| serder.Metadata `union:"Notify"` | |||||
| JobOutputBase | |||||
| Type string `json:"type"` | |||||
| Output string `json:"output"` | |||||
| } | } | ||||
| type HPCOutput struct { | |||||
| type HPCJobOutput struct { | |||||
| serder.Metadata `union:"HPCSlurm"` | serder.Metadata `union:"HPCSlurm"` | ||||
| JobOutputBase | JobOutputBase | ||||
| Type string `json:"type"` | Type string `json:"type"` | ||||
| @@ -7,7 +7,7 @@ import ( | |||||
| ) | ) | ||||
| type response[T any] struct { | type response[T any] struct { | ||||
| Code int `json:"code"` | |||||
| Code string `json:"code"` | |||||
| Message string `json:"message"` | Message string `json:"message"` | ||||
| Data T `json:"data"` | Data T `json:"data"` | ||||
| } | } | ||||
| @@ -1,13 +1,8 @@ | |||||
| package uploadersdk | package uploadersdk | ||||
| import ( | import ( | ||||
| "fmt" | |||||
| "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/serder" | |||||
| "mime/multipart" | "mime/multipart" | ||||
| "net/url" | |||||
| "strings" | |||||
| ) | ) | ||||
| type ObjectUploadReq struct { | type ObjectUploadReq struct { | ||||
| @@ -15,32 +10,32 @@ type ObjectUploadReq struct { | |||||
| Files []*multipart.FileHeader `form:"files"` | Files []*multipart.FileHeader `form:"files"` | ||||
| } | } | ||||
| func (c *Client) Upload(req ObjectUploadReq) (*cdsapi.ObjectUploadResp, error) { | |||||
| targetUrl, err := url.JoinPath(c.baseURL, "/object/upload") | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| resp, err := http2.PostJSON(targetUrl, http2.RequestParam{ | |||||
| Body: req, | |||||
| }) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| contType := resp.Header.Get("Content-Type") | |||||
| if strings.Contains(contType, http2.ContentTypeJSON) { | |||||
| var codeResp response[cdsapi.ObjectUploadResp] | |||||
| 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, codeResp.ToError() | |||||
| } | |||||
| return nil, fmt.Errorf("unknow response content type: %s", contType) | |||||
| } | |||||
| //func (c *Client) Upload(req ObjectUploadReq) (*cdsapi.ObjectUploadResp, error) { | |||||
| // targetUrl, err := url.JoinPath(c.baseURL, "/object/upload") | |||||
| // if err != nil { | |||||
| // return nil, err | |||||
| // } | |||||
| // | |||||
| // resp, err := http2.PostJSON(targetUrl, http2.RequestParam{ | |||||
| // Body: req, | |||||
| // }) | |||||
| // if err != nil { | |||||
| // return nil, err | |||||
| // } | |||||
| // | |||||
| // contType := resp.Header.Get("Content-Type") | |||||
| // if strings.Contains(contType, http2.ContentTypeJSON) { | |||||
| // var codeResp response[cdsapi.ObjectUploadResp] | |||||
| // if err := serder.JSONToObjectStream(resp.Body, &codeResp); err != nil { | |||||
| // return nil, fmt.Errorf("parsing response: %w", err) | |||||
| // } | |||||
| // | |||||
| // if codeResp.Code == errorcode.OK { | |||||
| // return &codeResp.Data, nil | |||||
| // } | |||||
| // | |||||
| // return nil, codeResp.ToError() | |||||
| // } | |||||
| // | |||||
| // return nil, fmt.Errorf("unknow response content type: %s", contType) | |||||
| //} | |||||