From 8d8d762d08247c3c0393cddc26d66dca3493825b Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 1 Jul 2022 12:05:05 +0800 Subject: [PATCH 1/6] fix issue --- templates/repo/cloudbrain/trainjob/new.tmpl | 6 +++++- templates/repo/grampus/trainjob/gpu/new.tmpl | 3 ++- templates/repo/grampus/trainjob/npu/new.tmpl | 3 ++- templates/repo/modelarts/trainjob/new.tmpl | 6 +++++- web_src/js/components/dataset/selectDataset.vue | 3 ++- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/templates/repo/cloudbrain/trainjob/new.tmpl b/templates/repo/cloudbrain/trainjob/new.tmpl index 0b7fc8d30..75c123b5e 100755 --- a/templates/repo/cloudbrain/trainjob/new.tmpl +++ b/templates/repo/cloudbrain/trainjob/new.tmpl @@ -280,7 +280,11 @@ $('.menu .item') .tab(); - + $(document).keydown(function(event){ + switch(event.keyCode){ + case 13:return false; + } + }); let sever_num = $('#trainjob_work_server_num') $('.add').click(function () { sever_num.val(parseInt(sever_num.val()) + 1) diff --git a/templates/repo/grampus/trainjob/gpu/new.tmpl b/templates/repo/grampus/trainjob/gpu/new.tmpl index 7c272ce82..5379c7b76 100755 --- a/templates/repo/grampus/trainjob/gpu/new.tmpl +++ b/templates/repo/grampus/trainjob/gpu/new.tmpl @@ -24,7 +24,8 @@ } .width85{ width: 85% !important; - margin-left: 4.5rem !important; + margin-left: 10.5rem !important; + align-items: center; } .width81{ width: 81% !important; diff --git a/templates/repo/grampus/trainjob/npu/new.tmpl b/templates/repo/grampus/trainjob/npu/new.tmpl index f983fbfe9..c97463283 100755 --- a/templates/repo/grampus/trainjob/npu/new.tmpl +++ b/templates/repo/grampus/trainjob/npu/new.tmpl @@ -19,7 +19,8 @@ } .width85{ width: 85% !important; - margin-left: 4.5rem !important; + margin-left: 10.5rem !important; + align-items: center; } .width81{ width: 81% !important; diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 1d1583e2d..5022bd41b 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -294,7 +294,11 @@ $('.menu .item') .tab(); - + $(document).keydown(function(event){ + switch(event.keyCode){ + case 13:return false; + } + }); // let sever_num = $("#trainjob_work_server_num_select .text").text() //$('#trainjob_work_server_num') // console.log("sever_num:",sever_num) // $('.add').click(function(){ diff --git a/web_src/js/components/dataset/selectDataset.vue b/web_src/js/components/dataset/selectDataset.vue index a03f90775..fb377e5fd 100755 --- a/web_src/js/components/dataset/selectDataset.vue +++ b/web_src/js/components/dataset/selectDataset.vue @@ -76,7 +76,7 @@ type="text" placeholder="搜数据集名称/描述..." v-model="search" - @keyup.enter="searchName" + @keyup.enter.native="searchName" /> @@ -941,6 +941,7 @@ export default { this.paramsFavorite.page = 1; this.getMyFavoriteDataset(); } + return false; }, confirmDataset() { this.dialogVisible = false; From b9650e63965368b33308405e9c99529167695cb7 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 1 Jul 2022 14:47:19 +0800 Subject: [PATCH 2/6] fix-bug --- routers/repo/modelarts.go | 128 ++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 54 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 95fac7f9a..00c9a5c88 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -991,19 +991,6 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) FlavorName := form.FlavorName VersionCount := modelarts.VersionCount EngineName := form.EngineName - if IsDatasetUseCountExceed(uuid) { - log.Error("DatasetUseCount is Exceed:%v") - trainJobErrorNewDataPrepare(ctx, form) - ctx.RenderWithErr("DatasetUseCount is Exceed", tplModelArtsTrainJobNew, &form) - return - } - _, datasetNames, err := models.GetDatasetInfo(uuid) - if err != nil { - log.Error("GetDatasetInfo failed:%v", err, ctx.Data["MsgID"]) - trainJobErrorNewDataPrepare(ctx, form) - ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tplModelArtsTrainJobNew, &form) - return - } count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID) if err != nil { @@ -1114,7 +1101,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) Value: modelarts.Ascend, }) } - DatasUrlList, dataUrl, isMultiDataset, err := GetDatasUrlListByUUIDS(uuid) + DatasUrlList, dataUrl, datasetNames, isMultiDataset, err := GetDatasUrlListByUUIDS(uuid) if err != nil { log.Error("Failed to GetDatasUrlListByUUIDS: %v", err) trainJobErrorNewDataPrepare(ctx, form) @@ -1270,20 +1257,6 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ EngineName := form.EngineName isLatestVersion := modelarts.IsLatestVersion - if IsDatasetUseCountExceed(uuid) { - log.Error("DatasetUseCount is Exceed:%v") - versionErrorDataPrepare(ctx, form) - ctx.RenderWithErr("DatasetUseCount is Exceed", tplModelArtsTrainJobVersionNew, &form) - return - } - _, datasetNames, err := models.GetDatasetInfo(uuid) - if err != nil { - log.Error("GetDatasetInfo failed:%v", err, ctx.Data["MsgID"]) - versionErrorDataPrepare(ctx, form) - ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tplModelArtsTrainJobVersionNew, &form) - return - } - canNewJob, _ := canUserCreateTrainJobVersion(ctx, latestTask.UserID) if !canNewJob { ctx.RenderWithErr("user cann't new trainjob", tplModelArtsTrainJobVersionNew, &form) @@ -1368,7 +1341,8 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ Value: modelarts.Ascend, }) } - DatasUrlList, dataUrl, isMultiDataset, err := GetDatasUrlListByUUIDS(uuid) + + DatasUrlList, dataUrl, datasetNames, isMultiDataset, err := GetDatasUrlListByUUIDS(uuid) if err != nil { log.Error("Failed to GetDatasUrlListByUUIDS: %v", err) versionErrorDataPrepare(ctx, form) @@ -2508,37 +2482,83 @@ func TrainJobDownloadLogFile(ctx *context.Context) { ctx.Resp.Header().Set("Cache-Control", "max-age=0") http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) } -func GetDatasUrlListByUUIDS(uuidStr string) ([]models.Datasurl, string, bool, error) { +func GetDatasUrlListByUUIDS(uuidStr string) ([]models.Datasurl, string, string, bool, error) { + var isMultiDataset bool var dataUrl string - var DatasUrlList []models.Datasurl - uuidList := strings.Split(uuidStr, ";") - isMultiDataset := false - - if len(uuidList) >= 1 { - for _, uuid := range uuidList { - attach, err := models.GetAttachmentByUUID(uuid) - if err != nil { - log.Error("GetAttachmentByUUID failed: %v", err) - return nil, "", isMultiDataset, err - } - datasetName := attach.Name - index := strings.LastIndex(datasetName, ".") - if index <= 0 { - index = 0 + var datasetNames string + var datasUrlList []models.Datasurl + uuids := strings.Split(uuidStr, ";") + if len(uuids) > setting.MaxDatasetNum { + log.Error("the dataset count(%d) exceed the limit", len(uuids)) + return datasUrlList, dataUrl, datasetNames, isMultiDataset, errors.New("the dataset count exceed the limit") + } + + datasetInfos := make(map[string]models.DatasetInfo) + attachs, err := models.GetAttachmentsByUUIDs(uuids) + if err != nil { + log.Error("GetAttachmentsByUUIDs failed: %v", err) + return datasUrlList, dataUrl, datasetNames, isMultiDataset, errors.New("GetAttachmentsByUUIDs failed") + } + for i, attach := range attachs { + fileName := strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(attach.Name, ".zip"), ".tar.gz"), ".tgz") + for _, datasetInfo := range datasetInfos { + if fileName == datasetInfo.Name { + log.Error("the dataset name is same: %v", attach.Name) + return datasUrlList, dataUrl, datasetNames, isMultiDataset, errors.New("the dataset name is same") } - datasetNameHead := datasetName[:index] - datasetUrl := "s3://" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" - DatasUrlList = append(DatasUrlList, models.Datasurl{ + } + if len(attachs) <= 1 { + dataUrl = "/" + setting.Bucket + "/" + setting.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID + attach.UUID + "/" + isMultiDataset = false + } else { + dataUrl = "/" + setting.Bucket + "/" + setting.BasePath + path.Join(attachs[0].UUID[0:1], attachs[0].UUID[1:2]) + "/" + attachs[0].UUID + attachs[0].UUID + "/" + datasetUrl := "s3://" + setting.Bucket + "/" + setting.BasePath + path.Join(attach.UUID[0:1], attach.UUID[1:2]) + "/" + attach.UUID + attach.UUID + "/" + datasUrlList = append(datasUrlList, models.Datasurl{ DatasetUrl: datasetUrl, - DatasetName: datasetNameHead, + DatasetName: fileName, }) + isMultiDataset = true + } + + if i == 0 { + datasetNames = attach.Name + } else { + datasetNames += ";" + attach.Name } - firstDataset := uuidList[0] - dataUrl = "/" + setting.Bucket + "/" + setting.BasePath + path.Join(firstDataset[0:1], firstDataset[1:2]) + "/" + firstDataset + firstDataset + "/" - isMultiDataset = true - return DatasUrlList, dataUrl, isMultiDataset, nil } - return nil, "", isMultiDataset, nil + + return datasUrlList, dataUrl, datasetNames, isMultiDataset, nil + + // var dataUrl string + // var DatasUrlList []models.Datasurl + // uuidList := strings.Split(uuidStr, ";") + // isMultiDataset := false + + // if len(uuidList) >= 1 { + // for _, uuid := range uuidList { + // attach, err := models.GetAttachmentByUUID(uuid) + // if err != nil { + // log.Error("GetAttachmentByUUID failed: %v", err) + // return nil, "", isMultiDataset, err + // } + // datasetName := attach.Name + // index := strings.LastIndex(datasetName, ".") + // if index <= 0 { + // index = 0 + // } + // datasetNameHead := datasetName[:index] + // datasetUrl := "s3://" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" + // DatasUrlList = append(DatasUrlList, models.Datasurl{ + // DatasetUrl: datasetUrl, + // DatasetName: datasetNameHead, + // }) + // } + // firstDataset := uuidList[0] + // dataUrl = "/" + setting.Bucket + "/" + setting.BasePath + path.Join(firstDataset[0:1], firstDataset[1:2]) + "/" + firstDataset + firstDataset + "/" + // isMultiDataset = true + // return DatasUrlList, dataUrl, isMultiDataset, nil + // } + // return nil, "", isMultiDataset, nil } func IsDatasetUseCountExceed(uuid string) bool { uuidList := strings.Split(uuid, ";") From b8ec66f52cd583fe04af07fc250619409ff57b36 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 1 Jul 2022 14:50:11 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/modelarts.go | 57 +++++++-------------------------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 00c9a5c88..d1d00d095 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1101,15 +1101,15 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) Value: modelarts.Ascend, }) } - DatasUrlList, dataUrl, datasetNames, isMultiDataset, err := GetDatasUrlListByUUIDS(uuid) + datasUrlList, dataUrl, datasetNames, isMultiDataset, err := getDatasUrlListByUUIDS(uuid) if err != nil { - log.Error("Failed to GetDatasUrlListByUUIDS: %v", err) + log.Error("Failed to getDatasUrlListByUUIDS: %v", err) trainJobErrorNewDataPrepare(ctx, form) - ctx.RenderWithErr("Failed to GetDatasUrlListByUUIDS:"+err.Error(), tplModelArtsTrainJobNew, &form) + ctx.RenderWithErr("Failed to getDatasUrlListByUUIDS:"+err.Error(), tplModelArtsTrainJobNew, &form) return } dataPath := dataUrl - jsondatas, err := json.Marshal(DatasUrlList) + jsondatas, err := json.Marshal(datasUrlList) if err != nil { log.Error("Failed to Marshal: %v", err) trainJobErrorNewDataPrepare(ctx, form) @@ -1342,15 +1342,15 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ }) } - DatasUrlList, dataUrl, datasetNames, isMultiDataset, err := GetDatasUrlListByUUIDS(uuid) + datasUrlList, dataUrl, datasetNames, isMultiDataset, err := getDatasUrlListByUUIDS(uuid) if err != nil { - log.Error("Failed to GetDatasUrlListByUUIDS: %v", err) + log.Error("Failed to getDatasUrlListByUUIDS: %v", err) versionErrorDataPrepare(ctx, form) - ctx.RenderWithErr("Failed to GetDatasUrlListByUUIDS:"+err.Error(), tplModelArtsTrainJobVersionNew, &form) + ctx.RenderWithErr("Failed to getDatasUrlListByUUIDS:"+err.Error(), tplModelArtsTrainJobVersionNew, &form) return } dataPath := dataUrl - jsondatas, err := json.Marshal(DatasUrlList) + jsondatas, err := json.Marshal(datasUrlList) if err != nil { log.Error("Failed to Marshal: %v", err) versionErrorDataPrepare(ctx, form) @@ -2482,7 +2482,7 @@ func TrainJobDownloadLogFile(ctx *context.Context) { ctx.Resp.Header().Set("Cache-Control", "max-age=0") http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) } -func GetDatasUrlListByUUIDS(uuidStr string) ([]models.Datasurl, string, string, bool, error) { +func getDatasUrlListByUUIDS(uuidStr string) ([]models.Datasurl, string, string, bool, error) { var isMultiDataset bool var dataUrl string var datasetNames string @@ -2528,43 +2528,4 @@ func GetDatasUrlListByUUIDS(uuidStr string) ([]models.Datasurl, string, string, } return datasUrlList, dataUrl, datasetNames, isMultiDataset, nil - - // var dataUrl string - // var DatasUrlList []models.Datasurl - // uuidList := strings.Split(uuidStr, ";") - // isMultiDataset := false - - // if len(uuidList) >= 1 { - // for _, uuid := range uuidList { - // attach, err := models.GetAttachmentByUUID(uuid) - // if err != nil { - // log.Error("GetAttachmentByUUID failed: %v", err) - // return nil, "", isMultiDataset, err - // } - // datasetName := attach.Name - // index := strings.LastIndex(datasetName, ".") - // if index <= 0 { - // index = 0 - // } - // datasetNameHead := datasetName[:index] - // datasetUrl := "s3://" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" - // DatasUrlList = append(DatasUrlList, models.Datasurl{ - // DatasetUrl: datasetUrl, - // DatasetName: datasetNameHead, - // }) - // } - // firstDataset := uuidList[0] - // dataUrl = "/" + setting.Bucket + "/" + setting.BasePath + path.Join(firstDataset[0:1], firstDataset[1:2]) + "/" + firstDataset + firstDataset + "/" - // isMultiDataset = true - // return DatasUrlList, dataUrl, isMultiDataset, nil - // } - // return nil, "", isMultiDataset, nil -} -func IsDatasetUseCountExceed(uuid string) bool { - uuidList := strings.Split(uuid, ";") - if len(uuidList) > setting.MaxDatasetNum { - return true - } else { - return false - } } From 6bd2b4d73d8c3525038c84689aa3e88d49b9af8f Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 1 Jul 2022 15:26:43 +0800 Subject: [PATCH 4/6] fix issue --- templates/repo/cloudbrain/trainjob/new.tmpl | 3 ++- templates/repo/grampus/trainjob/gpu/new.tmpl | 2 +- templates/repo/grampus/trainjob/npu/new.tmpl | 2 +- web_src/js/components/dataset/selectDataset.vue | 2 +- web_src/less/openi.less | 12 ++++++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/templates/repo/cloudbrain/trainjob/new.tmpl b/templates/repo/cloudbrain/trainjob/new.tmpl index 75c123b5e..adf3adf9b 100755 --- a/templates/repo/cloudbrain/trainjob/new.tmpl +++ b/templates/repo/cloudbrain/trainjob/new.tmpl @@ -30,7 +30,7 @@ margin-left: 10.5rem !important; align-items: center; } - + .width81 { margin-left: 1.5rem !important; width: 81% !important; @@ -62,6 +62,7 @@ color: rgba(16, 16, 16, 100) !important; font-size: 14px !important; } +