Browse Source

Merge pull request 'updated openi stopinstance' (#477) from tzwang/pcm-coordinator:master into master

pull/478/head
tzwang 6 months ago
parent
commit
004c1dc7b9
2 changed files with 44 additions and 24 deletions
  1. +16
    -0
      internal/scheduler/service/utils/status/deployInstance.go
  2. +28
    -24
      internal/storeLink/openi.go

+ 16
- 0
internal/scheduler/service/utils/status/deployInstance.go View File

@@ -287,6 +287,13 @@ func CheckStopStatus(in *inference.DeployInstance) bool {
default:
return false
}
case storeLink.TYPE_OPENI:
switch in.Status {
case "STOPPED":
return true
default:
return false
}
default:
return false
}
@@ -315,6 +322,15 @@ func CheckRunningStatus(in *inference.DeployInstance) bool {
default:
return false
}
case storeLink.TYPE_OPENI:
switch in.Status {
case "RUNNING":
return true
case "WAITING":
return true
default:
return false
}
default:
return false
}


+ 28
- 24
internal/storeLink/openi.go View File

@@ -76,7 +76,7 @@ func NewOpenI(host string, id int64, name string, token string, platform string)
}
}

func (o OpenI) Execute(ctx context.Context, option *option.AiOption, mode int) (interface{}, error) {
func (o *OpenI) Execute(ctx context.Context, option *option.AiOption, mode int) (interface{}, error) {
switch mode {
case executor.SUBMIT_MODE_JOINT_CLOUD:

@@ -285,7 +285,7 @@ func (o *OpenI) SubmitTask(ctx context.Context, imageId string, cmd string, envs
}

if (resp.Data == model.CreateTask{}) {
return nil, errors.New("failed to submit task")
return nil, errors.New("failed to submit task, empty response")
}

return resp.Data, nil
@@ -314,7 +314,7 @@ func swapImageIdAndImageUrl(imageId string) (string, string, error) {
return imgId, imgUrl, nil
}

func (o OpenI) Stop(ctx context.Context, id string) error {
func (o *OpenI) Stop(ctx context.Context, id string) error {
task, err := o.getTrainingTask(ctx, id)
if err != nil {
return err
@@ -360,23 +360,27 @@ func (o OpenI) Stop(ctx context.Context, id string) error {
return nil
}

func (o OpenI) GetClusterInferUrl(ctx context.Context, option *option.InferOption) (*inference.ClusterInferUrl, error) {
func (o *OpenI) GetClusterInferUrl(ctx context.Context, option *option.InferOption) (*inference.ClusterInferUrl, error) {
return nil, errors.New("failed to implement")
}

func (o OpenI) GetInferDeployInstanceList(ctx context.Context) ([]*inference.DeployInstance, error) {
func (o *OpenI) GetInferDeployInstanceList(ctx context.Context) ([]*inference.DeployInstance, error) {
return nil, errors.New("failed to implement")
}

func (o OpenI) StartInferDeployInstance(ctx context.Context, id string) bool {
func (o *OpenI) StartInferDeployInstance(ctx context.Context, id string) bool {
return false
}

func (o OpenI) StopInferDeployInstance(ctx context.Context, id string) bool {
return false
func (o *OpenI) StopInferDeployInstance(ctx context.Context, id string) bool {
err := o.Stop(ctx, id)
if err != nil {
return false
}
return true
}

func (o OpenI) GetInferDeployInstance(ctx context.Context, id string) (*inference.DeployInstance, error) {
func (o *OpenI) GetInferDeployInstance(ctx context.Context, id string) (*inference.DeployInstance, error) {
task, err := o.getTrainingTask(ctx, id)
if err != nil {
return nil, err
@@ -412,7 +416,7 @@ func (o OpenI) GetInferDeployInstance(ctx context.Context, id string) (*inferenc
return &resp, nil
}

func (o OpenI) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
func (o *OpenI) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
var repoName string

codePaths := strings.Split(option.AlgorithmId, FORWARD_SLASH)
@@ -600,27 +604,27 @@ func (o *OpenI) SubmitInferTask(ctx context.Context, imageId string, cmd string,
return resp.Data, nil
}

func (o OpenI) CheckModelExistence(ctx context.Context, modelName string, modelType string) bool {
func (o *OpenI) CheckModelExistence(ctx context.Context, modelName string, modelType string) bool {
return false
}

func (o OpenI) GetImageInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error) {
func (o *OpenI) GetImageInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error) {
return "", errors.New("failed to implement")
}

func (o OpenI) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) {
func (o *OpenI) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) {
return nil, errors.New("failed to implement")
}

func (o OpenI) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) {
func (o *OpenI) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) {
return nil, errors.New("failed to implement")
}

func (o OpenI) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) {
func (o *OpenI) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) {
return nil, errors.New("failed to implement")
}

func (o OpenI) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
func (o *OpenI) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
task, err := o.getTrainingTask(ctx, taskId)
if err != nil {
return "", err
@@ -672,7 +676,7 @@ func (o OpenI) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNu
return resp.Data, nil
}

func (o OpenI) getTrainingTask(ctx context.Context, taskId string) (*model.TaskDetail, error) {
func (o *OpenI) getTrainingTask(ctx context.Context, taskId string) (*model.TaskDetail, error) {
taskDetailsUrl := o.host + TaskDetailsUrl

param := model.TaskDetailParam{
@@ -713,7 +717,7 @@ func (o OpenI) getTrainingTask(ctx context.Context, taskId string) (*model.TaskD
return &resp.Data, nil
}

func (o OpenI) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) {
func (o *OpenI) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) {
task, err := o.getTrainingTask(ctx, taskId)
if err != nil {
return nil, err
@@ -750,23 +754,23 @@ func (o OpenI) GetTrainingTask(ctx context.Context, taskId string) (*collector.T
return &resp, nil
}

func (o OpenI) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) {
func (o *OpenI) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) {
return "", errors.New("failed to implement")
}

func (o OpenI) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error {
func (o *OpenI) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error {
return errors.New("failed to implement")
}

func (o OpenI) GetComputeCards(ctx context.Context) ([]string, error) {
func (o *OpenI) GetComputeCards(ctx context.Context) ([]string, error) {
return nil, errors.New("failed to implement")
}

func (o OpenI) GetUserBalance(ctx context.Context) (float64, error) {
func (o *OpenI) GetUserBalance(ctx context.Context) (float64, error) {
return 0, errors.New("failed to implement")
}

func (o OpenI) GetResourceSpecs(ctx context.Context) (*collector.ResourceSpec, error) {
func (o *OpenI) GetResourceSpecs(ctx context.Context) (*collector.ResourceSpec, error) {
var resources []interface{}
res := &collector.ResourceSpec{
ClusterId: strconv.FormatInt(o.participantId, 10),
@@ -1064,7 +1068,7 @@ func (o OpenI) GetResourceSpecs(ctx context.Context) (*collector.ResourceSpec, e
return res, nil
}

func (o OpenI) getOnlineInferUrl(ctx context.Context, taskId string, repoName string) (string, error) {
func (o *OpenI) getOnlineInferUrl(ctx context.Context, taskId string, repoName string) (string, error) {
taskDetailsUrl := o.host + TaskOnlineInferUrl

param := model.TaskDetailParam{


Loading…
Cancel
Save