| @@ -53,7 +53,7 @@ type Cloudbrain struct { | |||
| JobID string `xorm:"INDEX NOT NULL"` | |||
| JobType string `xorm:"INDEX NOT NULL DEFAULT 'DEBUG'"` | |||
| JobName string `xorm:"INDEX"` | |||
| Status string `xorm:"INDEX DEFAULT 'INIT'"` | |||
| Status string `xorm:"INDEX"` | |||
| UserID int64 `xorm:"INDEX"` | |||
| RepoID int64 `xorm:"INDEX"` | |||
| SubTaskName string `xorm:"INDEX"` | |||
| @@ -1124,7 +1124,7 @@ func UpdateJob(job *Cloudbrain) error { | |||
| func updateJob(e Engine, job *Cloudbrain) error { | |||
| var sess *xorm.Session | |||
| sess = e.Where("job_id = ?", job.JobID) | |||
| sess = e.Where("job_id = ? AND version_name=?", job.JobID, job.VersionName) | |||
| _, err := sess.Cols("status", "train_job_duration", "container_id", "container_ip").Update(job) | |||
| return err | |||
| } | |||
| @@ -294,62 +294,6 @@ func GetObsListObjectVersion(jobName, parentDir string, VersionOutputPath string | |||
| } | |||
| } | |||
| func GetVersionObsListObject(jobName, parentDir string) ([]FileInfo, error) { | |||
| input := &obs.ListObjectsInput{} | |||
| input.Bucket = setting.Bucket | |||
| input.Prefix = strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir), "/") | |||
| strPrefix := strings.Split(input.Prefix, "/") | |||
| output, err := ObsCli.ListObjects(input) | |||
| fileInfos := make([]FileInfo, 0) | |||
| if err == nil { | |||
| for _, val := range output.Contents { | |||
| str1 := strings.Split(val.Key, "/") | |||
| var isDir bool | |||
| var fileName, nextParentDir string | |||
| if strings.HasSuffix(val.Key, "/") { | |||
| //dirs in next level dir | |||
| if len(str1)-len(strPrefix) > 2 { | |||
| continue | |||
| } | |||
| fileName = str1[len(str1)-2] | |||
| isDir = true | |||
| if parentDir == "" { | |||
| nextParentDir = fileName | |||
| } else { | |||
| nextParentDir = parentDir + "/" + fileName | |||
| } | |||
| if fileName == strPrefix[len(strPrefix)-1] || (fileName+"/") == setting.OutPutPath { | |||
| continue | |||
| } | |||
| } else { | |||
| //files in next level dir | |||
| if len(str1)-len(strPrefix) > 1 { | |||
| continue | |||
| } | |||
| fileName = str1[len(str1)-1] | |||
| isDir = false | |||
| nextParentDir = parentDir | |||
| } | |||
| fileInfo := FileInfo{ | |||
| ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"), | |||
| FileName: fileName, | |||
| Size: val.Size, | |||
| IsDir: isDir, | |||
| ParenDir: nextParentDir, | |||
| } | |||
| fileInfos = append(fileInfos, fileInfo) | |||
| } | |||
| return fileInfos, err | |||
| } else { | |||
| if obsError, ok := err.(obs.ObsError); ok { | |||
| log.Error("Code:%s, Message:%s", obsError.Code, obsError.Message) | |||
| } | |||
| return nil, err | |||
| } | |||
| } | |||
| func ObsGenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, fileName string) (string, error) { | |||
| input := &obs.CreateSignedUrlInput{} | |||
| @@ -874,17 +874,12 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }) | |||
| m.Group("/train-job", func() { | |||
| m.Group("/:jobid", func() { | |||
| // m.Get("", repo.GetModelArtsTrainJob) | |||
| m.Get("", repo.GetModelArtsTrainJobVersion) | |||
| // m.Get("/log", repo.TrainJobGetLog) | |||
| m.Get("/log", repo.TrainJobGetLog) | |||
| m.Post("/del_version", repo.DelTrainJobVersion) | |||
| m.Post("/stop_version", repo.StopTrainJobVersion) | |||
| m.Get("/model_list", repo.ModelList) | |||
| m.Get("/model_download", repo.ModelDownload) | |||
| // m.Group("/:version-name", func() { | |||
| // m.Get("", repo.GetModelArtsTrainJobVersion) | |||
| // }) | |||
| }) | |||
| }) | |||
| }, reqRepoReader(models.UnitTypeCloudBrain)) | |||
| @@ -997,19 +997,35 @@ func TrainJobShow(ctx *context.Context) { | |||
| JobType: string(models.JobTypeTrain), | |||
| JobID: jobID, | |||
| }) | |||
| if err != nil { | |||
| ctx.ServerError("Cloudbrain", err) | |||
| return | |||
| } | |||
| if err != nil { | |||
| log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) | |||
| log.Error("GetVersionListTasks(%s) failed:%v", jobID, err.Error()) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
| return | |||
| } | |||
| //将运行参数转化为epoch_size = 3, device_target = Ascend的格式 | |||
| for i, _ := range VersionListTasks { | |||
| var parameters models.Parameters | |||
| err := json.Unmarshal([]byte(VersionListTasks[i].Parameters), ¶meters) | |||
| if err != nil { | |||
| log.Error("Failed to Unmarshal Parameters: %s (%v)", VersionListTasks[i].Parameters, err) | |||
| trainJobNewDataPrepare(ctx) | |||
| return | |||
| } | |||
| if len(parameters.Parameter) > 0 { | |||
| paramTemp := "" | |||
| for _, Parameter := range parameters.Parameter { | |||
| param := Parameter.Label + " = " + Parameter.Value + ", " | |||
| paramTemp = paramTemp + param | |||
| } | |||
| VersionListTasks[i].Parameters = paramTemp[:len(paramTemp)-2] | |||
| } | |||
| } | |||
| ctx.Data["jobID"] = jobID | |||
| // ctx.Data["result"] = result | |||
| ctx.Data["version_list_task"] = VersionListTasks | |||
| ctx.Data["version_list_count"] = VersionListCount | |||
| ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) | |||
| @@ -989,21 +989,14 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| m.Get("", reqRepoCloudBrainReader, repo.TrainJobShow) | |||
| m.Post("/stop", reqRepoCloudBrainWriter, repo.TrainJobStop) | |||
| m.Post("/del", reqRepoCloudBrainWriter, repo.TrainJobDel) | |||
| // m.Get("/log", reqRepoCloudBrainReader, repo.TrainJobGetLog) | |||
| // m.Get("/models", reqRepoCloudBrainReader, repo.TrainJobShowModels) | |||
| m.Get("/models", reqRepoCloudBrainReader, repo.TrainJobVersionShowModels) | |||
| // m.Get("/download_model", reqRepoCloudBrainReader, repo.TrainJobDownloadModel) | |||
| m.Get("/download_model", reqRepoCloudBrainReader, repo.TrainJobVersionDownloadModel) | |||
| m.Get("/create_version", reqRepoCloudBrainReader, repo.TrainJobNewVersion) | |||
| m.Post("/create_version", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreateVersion) | |||
| // }) | |||
| }) | |||
| m.Get("/create", reqRepoCloudBrainReader, repo.TrainJobNew) | |||
| m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreate) | |||
| // m.Get("/create", reqRepoCloudBrainReader, repo.TrainJobNewVersion) | |||
| // m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreateVersion) | |||
| m.Get("/para-config-list", reqRepoCloudBrainReader, repo.TrainJobGetConfigList) | |||
| }) | |||
| }, context.RepoRef()) | |||
| @@ -253,7 +253,7 @@ td, th { | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w"> | |||
| 空白 | |||
| <span style="font-size: 12px;" class="">{{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}</span> | |||
| </div> | |||
| </td> | |||
| </tr> | |||