diff --git a/sdks/pcmscheduler/jobset.go b/sdks/pcmscheduler/jobset.go index 4f8072f..d2affe8 100644 --- a/sdks/pcmscheduler/jobset.go +++ b/sdks/pcmscheduler/jobset.go @@ -163,11 +163,14 @@ func (c *Client) CreateInferenceJob(req CreateAIJobReq, token string) (*CreateIn } 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 { - targetUrl, err := url.JoinPath(c.baseURL, "inference/createTask") + targetUrl, err := url.JoinPath(c.baseURL, "inference/stopDeployInstance") if err != nil { return err } diff --git a/sdks/pcmscheduler/models.go b/sdks/pcmscheduler/models.go index 6f8707f..34c0c3e 100644 --- a/sdks/pcmscheduler/models.go +++ b/sdks/pcmscheduler/models.go @@ -86,13 +86,15 @@ const ( 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 diff --git a/sdks/scheduler/models.go b/sdks/scheduler/models.go index 8262d75..adfcd42 100644 --- a/sdks/scheduler/models.go +++ b/sdks/scheduler/models.go @@ -27,8 +27,8 @@ const ( GPUUtilization = "GPUUtilization" CPUUtilization = "CPUUtilization" - MethodPost = "POST" - MethodGet = "GET" + MethodPost = "post" + MethodGet = "get" CodeSuccess = 200 ) @@ -682,6 +682,8 @@ var JobOutputTypeUnion = types.NewTypeUnion[JobOutput]( (*AIJobOutput)(nil), (*BindingJobOutput)(nil), (*UploadJobOutput)(nil), + (*HPCJobOutput)(nil), + (*NotifyJobOutput)(nil), ) var _ = serder.UseTypeUnionInternallyTagged(&JobOutputTypeUnion, "type") @@ -693,10 +695,18 @@ func (d *JobOutputBase) Output2() {} type PublicOutput struct { serder.Metadata `union:"object"` 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"` JobOutputBase Type string `json:"type"` diff --git a/sdks/uploader/client.go b/sdks/uploader/client.go index 7b1f385..44533eb 100644 --- a/sdks/uploader/client.go +++ b/sdks/uploader/client.go @@ -7,7 +7,7 @@ import ( ) type response[T any] struct { - Code int `json:"code"` + Code string `json:"code"` Message string `json:"message"` Data T `json:"data"` } diff --git a/sdks/uploader/uploader.go b/sdks/uploader/uploader.go index 6cae186..479ab11 100644 --- a/sdks/uploader/uploader.go +++ b/sdks/uploader/uploader.go @@ -1,13 +1,8 @@ package uploadersdk import ( - "fmt" "gitlink.org.cn/cloudream/common/sdks/storage/cdsapi" - "gitlink.org.cn/cloudream/common/utils/http2" - "gitlink.org.cn/cloudream/common/utils/serder" "mime/multipart" - "net/url" - "strings" ) type ObjectUploadReq struct { @@ -15,32 +10,32 @@ type ObjectUploadReq struct { 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) +//}