From 7e10b2654b43414f350a3a24b3a6adb99ba3de07 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 22 Jun 2022 17:20:15 +0800 Subject: [PATCH] debug --- models/cloudbrain.go | 3 ++- modules/grampus/grampus.go | 11 +++++++---- modules/grampus/resty.go | 1 + routers/repo/grampus.go | 8 ++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 68e320ccf..4c7bf76a2 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -107,6 +107,7 @@ const ( GrampusStatusSucceeded = "SUCCEEDED" GrampusStatusStopped = "STOPPED" GrampusStatusUnknown = "UNKNOWN" + GrampusStatusWaiting = "WAITING" ) type Cloudbrain struct { @@ -1734,7 +1735,7 @@ func GetCloudbrainInferenceJobCountByUserID(userID int64) (int, error) { } func GetGrampusCountByUserID(userID int64, jobType, computeResource string) (int, error) { - count, err := x.In("status", GrampusStatusPending, GrampusStatusRunning).And("job_type = ? and user_id = ? and type = ?", jobType, userID, TypeC2Net).And("compute_resource = ?", computeResource).Count(new(Cloudbrain)) + count, err := x.In("status", GrampusStatusWaiting, GrampusStatusRunning).And("job_type = ? and user_id = ? and type = ?", jobType, userID, TypeC2Net).And("compute_resource = ?", computeResource).Count(new(Cloudbrain)) return int(count), err } diff --git a/modules/grampus/grampus.go b/modules/grampus/grampus.go index 11749a741..7e5ad7a28 100755 --- a/modules/grampus/grampus.go +++ b/modules/grampus/grampus.go @@ -15,7 +15,7 @@ const ( ProcessorTypeNPU = "npu.huawei.com/NPU" ProcessorTypeGPU = "nvidia.com/gpu" - CommandPrepareScript = "pwd;cd /tmp;mkdir -p output;mkdir -p code;mkdir -p dataset;wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" + + CommandPrepareScript = "pwd;cd /cache;mkdir -p output;mkdir -p code;mkdir -p dataset;wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" + "unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_obs downloader_for_minio uploader_for_minio;" //CommandPrepareScript = "bash;pwd;apt-get -y update;apt-get -y upgrade;apt-get -y install wget;apt-get -y install unzip;" + @@ -72,7 +72,9 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error ResourceSpecId: req.ResourceSpecId, ImageId: req.ImageId, ImageUrl: req.ImageUrl, - ReplicaNum: 0, + ReplicaNum: 1, + CenterName: []string{"成都智算"}, + CenterID: []string{"chengdu"}, }, }, }) @@ -111,6 +113,7 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error TotalVersionCount: req.TotalVersionCount, CreatedUnix: createTime, UpdatedUnix: createTime, + AiCenter: jobResult.JobInfo.Tasks[0].CenterID[0] + "+" + jobResult.JobInfo.Tasks[0].CenterName[0], }) if err != nil { @@ -130,8 +133,8 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error } func TransTrainJobStatus(status string) string { - if status == "pending" { - status = "waiting" + if status == models.GrampusStatusPending { + status = models.GrampusStatusWaiting } return strings.ToUpper(status) diff --git a/modules/grampus/resty.go b/modules/grampus/resty.go index 5e8722b4b..e743ec6d4 100755 --- a/modules/grampus/resty.go +++ b/modules/grampus/resty.go @@ -81,6 +81,7 @@ func getToken() error { } TOKEN = result.Token + log.Info(TOKEN) return nil } diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index 35e2c5feb..d6eaaa9ed 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -615,7 +615,7 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo if strings.HasSuffix(datasetName, ".tar.gz") { toolUnzip = "tar -zxvf " } - commandUnzip := "cd /tmp/dataset;" + toolUnzip + datasetName + ";cd /tmp/code;unzip -q master.zip;" + commandUnzip := "cd /cache/dataset;" + toolUnzip + datasetName + ";cd /cache/code;unzip -q master.zip;" command += commandUnzip //exec code @@ -638,7 +638,7 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo } } - commandCode := "cd /tmp/code/" + strings.ToLower(repoName) + ";python " + bootFile + paramCode + ";" + commandCode := "cd /cache/code/" + strings.ToLower(repoName) + ";python " + bootFile + paramCode + ";" command += commandCode //get exec result @@ -647,10 +647,10 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo //upload models if processorType == grampus.ProcessorTypeNPU { - commandUpload := "cd /tmp/script_for_grampus/;./uploader_for_obs " + setting.Bucket + " " + outputRemotePath + " " + "/tmp/output/;" + commandUpload := "cd /cache/script_for_grampus/;./uploader_for_obs " + setting.Bucket + " " + outputRemotePath + " " + "/tmp/output/;" command += commandUpload } else if processorType == grampus.ProcessorTypeGPU { - commandUpload := "cd /tmp/script_for_grampus/;./uploader_for_minio " + setting.Grampus.Env + " " + outputRemotePath + " " + "/tmp/output/;" + commandUpload := "cd /cache/script_for_grampus/;./uploader_for_minio " + setting.Grampus.Env + " " + outputRemotePath + " " + "/tmp/output/;" command += commandUpload }