From 88f5812984537bd47d16e502e8ad289aae96fb54 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Fri, 19 Aug 2022 09:20:02 +0800 Subject: [PATCH] debug --- modules/grampus/grampus.go | 4 +--- routers/repo/grampus.go | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/modules/grampus/grampus.go b/modules/grampus/grampus.go index caaae4e8e..0d84d7aa7 100755 --- a/modules/grampus/grampus.go +++ b/modules/grampus/grampus.go @@ -23,9 +23,7 @@ const ( NpuWorkDir = "/cache/" CommandPrepareScript = ";mkdir -p output;mkdir -p code;mkdir -p dataset;echo \"start loading script\";wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" + - "echo \"finish loading script\";unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_obs downloader_for_minio uploader_for_minio;" - //CommandPrepareScript = "pwd;cd /cache;mkdir -p output;mkdir -p code;mkdir -p dataset;echo \"start loading script\";wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" + - // "echo \"finish loading script\";unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_obs downloader_for_minio uploader_for_minio;" + "echo \"finish loading script\";unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_npu downloader_for_minio uploader_for_gpu;" CodeArchiveName = "master.zip" ) diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index cdde7596c..abc2027d3 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -767,10 +767,6 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo command += commandDownload } - //check download result - commandCheckRes := "bash -c \"[[ $? -eq 0 ]] && exit 0 || exit -1;\";" - command += commandCheckRes - //unzip code & dataset toolUnzip := "unzip -q '" if strings.HasSuffix(datasetName, ".tar.gz") { @@ -779,16 +775,22 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo commandUnzip := "cd " + workDir + "code;unzip -q master.zip;echo \"start to unzip dataset\";cd " + workDir + "dataset;" + toolUnzip + datasetName + "';" command += commandUnzip - //check unzip result - commandCheckRes = "bash -c \"[[ $? -eq 0 ]] && exit 0 || exit -1;\";" - command += commandCheckRes - command += "echo \"unzip finished;start to exec code;\";" + // set export + var commandExport string + if processorType == grampus.ProcessorTypeNPU { + commandExport = "export bucket=" + setting.Bucket + " && export remote_path=" + outputRemotePath + ";" + } else if processorType == grampus.ProcessorTypeGPU { + commandExport = "export env=" + setting.Grampus.Env + " && export remote_path=" + outputRemotePath + ";" + } + + command += commandExport + //exec code var parameters models.Parameters var paramCode string - param := make([]models.Parameter, 0) + if len(paramSrc) != 0 { err := json.Unmarshal([]byte(paramSrc), ¶meters) if err != nil { @@ -797,10 +799,6 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo } for _, parameter := range parameters.Parameter { - param = append(param, models.Parameter{ - Label: parameter.Label, - Value: parameter.Value, - }) paramCode += " --" + parameter.Label + "=" + parameter.Value } } @@ -820,15 +818,15 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo //upload models if processorType == grampus.ProcessorTypeNPU { - commandUpload := "cd " + workDir + "script_for_grampus/;./uploader_for_obs " + setting.Bucket + " " + outputRemotePath + " " + workDir + "output/;" + commandUpload := "cd " + workDir + "script_for_grampus/;./uploader_for_npu " + setting.Bucket + " " + outputRemotePath + " " + workDir + "output/;" command += commandUpload } else if processorType == grampus.ProcessorTypeGPU { - commandUpload := "cd " + workDir + "script_for_grampus/;./uploader_for_minio " + setting.Grampus.Env + " " + outputRemotePath + " " + workDir + "output/;" + commandUpload := "cd " + workDir + "script_for_grampus/;./uploader_for_gpu " + setting.Grampus.Env + " " + outputRemotePath + " " + workDir + "output/;" command += commandUpload } //check exec result - commandCheckRes = "bash -c \"[[ $result -eq 0 ]] && exit 0 || exit -1\"" + commandCheckRes := "bash -c \"[[ $result -eq 0 ]] && exit 0 || exit -1\"" command += commandCheckRes return command, nil