diff --git a/sdks/pcmscheduler/jobset.go b/sdks/pcmscheduler/jobset.go index be1e3ae..0d9ea55 100644 --- a/sdks/pcmscheduler/jobset.go +++ b/sdks/pcmscheduler/jobset.go @@ -57,6 +57,10 @@ func (c *Client) GetClusterInfo(req GetClusterInfoReq) ([]ClusterDetail, error) return nil, fmt.Errorf("unknow response content type: %s", contType) } +type CreateInferenceJobResp struct { + TaskId string `json:"taskId"` +} + type CreateJobReq struct { Name string `json:"name"` Description string `json:"description"` @@ -121,8 +125,42 @@ type ScheduleData struct { ClusterIDs []schsdk.ClusterID `json:"clusterIDs"` } +func (c *Client) CreateInferenceJob(req CreateJobReq, token string) (*CreateInferenceJobResp, error) { + targetUrl, err := url.JoinPath(c.baseURL, "inference/createTask") + if err != nil { + return nil, err + } + + resp, err := http2.PostJSON(targetUrl, http2.RequestParam{ + Body: req, + 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[CreateInferenceJobResp] + 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) + +} + func (c *Client) CreateJob(req CreateJobReq, token string) (*CreateJobResp, error) { - targetUrl, err := url.JoinPath(c.baseURL, "/createTask") + targetUrl, err := url.JoinPath(c.baseURL, "schedule/createTask") if err != nil { return nil, err } @@ -181,7 +219,7 @@ type DataScheduleResults struct { } func (c *Client) RunJob(req RunJobReq, token string) error { - targetUrl, err := url.JoinPath(c.baseURL, "runTask") + targetUrl, err := url.JoinPath(c.baseURL, "schedule/runTask") if err != nil { return err } @@ -220,7 +258,7 @@ type CancelJobReq struct { } func (c *Client) CancelJob(req CancelJobReq) error { - targetUrl, err := url.JoinPath(c.baseURL, "/queryResources") + targetUrl, err := url.JoinPath(c.baseURL, "schedule/queryResources") if err != nil { return err } diff --git a/sdks/pcmscheduler/models.go b/sdks/pcmscheduler/models.go index 2eb6f3f..d8642cf 100644 --- a/sdks/pcmscheduler/models.go +++ b/sdks/pcmscheduler/models.go @@ -63,8 +63,9 @@ const ( PlatformOpenI = "OpenI" PlatformModelArts = "ModelArts" - PlatformPCM = "PCM" - PlatformHPC = "HPC" + PlatformPCM = "PCM" + PlatformPCMInference = "PCM_Inference" + PlatformHPC = "HPC" URL = "url" ID = "id" diff --git a/sdks/scheduler/models.go b/sdks/scheduler/models.go index 3faf9e2..e676645 100644 --- a/sdks/scheduler/models.go +++ b/sdks/scheduler/models.go @@ -65,6 +65,7 @@ var JobInfoTypeUnion = types.NewTypeUnion[JobInfo]( (*PCMJobInfo)(nil), (*HPCJobInfo)(nil), (*BindingJobInfo)(nil), + (*PCMInferenceJobInfo)(nil), ) var _ = serder.UseTypeUnionInternallyTagged(&JobInfoTypeUnion, "type") @@ -105,6 +106,16 @@ type NormalJobInfo struct { ModelJobInfo ModelJobInfo `json:"modelJobInfo"` } +type PCMInferenceJobInfo struct { + serder.Metadata `union:"PCM_Inference"` + JobInfoBase + Type string `json:"type"` + Name string `json:"name"` + Description string `json:"description"` + Files JobFilesInfo `json:"files"` + JobResources JobResources `json:"jobResources"` +} + type PCMJobInfo struct { serder.Metadata `union:"PCM"` JobInfoBase