| @@ -55,6 +55,7 @@ coverage.all | |||
| !/custom/conf/templates | |||
| /custom/conf/app.ini | |||
| !/custom/conf/app.ini.sample | |||
| /custom/public/kanban | |||
| /data | |||
| /indexers | |||
| /log | |||
| @@ -206,7 +206,16 @@ func (task *Cloudbrain) CorrectCreateUnix() { | |||
| func (task *Cloudbrain) IsTerminal() bool { | |||
| status := task.Status | |||
| return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || status == string(ModelArtsTrainJobKilled) || status == string(ModelArtsStopped) || status == string(JobStopped) || status == string(JobFailed) || status == string(JobSucceeded) | |||
| return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || | |||
| status == string(ModelArtsTrainJobKilled) || status == string(ModelArtsStopped) || | |||
| status == string(JobStopped) || status == string(JobFailed) || | |||
| status == string(JobSucceeded) || status == GrampusStatusFailed || | |||
| status == GrampusStatusSucceeded || status == GrampusStatusStopped | |||
| } | |||
| func (task *Cloudbrain) IsRunning() bool { | |||
| status := task.Status | |||
| return status == string(ModelArtsTrainJobRunning) || status == string(ModelArtsRunning) || | |||
| status == string(JobRunning) || status == GrampusStatusRunning | |||
| } | |||
| func ConvertDurationToStr(duration int64) string { | |||
| @@ -158,16 +158,20 @@ DROP TRIGGER IF EXISTS es_update_dataset on public.dataset; | |||
| CREATE OR REPLACE FUNCTION public.update_dataset() RETURNS trigger AS | |||
| $def$ | |||
| BEGIN | |||
| UPDATE public.dataset_es | |||
| SET description=NEW.description, | |||
| title=NEW.title, | |||
| category=NEW.category, | |||
| task=NEW.task, | |||
| download_times=NEW.download_times, | |||
| updated_unix=NEW.updated_unix, | |||
| file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false), | |||
| file_desc=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false) | |||
| where id=NEW.id; | |||
| if (NEW.status=0) then | |||
| delete from public.dataset_es where id=NEW.id; | |||
| elsif (NEW.status=1) then | |||
| UPDATE public.dataset_es | |||
| SET description=NEW.description, | |||
| title=NEW.title, | |||
| category=NEW.category, | |||
| task=NEW.task, | |||
| download_times=NEW.download_times, | |||
| updated_unix=NEW.updated_unix, | |||
| file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false), | |||
| file_desc=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false) | |||
| where id=NEW.id; | |||
| end if; | |||
| return new; | |||
| END | |||
| $def$ | |||
| @@ -461,7 +461,7 @@ $def$ | |||
| if not OLD.is_private and NEW.is_private then | |||
| delete from public.issue_es where repo_id=NEW.id; | |||
| delete from public.dataset_es where repo_id=NEW.id; | |||
| -- delete from public.dataset_es where repo_id=NEW.id; | |||
| delete from public.repository_es where id=NEW.id; | |||
| end if; | |||
| @@ -238,6 +238,9 @@ func GetAllUserPublicRepoKPIStats(startTime time.Time, endTime time.Time) (map[s | |||
| CommitLines: 0, | |||
| } | |||
| } | |||
| if value.Email == "1250125907@qq.com" || value.Email == "peiyongyu-34@163.com" { | |||
| log.Info("repo path=" + repository.RepoPath()) | |||
| } | |||
| authors[key].Commits += value.Commits | |||
| authors[key].CommitLines += value.CommitLines | |||
| @@ -954,7 +954,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, | |||
| CountDate = time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 1, 0, 0, currentTimeNow.Location()) | |||
| } | |||
| DataDate := startTime.Format("2006-01-02") | |||
| DataDate := CountDate.Format("2006-01-02") | |||
| CodeMergeCountMap := queryPullRequest(start_unix, end_unix) | |||
| CommitCountMap := queryCommitAction(start_unix, end_unix, 5) | |||
| IssueCountMap := queryCreateIssue(start_unix, end_unix) | |||
| @@ -1140,6 +1140,7 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, userA | |||
| ",activate_regist_user=" + fmt.Sprint(useMetrics.ActivateRegistUser) + | |||
| ",not_activate_regist_user=" + fmt.Sprint(useMetrics.CurrentDayRegistUser-useMetrics.ActivateRegistUser) + | |||
| ",current_day_regist_user=" + fmt.Sprint(useMetrics.CurrentDayRegistUser) + | |||
| ",data_date='" + time.Unix(key, 0).Format("2006-01-02") + "'" + | |||
| " where count_date=" + fmt.Sprint(key) | |||
| statictisSess.Exec(updateSql) | |||
| @@ -19,6 +19,7 @@ const ( | |||
| ACCESS_TOKEN_PATH = "/cgi-bin/token" | |||
| QR_CODE_PATH = "/cgi-bin/qrcode/create" | |||
| GET_MATERIAL_PATH = "/cgi-bin/material/batchget_material" | |||
| SEND_TEMPLATE_PATH = "/cgi-bin/message/template/send" | |||
| ACTION_QR_STR_SCENE = "QR_STR_SCENE" | |||
| ERR_CODE_ACCESSTOKEN_EXPIRE = 42001 | |||
| @@ -41,12 +42,33 @@ type QRCodeRequest struct { | |||
| Action_info ActionInfo `json:"action_info"` | |||
| Expire_seconds int `json:"expire_seconds"` | |||
| } | |||
| type MaterialRequest struct { | |||
| Type string `json:"type"` | |||
| Offset int `json:"offset"` | |||
| Count int `json:"count"` | |||
| } | |||
| type TemplateMsgRequest struct { | |||
| ToUser string `json:"touser"` | |||
| TemplateId string `json:"template_id"` | |||
| Url string `json:"url"` | |||
| ClientMsgId string `json:"client_msg_id"` | |||
| Data interface{} `json:"data"` | |||
| } | |||
| type TemplateValue struct { | |||
| Value string `json:"value"` | |||
| Color string `json:"color"` | |||
| } | |||
| type CloudbrainTaskData struct { | |||
| First TemplateValue `json:"first"` | |||
| Keyword1 TemplateValue `json:"keyword1"` | |||
| Keyword2 TemplateValue `json:"keyword2"` | |||
| Keyword3 TemplateValue `json:"keyword3"` | |||
| Remark TemplateValue `json:"remark"` | |||
| } | |||
| type ActionInfo struct { | |||
| Scene Scene `json:"scene"` | |||
| } | |||
| @@ -161,3 +183,27 @@ func getErrorCodeFromResponse(r *resty.Response) int { | |||
| c, _ := strconv.Atoi(fmt.Sprint(code)) | |||
| return c | |||
| } | |||
| func sendTemplateMsg(req TemplateMsgRequest) (error, bool) { | |||
| client := getWechatRestyClient() | |||
| bodyJson, _ := json.Marshal(req) | |||
| r, err := client.R(). | |||
| SetHeader("Content-Type", "application/json"). | |||
| SetQueryParam("access_token", GetWechatAccessToken()). | |||
| SetBody(bodyJson). | |||
| Post(setting.WechatApiHost + SEND_TEMPLATE_PATH) | |||
| if err != nil { | |||
| log.Error("sendTemplateMsg,e=%v", err) | |||
| return nil, false | |||
| } | |||
| a := r.Body() | |||
| resultMap := make(map[string]interface{}, 0) | |||
| json.Unmarshal(a, &resultMap) | |||
| errcode := resultMap["errcode"] | |||
| log.Info("sendTemplateMsg,%v", r) | |||
| if errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_EXPIRE) || errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_INVALID) { | |||
| return nil, true | |||
| } | |||
| return nil, false | |||
| } | |||
| @@ -0,0 +1,145 @@ | |||
| package wechat | |||
| import ( | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/log" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "errors" | |||
| "fmt" | |||
| "time" | |||
| ) | |||
| type JobOperateType string | |||
| const ( | |||
| JobOperateTypeStart JobOperateType = "start" | |||
| JobOperateTypeStop JobOperateType = "stop" | |||
| ) | |||
| func GetJobOperateTypeFromCloudbrainStatus(cloudbrain *models.Cloudbrain) JobOperateType { | |||
| if cloudbrain.IsTerminal() { | |||
| return JobOperateTypeStop | |||
| } | |||
| if cloudbrain.IsRunning() { | |||
| return JobOperateTypeStart | |||
| } | |||
| return "" | |||
| } | |||
| func SendCloudbrainStartedMsg(operateType JobOperateType, cloudbrain models.Cloudbrain) error { | |||
| defer func() { | |||
| if err := recover(); err != nil { | |||
| combinedErr := fmt.Errorf("%s\n%s", err, log.Stack(2)) | |||
| log.Error("PANIC:", combinedErr) | |||
| } | |||
| }() | |||
| repo, err := models.GetRepositoryByID(cloudbrain.RepoID) | |||
| if err != nil { | |||
| log.Error("SendCloudbrainStartedMsg GetRepositoryByID error,%v", err) | |||
| } | |||
| if setting.CloudbrainStartedTemplateId == "" { | |||
| return nil | |||
| } | |||
| openId := models.GetUserWechatOpenId(cloudbrain.UserID) | |||
| if openId == "" { | |||
| return errors.New("Wechat openId not exist") | |||
| } | |||
| data := CloudbrainTaskData{ | |||
| First: TemplateValue{Value: getCloudbrainTemplateTitle(operateType)}, | |||
| Keyword1: TemplateValue{Value: cloudbrain.DisplayJobName}, | |||
| Keyword2: TemplateValue{Value: getJobTypeDisplayName(cloudbrain.JobType)}, | |||
| Keyword3: TemplateValue{Value: time.Unix(int64(cloudbrain.CreatedUnix), 0).Format("2006-01-02 15:04:05")}, | |||
| Remark: TemplateValue{Value: getCloudbrainTemplateRemark(operateType)}, | |||
| } | |||
| req := TemplateMsgRequest{ | |||
| ToUser: openId, | |||
| TemplateId: setting.CloudbrainStartedTemplateId, | |||
| Url: getCloudbrainTemplateUrl(cloudbrain, repo), | |||
| ClientMsgId: string(operateType) + "_" + fmt.Sprint(cloudbrain.ID), | |||
| Data: data, | |||
| } | |||
| err, retryFlag := sendTemplateMsg(req) | |||
| if retryFlag { | |||
| log.Info("retrySendCloudbrainTemplateMsg calling") | |||
| refreshAccessToken() | |||
| err, _ = sendTemplateMsg(req) | |||
| if err != nil { | |||
| log.Error("SendCloudbrainStartedMsg err. %v", err) | |||
| return err | |||
| } | |||
| return nil | |||
| } | |||
| if err != nil { | |||
| log.Error("SendCloudbrainStartedMsg err. %v", err) | |||
| return err | |||
| } | |||
| return nil | |||
| } | |||
| func getCloudbrainTemplateUrl(cloudbrain models.Cloudbrain, repo *models.Repository) string { | |||
| url := setting.AppURL + repo.FullName() | |||
| switch cloudbrain.JobType { | |||
| case string(models.JobTypeDebug): | |||
| if cloudbrain.ComputeResource == "CPU/GPU" { | |||
| url += "/cloudbrain/" + fmt.Sprint(cloudbrain.ID) | |||
| } else { | |||
| url += "/modelarts/notebook/" + fmt.Sprint(cloudbrain.ID) | |||
| } | |||
| case string(models.JobTypeBenchmark): | |||
| url += "/cloudbrain/benchmark/" + fmt.Sprint(cloudbrain.ID) | |||
| case string(models.JobTypeTrain): | |||
| if cloudbrain.Type == models.TypeCloudBrainOne { | |||
| url += "/cloudbrain/train-job/" + fmt.Sprint(cloudbrain.JobID) | |||
| } else if cloudbrain.Type == models.TypeCloudBrainTwo { | |||
| url += "/modelarts/train-job/" + fmt.Sprint(cloudbrain.JobID) | |||
| } else if cloudbrain.Type == models.TypeC2Net { | |||
| url += "/grampus/train-job/" + fmt.Sprint(cloudbrain.JobID) | |||
| } | |||
| case string(models.JobTypeInference): | |||
| url += "/modelarts/inference-job/" + fmt.Sprint(cloudbrain.JobID) | |||
| } | |||
| return url | |||
| } | |||
| func getCloudbrainTemplateTitle(operateType JobOperateType) string { | |||
| var title string | |||
| switch operateType { | |||
| case JobOperateTypeStart: | |||
| title = "您好,您提交的算力资源申请已通过,任务已启动,请您关注运行情况。" | |||
| case JobOperateTypeStop: | |||
| title = "您好,您提交的任务已运行结束。" | |||
| } | |||
| return title | |||
| } | |||
| func getCloudbrainTemplateRemark(operateType JobOperateType) string { | |||
| var remark string | |||
| switch operateType { | |||
| case JobOperateTypeStart: | |||
| remark = "感谢您的耐心等待。" | |||
| case JobOperateTypeStop: | |||
| remark = "点击可查看运行结果" | |||
| } | |||
| return remark | |||
| } | |||
| func getJobTypeDisplayName(jobType string) string { | |||
| switch jobType { | |||
| case string(models.JobTypeDebug): | |||
| return "调试任务" | |||
| case string(models.JobTypeBenchmark): | |||
| return "评测任务" | |||
| case string(models.JobTypeTrain): | |||
| return "训练任务" | |||
| case string(models.JobTypeInference): | |||
| return "推理任务" | |||
| } | |||
| return "" | |||
| } | |||
| @@ -62,7 +62,7 @@ func GetUserKPIStats(repoPath string, startTime time.Time, endTime time.Time) (m | |||
| after := startTime.Format(time.RFC3339) | |||
| until := endTime.Format(time.RFC3339) | |||
| args := []string{"log", "--numstat", "--no-merges", "--branches=*", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--after='%s'", after), fmt.Sprintf("--until=='%s'", until)} | |||
| args := []string{"log", "--numstat", "--no-merges", "--branches=*", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--after='%s'", after), fmt.Sprintf("--until='%s'", until)} | |||
| stdout, err := NewCommand(args...).RunInDirBytes(repoPath) | |||
| if err != nil { | |||
| return nil, err | |||
| @@ -56,4 +56,6 @@ type Notifier interface { | |||
| NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) | |||
| NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) | |||
| NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) | |||
| } | |||
| @@ -158,3 +158,7 @@ func (*NullNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Reposit | |||
| func (*NullNotifier) NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) { | |||
| } | |||
| func (*NullNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { | |||
| } | |||
| @@ -12,6 +12,7 @@ import ( | |||
| "code.gitea.io/gitea/modules/notification/mail" | |||
| "code.gitea.io/gitea/modules/notification/ui" | |||
| "code.gitea.io/gitea/modules/notification/webhook" | |||
| wechatNotifier "code.gitea.io/gitea/modules/notification/wechat" | |||
| "code.gitea.io/gitea/modules/repository" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| ) | |||
| @@ -35,6 +36,7 @@ func NewContext() { | |||
| RegisterNotifier(indexer.NewNotifier()) | |||
| RegisterNotifier(webhook.NewNotifier()) | |||
| RegisterNotifier(action.NewNotifier()) | |||
| RegisterNotifier(wechatNotifier.NewNotifier()) | |||
| } | |||
| // NotifyUploadAttachment notifies attachment upload message to notifiers | |||
| @@ -269,3 +271,10 @@ func NotifySyncDeleteRef(pusher *models.User, repo *models.Repository, refType, | |||
| notifier.NotifySyncDeleteRef(pusher, repo, refType, refFullName) | |||
| } | |||
| } | |||
| // NotifyChangeCloudbrainStatus | |||
| func NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { | |||
| for _, notifier := range notifiers { | |||
| notifier.NotifyChangeCloudbrainStatus(cloudbrain, oldStatus) | |||
| } | |||
| } | |||
| @@ -0,0 +1,44 @@ | |||
| // Copyright 2019 The Gitea Authors. All rights reserved. | |||
| // Use of this source code is governed by a MIT-style | |||
| // license that can be found in the LICENSE file. | |||
| package wechat | |||
| import ( | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/auth/wechat" | |||
| "code.gitea.io/gitea/modules/notification/base" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| ) | |||
| type wechatNotifier struct { | |||
| base.NullNotifier | |||
| } | |||
| var ( | |||
| _ base.Notifier = &wechatNotifier{} | |||
| ) | |||
| // NewNotifier create a new wechatNotifier notifier | |||
| func NewNotifier() base.Notifier { | |||
| return &wechatNotifier{} | |||
| } | |||
| func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { | |||
| operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain) | |||
| if operateType == "" { | |||
| return | |||
| } | |||
| switch operateType { | |||
| case wechat.JobOperateTypeStart: | |||
| if len(setting.CloudbrainStartedNotifyList) == 0 { | |||
| return | |||
| } | |||
| for _, v := range setting.CloudbrainStartedNotifyList { | |||
| if v == cloudbrain.JobType { | |||
| go wechat.SendCloudbrainStartedMsg(operateType, *cloudbrain) | |||
| return | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -582,6 +582,10 @@ var ( | |||
| TreePathOfAutoMsgReply string | |||
| TreePathOfSubscribe string | |||
| //wechat template msg config | |||
| CloudbrainStartedTemplateId string | |||
| CloudbrainStartedNotifyList []string | |||
| //nginx proxy | |||
| PROXYURL string | |||
| RadarMap = struct { | |||
| @@ -1432,7 +1436,7 @@ func NewContext() { | |||
| WechatApiHost = sec.Key("HOST").MustString("https://api.weixin.qq.com") | |||
| WechatApiTimeoutSeconds = sec.Key("TIMEOUT_SECONDS").MustInt(3) | |||
| WechatAppId = sec.Key("APP_ID").MustString("wxba77b915a305a57d") | |||
| WechatAppSecret = sec.Key("APP_SECRET").MustString("e48e13f315adc32749ddc7057585f198") | |||
| WechatAppSecret = sec.Key("APP_SECRET").MustString("") | |||
| WechatQRCodeExpireSeconds = sec.Key("QR_CODE_EXPIRE_SECONDS").MustInt(120) | |||
| WechatAuthSwitch = sec.Key("AUTH_SWITCH").MustBool(true) | |||
| UserNameOfWechatReply = sec.Key("AUTO_REPLY_USER_NAME").MustString("OpenIOSSG") | |||
| @@ -1440,6 +1444,8 @@ func NewContext() { | |||
| RefNameOfWechatReply = sec.Key("AUTO_REPLY_REF_NAME").MustString("master") | |||
| TreePathOfAutoMsgReply = sec.Key("AUTO_REPLY_TREE_PATH").MustString("wechat/auto_reply.json") | |||
| TreePathOfSubscribe = sec.Key("SUBSCRIBE_TREE_PATH").MustString("wechat/subscribe_reply.json") | |||
| CloudbrainStartedTemplateId = sec.Key("CLOUDBRAIN_STARTED_TEMPLATE_ID").MustString("") | |||
| CloudbrainStartedNotifyList = strings.Split(sec.Key("CLOUDBRAIN_STARTED_NOTIFY_LIST").MustString("DEBUG"), ",") | |||
| SetRadarMapConfig() | |||
| @@ -187,9 +187,6 @@ func GetOneLevelAllObjectUnderDirMinio(bucket string, prefixRootPath string, rel | |||
| if val.Key == Prefix { | |||
| continue | |||
| } | |||
| if strings.Contains(val.Key[prefixLen:len(val.Key)-1], "/") { | |||
| continue | |||
| } | |||
| if strings.HasSuffix(val.Key, "/") { | |||
| isDir = true | |||
| fileName = val.Key[prefixLen : len(val.Key)-1] | |||
| @@ -1007,7 +1007,7 @@ cloudbrain.time.starttime=Start run time | |||
| cloudbrain.time.endtime=End run time | |||
| cloudbrain.datasetdownload=Dataset download url | |||
| model_manager = Model | |||
| model_noright=No right | |||
| model_noright=You have no right to do the operation. | |||
| model_rename=Duplicate model name, please modify model name. | |||
| date=Date | |||
| @@ -1225,7 +1225,7 @@ model.manage.create_new_convert_task=Create Model Transformation Task | |||
| modelconvert.manage.create_error1=A model transformation task with the same name already exists. | |||
| modelconvert.manage.create_error2=Only one running model transformation task can be created. | |||
| modelconvert.manage.model_not_exist=The model does not exist. | |||
| modelconvert.manage.no_operate_right=No operation permission. | |||
| modelconvert.manage.no_operate_right=You have no right to do the operation. | |||
| grampus.train_job.ai_center = AI Center | |||
| grampus.dataset_path_rule = The code is storaged in /cache/code;the dataset is storaged in /cache/dataset;and please put your model into /cache/output, then you can download it online。 | |||
| @@ -1006,7 +1006,7 @@ datasets.desc=数据集功能 | |||
| cloudbrain_helper=使用GPU/NPU资源,开启Notebook、模型训练任务等 | |||
| model_manager = 模型 | |||
| model_noright=无权限操作 | |||
| model_noright=您没有操作权限。 | |||
| model_rename=模型名称重复,请修改模型名称 | |||
| @@ -1237,7 +1237,7 @@ model.manage.create_new_convert_task=创建模型转换任务 | |||
| modelconvert.manage.create_error1=相同的名称模型转换任务已经存在。 | |||
| modelconvert.manage.create_error2=只能创建一个正在运行的模型转换任务。 | |||
| modelconvert.manage.model_not_exist=选择的模型不存在。 | |||
| modelconvert.manage.no_operate_right=无操作权限。 | |||
| modelconvert.manage.no_operate_right=您没有操作权限。 | |||
| grampus.train_job.ai_center=智算中心 | |||
| grampus.dataset_path_rule = 训练脚本存储在/cache/code中,数据集存储在/cache/dataset中,训练输出请存储在/cache/output中以供后续下载。 | |||
| @@ -6,6 +6,7 @@ | |||
| package repo | |||
| import ( | |||
| "code.gitea.io/gitea/modules/notification" | |||
| "encoding/json" | |||
| "net/http" | |||
| "sort" | |||
| @@ -74,7 +75,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
| log.Error("ConvertToJobResultPayload failed:", err) | |||
| return | |||
| } | |||
| oldStatus := job.Status | |||
| job.Status = result.JobStatus.State | |||
| taskRoles := result.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| @@ -86,6 +87,9 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
| if result.JobStatus.State != string(models.JobWaiting) { | |||
| models.ParseAndSetDurationFromCloudBrainOne(result, job) | |||
| if oldStatus != job.Status { | |||
| notification.NotifyChangeCloudbrainStatus(job, oldStatus) | |||
| } | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -99,6 +103,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
| "SubState": result.JobStatus.SubState, | |||
| "CreatedTime": time.Unix(result.JobStatus.CreatedTime/1000, 0).Format("2006-01-02 15:04:05"), | |||
| "CompletedTime": time.Unix(result.JobStatus.CompletedTime/1000, 0).Format("2006-01-02 15:04:05"), | |||
| "JobDuration": job.TrainJobDuration, | |||
| }) | |||
| } | |||
| @@ -123,7 +128,7 @@ func GetCloudBrainInferenceJob(ctx *context.APIContext) { | |||
| log.Error("ConvertToJobResultPayload failed:", err) | |||
| return | |||
| } | |||
| oldStatus := job.Status | |||
| job.Status = result.JobStatus.State | |||
| if result.JobStatus.State != string(models.JobWaiting) && result.JobStatus.State != string(models.JobFailed) { | |||
| taskRoles := result.TaskRoles | |||
| @@ -136,6 +141,9 @@ func GetCloudBrainInferenceJob(ctx *context.APIContext) { | |||
| if result.JobStatus.State != string(models.JobWaiting) { | |||
| models.ParseAndSetDurationFromCloudBrainOne(result, job) | |||
| if oldStatus != job.Status { | |||
| notification.NotifyChangeCloudbrainStatus(job, oldStatus) | |||
| } | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -6,6 +6,7 @@ | |||
| package repo | |||
| import ( | |||
| "code.gitea.io/gitea/modules/notification" | |||
| "encoding/json" | |||
| "net/http" | |||
| "path" | |||
| @@ -42,8 +43,11 @@ func GetModelArtsNotebook(ctx *context.APIContext) { | |||
| ctx.NotFound(err) | |||
| return | |||
| } | |||
| oldStatus := job.Status | |||
| job.Status = result.Status | |||
| if oldStatus != result.Status { | |||
| notification.NotifyChangeCloudbrainStatus(job, oldStatus) | |||
| } | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -75,21 +79,26 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { | |||
| if job.StartTime == 0 && result.Lease.UpdateTime > 0 { | |||
| job.StartTime = timeutil.TimeStamp(result.Lease.UpdateTime / 1000) | |||
| } | |||
| oldStatus := job.Status | |||
| job.Status = result.Status | |||
| if job.EndTime == 0 && models.IsModelArtsDebugJobTerminal(job.Status) { | |||
| job.EndTime = timeutil.TimeStampNow() | |||
| } | |||
| job.CorrectCreateUnix() | |||
| job.ComputeAndSetDuration() | |||
| if oldStatus != result.Status { | |||
| notification.NotifyChangeCloudbrainStatus(job, oldStatus) | |||
| } | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| } | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "ID": ID, | |||
| "JobName": job.JobName, | |||
| "JobStatus": result.Status, | |||
| "ID": ID, | |||
| "JobName": job.JobName, | |||
| "JobStatus": result.Status, | |||
| "JobDuration": job.TrainJobDuration, | |||
| }) | |||
| } | |||
| @@ -111,10 +120,13 @@ func GetModelArtsTrainJob(ctx *context.APIContext) { | |||
| ctx.NotFound(err) | |||
| return | |||
| } | |||
| oldStatus := job.Status | |||
| job.Status = modelarts.TransTrainJobStatus(result.IntStatus) | |||
| job.Duration = result.Duration | |||
| job.TrainJobDuration = result.TrainJobDuration | |||
| if oldStatus != job.Status { | |||
| notification.NotifyChangeCloudbrainStatus(job, oldStatus) | |||
| } | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -155,7 +167,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { | |||
| log.Error("ConvertToJobResultPayload failed:", err) | |||
| return | |||
| } | |||
| oldStatus := job.Status | |||
| job.Status = result.JobStatus.State | |||
| if result.JobStatus.State != string(models.JobWaiting) && result.JobStatus.State != string(models.JobFailed) { | |||
| taskRoles := result.TaskRoles | |||
| @@ -168,6 +180,9 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { | |||
| if result.JobStatus.State != string(models.JobWaiting) { | |||
| models.ParseAndSetDurationFromCloudBrainOne(result, job) | |||
| if oldStatus != job.Status { | |||
| notification.NotifyChangeCloudbrainStatus(job, oldStatus) | |||
| } | |||
| err = models.UpdateJob(job) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:", err) | |||
| @@ -152,6 +152,10 @@ func saveModelByParameters(jobId string, versionName string, name string, versio | |||
| } | |||
| func SaveNewNameModel(ctx *context.Context) { | |||
| if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { | |||
| ctx.Error(403, ctx.Tr("repo.model_noright")) | |||
| return | |||
| } | |||
| name := ctx.Query("Name") | |||
| if name == "" { | |||
| ctx.Error(500, fmt.Sprintf("name or version is null.")) | |||
| @@ -169,6 +173,10 @@ func SaveNewNameModel(ctx *context.Context) { | |||
| } | |||
| func SaveModel(ctx *context.Context) { | |||
| if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { | |||
| ctx.Error(403, ctx.Tr("repo.model_noright")) | |||
| return | |||
| } | |||
| log.Info("save model start.") | |||
| JobId := ctx.Query("JobId") | |||
| VersionName := ctx.Query("VersionName") | |||
| @@ -177,16 +185,8 @@ func SaveModel(ctx *context.Context) { | |||
| label := ctx.Query("Label") | |||
| description := ctx.Query("Description") | |||
| engine := ctx.QueryInt("Engine") | |||
| trainTaskCreate := ctx.QueryBool("trainTaskCreate") | |||
| modelSelectedFile := ctx.Query("modelSelectedFile") | |||
| log.Info("engine=" + fmt.Sprint(engine) + " modelSelectedFile=" + modelSelectedFile) | |||
| if !trainTaskCreate { | |||
| if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { | |||
| //ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| ctx.JSON(403, ctx.Tr("repo.model_noright")) | |||
| return | |||
| } | |||
| } | |||
| if JobId == "" || VersionName == "" { | |||
| ctx.Error(500, fmt.Sprintf("JobId or VersionName is null.")) | |||
| @@ -15,6 +15,8 @@ import ( | |||
| "time" | |||
| "unicode/utf8" | |||
| "code.gitea.io/gitea/modules/notification" | |||
| "code.gitea.io/gitea/modules/grampus" | |||
| "code.gitea.io/gitea/modules/timeutil" | |||
| @@ -218,6 +220,255 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { | |||
| return nil | |||
| } | |||
| func cloudBrainTrainJobErrorPrepare(ctx *context.Context, form auth.CreateCloudBrainForm) error { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| if categories == nil { | |||
| json.Unmarshal([]byte(setting.BenchmarkCategory), &categories) | |||
| } | |||
| ctx.Data["benchmark_categories"] = categories.Category | |||
| ctx.Data["benchmark_types"] = GetBenchmarkTypes(ctx).BenchmarkType | |||
| queuesDetail, _ := cloudbrain.GetQueuesDetail() | |||
| if queuesDetail != nil { | |||
| ctx.Data["QueuesDetail"] = queuesDetail | |||
| } | |||
| cloudbrain.InitSpecialPool() | |||
| if gpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) | |||
| } | |||
| ctx.Data["gpu_types"] = gpuInfos.GpuInfo | |||
| if trainGpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.TrainGpuTypes), &trainGpuInfos) | |||
| } | |||
| ctx.Data["train_gpu_types"] = trainGpuInfos.GpuInfo | |||
| if inferenceGpuInfos == nil && setting.InferenceGpuTypes != "" { | |||
| json.Unmarshal([]byte(setting.InferenceGpuTypes), &inferenceGpuInfos) | |||
| } | |||
| if inferenceGpuInfos != nil { | |||
| ctx.Data["inference_gpu_types"] = inferenceGpuInfos.GpuInfo | |||
| } | |||
| if benchmarkGpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) | |||
| } | |||
| ctx.Data["benchmark_gpu_types"] = benchmarkGpuInfos.GpuInfo | |||
| if benchmarkResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.BenchmarkResourceSpecs), &benchmarkResourceSpecs) | |||
| } | |||
| ctx.Data["benchmark_resource_specs"] = benchmarkResourceSpecs.ResourceSpec | |||
| if cloudbrain.ResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) | |||
| } | |||
| ctx.Data["resource_specs"] = cloudbrain.ResourceSpecs.ResourceSpec | |||
| if cloudbrain.TrainResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) | |||
| } | |||
| ctx.Data["train_resource_specs"] = cloudbrain.TrainResourceSpecs.ResourceSpec | |||
| if cloudbrain.InferenceResourceSpecs == nil && setting.InferenceResourceSpecs != "" { | |||
| json.Unmarshal([]byte(setting.InferenceResourceSpecs), &cloudbrain.InferenceResourceSpecs) | |||
| } | |||
| if cloudbrain.InferenceResourceSpecs != nil { | |||
| ctx.Data["inference_resource_specs"] = cloudbrain.InferenceResourceSpecs.ResourceSpec | |||
| } | |||
| if cloudbrain.SpecialPools != nil { | |||
| var debugGpuTypes []*models.GpuInfo | |||
| var trainGpuTypes []*models.GpuInfo | |||
| for _, pool := range cloudbrain.SpecialPools.Pools { | |||
| org, _ := models.GetOrgByName(pool.Org) | |||
| if org != nil { | |||
| isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID) | |||
| if isOrgMember { | |||
| for _, jobType := range pool.JobType { | |||
| if jobType == string(models.JobTypeDebug) { | |||
| debugGpuTypes = append(debugGpuTypes, pool.Pool...) | |||
| if pool.ResourceSpec != nil { | |||
| ctx.Data["resource_specs"] = pool.ResourceSpec | |||
| } | |||
| } else if jobType == string(models.JobTypeTrain) { | |||
| trainGpuTypes = append(trainGpuTypes, pool.Pool...) | |||
| if pool.ResourceSpec != nil { | |||
| ctx.Data["train_resource_specs"] = pool.ResourceSpec | |||
| } | |||
| } | |||
| } | |||
| break | |||
| } | |||
| } | |||
| } | |||
| if len(debugGpuTypes) > 0 { | |||
| ctx.Data["gpu_types"] = debugGpuTypes | |||
| } | |||
| if len(trainGpuTypes) > 0 { | |||
| ctx.Data["train_gpu_types"] = trainGpuTypes | |||
| } | |||
| } | |||
| var Parameters modelarts.Parameters | |||
| if err := json.Unmarshal([]byte(form.Params), &Parameters); err != nil { | |||
| ctx.ServerError("json.Unmarshal failed:", err) | |||
| return err | |||
| } | |||
| ctx.Data["params"] = Parameters.Parameter | |||
| ctx.Data["boot_file"] = form.BootFile | |||
| ctx.Data["attachment"] = form.Attachment | |||
| _, datasetNames, err := models.GetDatasetInfo(form.Attachment) | |||
| if err != nil { | |||
| log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) | |||
| return nil | |||
| } | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["branch_name"] = form.BranchName | |||
| ctx.Data["datasetType"] = models.TypeCloudBrainOne | |||
| ctx.Data["display_job_name"] = form.DisplayJobName | |||
| ctx.Data["image"] = form.Image | |||
| ctx.Data["job_type"] = form.JobType | |||
| ctx.Data["gpu_type"] = form.GpuType | |||
| ctx.Data["resource_spec_id"] = form.ResourceSpecId | |||
| return nil | |||
| } | |||
| func cloudBrainInferenceJobErrorPrepare(ctx *context.Context, form auth.CreateCloudBrainInferencForm) error { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| if categories == nil { | |||
| json.Unmarshal([]byte(setting.BenchmarkCategory), &categories) | |||
| } | |||
| ctx.Data["benchmark_categories"] = categories.Category | |||
| ctx.Data["benchmark_types"] = GetBenchmarkTypes(ctx).BenchmarkType | |||
| queuesDetail, _ := cloudbrain.GetQueuesDetail() | |||
| if queuesDetail != nil { | |||
| ctx.Data["QueuesDetail"] = queuesDetail | |||
| } | |||
| cloudbrain.InitSpecialPool() | |||
| if gpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) | |||
| } | |||
| ctx.Data["gpu_types"] = gpuInfos.GpuInfo | |||
| if trainGpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.TrainGpuTypes), &trainGpuInfos) | |||
| } | |||
| ctx.Data["train_gpu_types"] = trainGpuInfos.GpuInfo | |||
| if inferenceGpuInfos == nil && setting.InferenceGpuTypes != "" { | |||
| json.Unmarshal([]byte(setting.InferenceGpuTypes), &inferenceGpuInfos) | |||
| } | |||
| if inferenceGpuInfos != nil { | |||
| ctx.Data["inference_gpu_types"] = inferenceGpuInfos.GpuInfo | |||
| } | |||
| if benchmarkGpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) | |||
| } | |||
| ctx.Data["benchmark_gpu_types"] = benchmarkGpuInfos.GpuInfo | |||
| if benchmarkResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.BenchmarkResourceSpecs), &benchmarkResourceSpecs) | |||
| } | |||
| ctx.Data["benchmark_resource_specs"] = benchmarkResourceSpecs.ResourceSpec | |||
| if cloudbrain.ResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) | |||
| } | |||
| ctx.Data["resource_specs"] = cloudbrain.ResourceSpecs.ResourceSpec | |||
| if cloudbrain.TrainResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) | |||
| } | |||
| ctx.Data["train_resource_specs"] = cloudbrain.TrainResourceSpecs.ResourceSpec | |||
| if cloudbrain.InferenceResourceSpecs == nil && setting.InferenceResourceSpecs != "" { | |||
| json.Unmarshal([]byte(setting.InferenceResourceSpecs), &cloudbrain.InferenceResourceSpecs) | |||
| } | |||
| if cloudbrain.InferenceResourceSpecs != nil { | |||
| ctx.Data["inference_resource_specs"] = cloudbrain.InferenceResourceSpecs.ResourceSpec | |||
| } | |||
| if cloudbrain.SpecialPools != nil { | |||
| var debugGpuTypes []*models.GpuInfo | |||
| var trainGpuTypes []*models.GpuInfo | |||
| for _, pool := range cloudbrain.SpecialPools.Pools { | |||
| org, _ := models.GetOrgByName(pool.Org) | |||
| if org != nil { | |||
| isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID) | |||
| if isOrgMember { | |||
| for _, jobType := range pool.JobType { | |||
| if jobType == string(models.JobTypeDebug) { | |||
| debugGpuTypes = append(debugGpuTypes, pool.Pool...) | |||
| if pool.ResourceSpec != nil { | |||
| ctx.Data["resource_specs"] = pool.ResourceSpec | |||
| } | |||
| } else if jobType == string(models.JobTypeTrain) { | |||
| trainGpuTypes = append(trainGpuTypes, pool.Pool...) | |||
| if pool.ResourceSpec != nil { | |||
| ctx.Data["train_resource_specs"] = pool.ResourceSpec | |||
| } | |||
| } | |||
| } | |||
| break | |||
| } | |||
| } | |||
| } | |||
| if len(debugGpuTypes) > 0 { | |||
| ctx.Data["gpu_types"] = debugGpuTypes | |||
| } | |||
| if len(trainGpuTypes) > 0 { | |||
| ctx.Data["train_gpu_types"] = trainGpuTypes | |||
| } | |||
| } | |||
| var Parameters modelarts.Parameters | |||
| if err := json.Unmarshal([]byte(form.Params), &Parameters); err != nil { | |||
| ctx.ServerError("json.Unmarshal failed:", err) | |||
| return err | |||
| } | |||
| ctx.Data["params"] = Parameters.Parameter | |||
| ctx.Data["boot_file"] = form.BootFile | |||
| ctx.Data["attachment"] = form.Attachment | |||
| _, datasetNames, err := models.GetDatasetInfo(form.Attachment) | |||
| if err != nil { | |||
| log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) | |||
| return nil | |||
| } | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["branch_name"] = form.BranchName | |||
| ctx.Data["datasetType"] = models.TypeCloudBrainOne | |||
| ctx.Data["display_job_name"] = form.DisplayJobName | |||
| ctx.Data["image"] = form.Image | |||
| ctx.Data["job_type"] = form.JobType | |||
| ctx.Data["gpu_type"] = form.GpuType | |||
| ctx.Data["resource_spec_id"] = form.ResourceSpecId | |||
| ctx.Data["label_names"] = form.LabelName | |||
| ctx.Data["train_url"] = form.TrainUrl | |||
| ctx.Data["ckpt_name"] = form.CkptName | |||
| ctx.Data["model_name"] = form.ModelName | |||
| ctx.Data["model_version"] = form.ModelVersion | |||
| ctx.Data["description"] = form.Description | |||
| return nil | |||
| } | |||
| func CloudBrainNew(ctx *context.Context) { | |||
| err := cloudBrainNewDataPrepare(ctx) | |||
| @@ -251,28 +502,28 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||
| if err == nil { | |||
| if len(tasks) != 0 { | |||
| log.Error("the job name did already exist", ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("the job name did already exist", tpl, &form) | |||
| return | |||
| } | |||
| } else { | |||
| if !models.IsErrJobNotExist(err) { | |||
| log.Error("system error, %v", err, ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("system error", tpl, &form) | |||
| return | |||
| } | |||
| } | |||
| if !jobNamePattern.MatchString(displayJobName) { | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tpl, &form) | |||
| return | |||
| } | |||
| if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeTrain) { | |||
| log.Error("jobtype error:", jobType, ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("jobtype error", tpl, &form) | |||
| return | |||
| } | |||
| @@ -280,13 +531,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||
| count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, jobType) | |||
| if err != nil { | |||
| log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("system error", tpl, &form) | |||
| return | |||
| } else { | |||
| if count >= 1 { | |||
| log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(ctx.Tr("repo.cloudbrain.morethanonejob"), tpl, &form) | |||
| return | |||
| } | |||
| @@ -320,7 +571,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||
| errStr := checkCloudBrainSpecialPool(ctx, jobType, gpuQueue, resourceSpecId) | |||
| if errStr != "" { | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(errStr, tpl, &form) | |||
| return | |||
| } | |||
| @@ -366,7 +617,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||
| err = cloudbrain.GenerateTask(req) | |||
| if err != nil { | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainTrainJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(err.Error(), tpl, &form) | |||
| return | |||
| } | |||
| @@ -406,20 +657,21 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra | |||
| if err == nil { | |||
| if len(tasks) != 0 { | |||
| log.Error("the job name did already exist", ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("the job name did already exist", tpl, &form) | |||
| return | |||
| } | |||
| } else { | |||
| if !models.IsErrJobNotExist(err) { | |||
| log.Error("system error, %v", err, ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("system error", tpl, &form) | |||
| return | |||
| } | |||
| } | |||
| if !jobNamePattern.MatchString(displayJobName) { | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tpl, &form) | |||
| return | |||
| } | |||
| @@ -427,13 +679,13 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra | |||
| count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, jobType) | |||
| if err != nil { | |||
| log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr("system error", tpl, &form) | |||
| return | |||
| } else { | |||
| if count >= 1 { | |||
| log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(ctx.Tr("repo.cloudbrain.morethanonejob"), tpl, &form) | |||
| return | |||
| } | |||
| @@ -453,7 +705,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra | |||
| datasetInfos, datasetNames, err := models.GetDatasetInfo(uuid) | |||
| if err != nil { | |||
| log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tpl, &form) | |||
| return | |||
| } | |||
| @@ -490,7 +742,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra | |||
| err = cloudbrain.GenerateTask(req) | |||
| if err != nil { | |||
| cloudBrainNewDataPrepare(ctx) | |||
| cloudBrainInferenceJobErrorPrepare(ctx, form) | |||
| ctx.RenderWithErr(err.Error(), tpl, &form) | |||
| return | |||
| } | |||
| @@ -641,6 +893,7 @@ func CloudBrainTrainJobShow(ctx *context.Context) { | |||
| func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.JobType) { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| debugListType := ctx.Query("debugListType") | |||
| cloudbrain.InitSpecialPool() | |||
| var task *models.Cloudbrain | |||
| var err error | |||
| @@ -652,22 +905,22 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| hasSpec := false | |||
| if task.JobType == string(models.JobTypeTrain) { | |||
| if cloudbrain.TrainResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) | |||
| } | |||
| hasSpec := false | |||
| for _, tmp := range cloudbrain.TrainResourceSpecs.ResourceSpec { | |||
| if tmp.Id == task.ResourceSpecId { | |||
| hasSpec = true | |||
| @@ -675,24 +928,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.Data["CpuNum"] = tmp.CpuNum | |||
| ctx.Data["MemMiB"] = tmp.MemMiB | |||
| ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB | |||
| } | |||
| } | |||
| if !hasSpec && cloudbrain.SpecialPools != nil { | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| if specialPool.ResourceSpec != nil { | |||
| for _, spec := range specialPool.ResourceSpec { | |||
| if task.ResourceSpecId == spec.Id { | |||
| ctx.Data["GpuNum"] = spec.GpuNum | |||
| ctx.Data["CpuNum"] = spec.CpuNum | |||
| ctx.Data["MemMiB"] = spec.MemMiB | |||
| ctx.Data["ShareMemMiB"] = spec.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } | |||
| break | |||
| } | |||
| } | |||
| @@ -702,10 +938,12 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| } | |||
| for _, tmp := range cloudbrain.InferenceResourceSpecs.ResourceSpec { | |||
| if tmp.Id == task.ResourceSpecId { | |||
| hasSpec = true | |||
| ctx.Data["GpuNum"] = tmp.GpuNum | |||
| ctx.Data["CpuNum"] = tmp.CpuNum | |||
| ctx.Data["MemMiB"] = tmp.MemMiB | |||
| ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } else { | |||
| @@ -714,10 +952,32 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| } | |||
| for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { | |||
| if tmp.Id == task.ResourceSpecId { | |||
| hasSpec = true | |||
| ctx.Data["GpuNum"] = tmp.GpuNum | |||
| ctx.Data["CpuNum"] = tmp.CpuNum | |||
| ctx.Data["MemMiB"] = tmp.MemMiB | |||
| ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } | |||
| if !hasSpec && cloudbrain.SpecialPools != nil { | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| if specialPool.ResourceSpec != nil { | |||
| for _, spec := range specialPool.ResourceSpec { | |||
| if task.ResourceSpecId == spec.Id { | |||
| ctx.Data["GpuNum"] = spec.GpuNum | |||
| ctx.Data["CpuNum"] = spec.CpuNum | |||
| ctx.Data["MemMiB"] = spec.MemMiB | |||
| ctx.Data["ShareMemMiB"] = spec.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -736,14 +996,6 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| for _, resourceType := range specialPool.Pool { | |||
| if resourceType.Queue == jobRes.Config.GpuType { | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| } | |||
| } else if task.JobType == string(models.JobTypeInference) { | |||
| if inferenceGpuInfos == nil { | |||
| @@ -775,16 +1027,30 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| } | |||
| } | |||
| } | |||
| if cloudbrain.SpecialPools != nil { | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| for _, resourceType := range specialPool.Pool { | |||
| if resourceType.Queue == jobRes.Config.GpuType { | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| } | |||
| } | |||
| taskRoles := jobRes.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| ctx.Data["taskRes"] = taskRes | |||
| ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics | |||
| oldStatus := task.Status | |||
| task.Status = taskRes.TaskStatuses[0].State | |||
| task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||
| task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP | |||
| models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||
| if task.DeletedAt.IsZero() { //normal record | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| @@ -900,6 +1166,20 @@ func CloudBrainCommitImageShow(ctx *context.Context) { | |||
| ctx.HTML(200, tplCloudBrainImageSubmit) | |||
| } | |||
| func GetImage(ctx *context.Context) { | |||
| var ID = ctx.Params(":id") | |||
| id, _ := strconv.ParseInt(ID, 10, 64) | |||
| image, err := models.GetImageByID(id) | |||
| if err != nil { | |||
| log.Error("GetImageByID failed:%v", err.Error()) | |||
| ctx.JSON(http.StatusNotFound, nil) | |||
| } | |||
| ctx.JSON(http.StatusOK, image) | |||
| } | |||
| func CloudBrainImageEdit(ctx *context.Context) { | |||
| ctx.Data["PageIsImageEdit"] = true | |||
| ctx.Data["PageFrom"] = ctx.Params(":from") | |||
| @@ -1124,12 +1404,15 @@ func CloudBrainStop(ctx *context.Context) { | |||
| errorMsg = "cloudbrain.Stopped_failed" | |||
| break | |||
| } | |||
| oldStatus := task.Status | |||
| task.Status = string(models.JobStopped) | |||
| if task.EndTime == 0 { | |||
| task.EndTime = timeutil.TimeStampNow() | |||
| } | |||
| task.ComputeAndSetDuration() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) | |||
| @@ -1223,11 +1506,15 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { | |||
| if err != nil { | |||
| log.Warn("Failed to stop cloudBrain job:"+taskInfo.JobID, err) | |||
| } else { | |||
| oldStatus := taskInfo.Status | |||
| taskInfo.Status = string(models.JobStopped) | |||
| if taskInfo.EndTime == 0 { | |||
| taskInfo.EndTime = timeutil.TimeStampNow() | |||
| } | |||
| taskInfo.ComputeAndSetDuration() | |||
| if oldStatus != taskInfo.Status { | |||
| notification.NotifyChangeCloudbrainStatus(taskInfo, oldStatus) | |||
| } | |||
| err = models.UpdateJob(taskInfo) | |||
| if err != nil { | |||
| log.Warn("UpdateJob failed", err) | |||
| @@ -1707,9 +1994,13 @@ func SyncCloudbrainStatus() { | |||
| jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||
| taskRoles := jobRes.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| oldStatus := task.Status | |||
| task.Status = taskRes.TaskStatuses[0].State | |||
| if task.Status != string(models.JobWaiting) { | |||
| models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| @@ -1736,6 +2027,9 @@ func SyncCloudbrainStatus() { | |||
| task.EndTime = timeutil.TimeStampNow() | |||
| } | |||
| task.ComputeAndSetDuration() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.DisplayJobName, err) | |||
| @@ -1754,6 +2048,7 @@ func SyncCloudbrainStatus() { | |||
| } | |||
| if result != nil { | |||
| oldStatus := task.Status | |||
| task.Status = result.Status | |||
| if task.StartTime == 0 && result.Lease.UpdateTime > 0 { | |||
| task.StartTime = timeutil.TimeStamp(result.Lease.UpdateTime / 1000) | |||
| @@ -1763,6 +2058,9 @@ func SyncCloudbrainStatus() { | |||
| } | |||
| task.CorrectCreateUnix() | |||
| task.ComputeAndSetDuration() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| @@ -1777,6 +2075,7 @@ func SyncCloudbrainStatus() { | |||
| } | |||
| if result != nil { | |||
| oldStatus := task.Status | |||
| task.Status = modelarts.TransTrainJobStatus(result.IntStatus) | |||
| task.Duration = result.Duration / 1000 | |||
| task.TrainJobDuration = result.TrainJobDuration | |||
| @@ -1789,6 +2088,9 @@ func SyncCloudbrainStatus() { | |||
| task.EndTime = task.StartTime.Add(task.Duration) | |||
| } | |||
| task.CorrectCreateUnix() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| @@ -1809,6 +2111,7 @@ func SyncCloudbrainStatus() { | |||
| if len(result.JobInfo.Tasks[0].CenterID) == 1 && len(result.JobInfo.Tasks[0].CenterName) == 1 { | |||
| task.AiCenter = result.JobInfo.Tasks[0].CenterID[0] + "+" + result.JobInfo.Tasks[0].CenterName[0] | |||
| } | |||
| oldStatus := task.Status | |||
| task.Status = grampus.TransTrainJobStatus(result.JobInfo.Status) | |||
| task.Duration = result.JobInfo.RunSec | |||
| task.TrainJobDuration = models.ConvertDurationToStr(task.Duration) | |||
| @@ -1820,6 +2123,9 @@ func SyncCloudbrainStatus() { | |||
| task.EndTime = task.StartTime.Add(task.Duration) | |||
| } | |||
| task.CorrectCreateUnix() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| @@ -1,15 +1,8 @@ | |||
| package repo | |||
| import ( | |||
| "code.gitea.io/gitea/modules/auth" | |||
| "code.gitea.io/gitea/modules/git" | |||
| "code.gitea.io/gitea/modules/grampus" | |||
| "code.gitea.io/gitea/modules/modelarts" | |||
| "code.gitea.io/gitea/modules/timeutil" | |||
| "code.gitea.io/gitea/modules/util" | |||
| "encoding/json" | |||
| "errors" | |||
| "github.com/unknwon/com" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "os" | |||
| @@ -18,6 +11,15 @@ import ( | |||
| "strings" | |||
| "time" | |||
| "code.gitea.io/gitea/modules/auth" | |||
| "code.gitea.io/gitea/modules/git" | |||
| "code.gitea.io/gitea/modules/grampus" | |||
| "code.gitea.io/gitea/modules/modelarts" | |||
| "code.gitea.io/gitea/modules/notification" | |||
| "code.gitea.io/gitea/modules/timeutil" | |||
| "code.gitea.io/gitea/modules/util" | |||
| "github.com/unknwon/com" | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/base" | |||
| "code.gitea.io/gitea/modules/cloudbrain" | |||
| @@ -136,6 +138,93 @@ func grampusTrainJobNewDataPrepare(ctx *context.Context, processType string) err | |||
| return nil | |||
| } | |||
| func grampusTrainJobErrorPrepare(ctx *context.Context, processType string, form auth.CreateGrampusTrainJobForm) error { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| //get valid images | |||
| images, err := grampus.GetImages(processType) | |||
| if err != nil { | |||
| log.Error("GetImages failed:", err.Error()) | |||
| } else { | |||
| ctx.Data["images"] = images.Infos | |||
| } | |||
| grampus.InitSpecialPool() | |||
| ctx.Data["GPUEnabled"] = true | |||
| ctx.Data["NPUEnabled"] = true | |||
| includeCenters := make(map[string]struct{}) | |||
| excludeCenters := make(map[string]struct{}) | |||
| if grampus.SpecialPools != nil { | |||
| for _, pool := range grampus.SpecialPools.Pools { | |||
| if pool.IsExclusive { | |||
| if !IsUserInOrgPool(ctx.User.ID, pool) { | |||
| ctx.Data[pool.Type+"Enabled"] = false | |||
| } | |||
| } else { | |||
| if strings.Contains(strings.ToLower(processType), strings.ToLower(pool.Type)) { | |||
| if IsUserInOrgPool(ctx.User.ID, pool) { | |||
| for _, center := range pool.Pool { | |||
| includeCenters[center.Queue] = struct{}{} | |||
| } | |||
| } else { | |||
| for _, center := range pool.Pool { | |||
| excludeCenters[center.Queue] = struct{}{} | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| //get valid resource specs | |||
| specs, err := grampus.GetResourceSpecs(processType) | |||
| grampusSpecs := getFilterSpecBySpecialPool(specs, includeCenters, excludeCenters) | |||
| if err != nil { | |||
| log.Error("GetResourceSpecs failed:", err.Error()) | |||
| } else { | |||
| ctx.Data["flavor_infos"] = grampusSpecs | |||
| } | |||
| if processType == grampus.ProcessorTypeGPU { | |||
| ctx.Data["datasetType"] = models.TypeCloudBrainOne | |||
| } else if processType == grampus.ProcessorTypeNPU { | |||
| ctx.Data["datasetType"] = models.TypeCloudBrainTwo | |||
| } | |||
| var Parameters modelarts.Parameters | |||
| if err := json.Unmarshal([]byte(form.Params), &Parameters); err != nil { | |||
| ctx.ServerError("json.Unmarshal failed:", err) | |||
| return err | |||
| } | |||
| ctx.Data["params"] = Parameters.Parameter | |||
| ctx.Data["boot_file"] = form.BootFile | |||
| ctx.Data["attachment"] = form.Attachment | |||
| _, datasetNames, err := models.GetDatasetInfo(form.Attachment) | |||
| if err != nil { | |||
| log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) | |||
| return nil | |||
| } | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["branch_name"] = form.BranchName | |||
| ctx.Data["image_id"] = form.ImageID | |||
| ctx.Data["display_job_name"] = form.DisplayJobName | |||
| ctx.Data["image"] = form.Image | |||
| ctx.Data["flavor"] = form.FlavorID | |||
| ctx.Data["flavor_name"] = form.FlavorName | |||
| ctx.Data["description"] = form.Description | |||
| ctx.Data["engine_name"] = form.EngineName | |||
| ctx.Data["work_server_number"] = form.WorkServerNumber | |||
| return nil | |||
| } | |||
| func getFilterSpecBySpecialPool(specs *models.GetGrampusResourceSpecsResult, includeCenters map[string]struct{}, excludeCenters map[string]struct{}) []models.GrampusSpec { | |||
| if len(includeCenters) == 0 && len(excludeCenters) == 0 { | |||
| return specs.Infos | |||
| @@ -206,14 +295,14 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| image := strings.TrimSpace(form.Image) | |||
| if !jobNamePattern.MatchString(displayJobName) { | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| errStr := checkSpecialPool(ctx, "GPU") | |||
| if errStr != "" { | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr(errStr, tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -222,13 +311,13 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.GPUResource) | |||
| if err != nil { | |||
| log.Error("GetGrampusCountByUserID failed:%v", err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("system error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } else { | |||
| if count >= 1 { | |||
| log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -237,7 +326,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| //check param | |||
| if err := grampusParamCheckCreateTrainJob(form); err != nil { | |||
| log.Error("paramCheckCreateTrainJob failed:(%v)", err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr(err.Error(), tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -247,14 +336,14 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| if err == nil { | |||
| if len(tasks) != 0 { | |||
| log.Error("the job name did already exist", ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("the job name did already exist", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| } else { | |||
| if !models.IsErrJobNotExist(err) { | |||
| log.Error("system error, %v", err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("system error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -264,7 +353,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| attachment, err := models.GetAttachmentByUUID(uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID failed:", err.Error(), ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("dataset is not exist", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -277,7 +366,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| if err := downloadZipCode(ctx, codeLocalPath, branchName); err != nil { | |||
| log.Error("downloadZipCode failed, server timed out: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -286,7 +375,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| //upload code | |||
| if err := uploadCodeToMinio(codeLocalPath+"/", jobName, cloudbrain.CodeMountPath+"/"); err != nil { | |||
| log.Error("Failed to uploadCodeToMinio: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -294,7 +383,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| modelPath := setting.JobPath + jobName + cloudbrain.ModelMountPath + "/" | |||
| if err := mkModelPath(modelPath); err != nil { | |||
| log.Error("Failed to mkModelPath: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -302,7 +391,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| //init model readme | |||
| if err := uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/"); err != nil { | |||
| log.Error("Failed to uploadCodeToMinio: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -311,7 +400,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| command, err := generateCommand(repo.Name, grampus.ProcessorTypeGPU, codeMinioPath+cloudbrain.DefaultBranchName+".zip", dataMinioPath, bootFile, params, setting.CBCodePathPrefix+jobName+cloudbrain.ModelMountPath+"/", attachment.Name) | |||
| if err != nil { | |||
| log.Error("Failed to generateCommand: %s (%v)", displayJobName, err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -343,7 +432,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| err = grampus.GenerateTrainJob(ctx, req) | |||
| if err != nil { | |||
| log.Error("GenerateTrainJob failed:%v", err.Error(), ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) | |||
| ctx.RenderWithErr(err.Error(), tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -390,14 +479,14 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| engineName := form.EngineName | |||
| if !jobNamePattern.MatchString(displayJobName) { | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| errStr := checkSpecialPool(ctx, "NPU") | |||
| if errStr != "" { | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr(errStr, tplGrampusTrainJobGPUNew, &form) | |||
| return | |||
| } | |||
| @@ -406,13 +495,13 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.NPUResource) | |||
| if err != nil { | |||
| log.Error("GetGrampusCountByUserID failed:%v", err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("system error", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } else { | |||
| if count >= 1 { | |||
| log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -421,7 +510,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| //check param | |||
| if err := grampusParamCheckCreateTrainJob(form); err != nil { | |||
| log.Error("paramCheckCreateTrainJob failed:(%v)", err) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr(err.Error(), tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -431,14 +520,14 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| if err == nil { | |||
| if len(tasks) != 0 { | |||
| log.Error("the job name did already exist", ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("the job name did already exist", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| } else { | |||
| if !models.IsErrJobNotExist(err) { | |||
| log.Error("system error, %v", err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("system error", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -448,7 +537,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| attachment, err := models.GetAttachmentByUUID(uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID failed:", err.Error(), ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("dataset is not exist", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -461,7 +550,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| if err := downloadZipCode(ctx, codeLocalPath, branchName); err != nil { | |||
| log.Error("downloadZipCode failed, server timed out: %s (%v)", repo.FullName(), err) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("Create task failed, server timed out", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -469,14 +558,14 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| //todo: upload code (send to file_server todo this work?) | |||
| if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath); err != nil { | |||
| log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("Failed to obsMkdir_output", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | |||
| log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("Failed to uploadCodeToObs", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -485,7 +574,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| command, err := generateCommand(repo.Name, grampus.ProcessorTypeNPU, codeObsPath+cloudbrain.DefaultBranchName+".zip", dataObsPath+"'"+attachment.Name+"'", bootFile, params, setting.CodePathPrefix+jobName+modelarts.OutputPath, attachment.Name) | |||
| if err != nil { | |||
| log.Error("Failed to generateCommand: %s (%v)", displayJobName, err, ctx.Data["MsgID"]) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -521,7 +610,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain | |||
| err = grampus.GenerateTrainJob(ctx, req) | |||
| if err != nil { | |||
| log.Error("GenerateTrainJob failed:%v", err.Error()) | |||
| grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) | |||
| grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) | |||
| ctx.RenderWithErr(err.Error(), tplGrampusTrainJobNPUNew, &form) | |||
| return | |||
| } | |||
| @@ -550,12 +639,15 @@ func GrampusStopJob(ctx *context.Context) { | |||
| errorMsg = res.ErrorMsg | |||
| break | |||
| } | |||
| oldStatus := task.Status | |||
| task.Status = string(models.GrampusStatusStopped) | |||
| if task.EndTime == 0 { | |||
| task.EndTime = timeutil.TimeStampNow() | |||
| } | |||
| task.ComputeAndSetDuration() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) | |||
| @@ -626,7 +718,7 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||
| task, err := models.GetCloudbrainByJobIDWithDeleted(ctx.Params(":jobid")) | |||
| if err != nil { | |||
| log.Error("GetCloudbrainByJobID failed:" + err.Error()) | |||
| ctx.ServerError("system error", err) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| @@ -634,14 +726,15 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||
| result, err := grampus.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Error("GetJob failed:" + err.Error()) | |||
| //ctx.ServerError("GetJob failed", err) | |||
| //return | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if result != nil { | |||
| if len(result.JobInfo.Tasks[0].CenterID) == 1 && len(result.JobInfo.Tasks[0].CenterName) == 1 { | |||
| task.AiCenter = result.JobInfo.Tasks[0].CenterID[0] + "+" + result.JobInfo.Tasks[0].CenterName[0] | |||
| } | |||
| oldStatus := task.Status | |||
| task.Status = grampus.TransTrainJobStatus(result.JobInfo.Status) | |||
| if task.Status != result.JobInfo.Status || result.JobInfo.Status == models.GrampusStatusRunning { | |||
| task.Duration = result.JobInfo.RunSec | |||
| @@ -654,6 +747,9 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||
| task.EndTime = task.StartTime.Add(task.Duration) | |||
| } | |||
| task.CorrectCreateUnix() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob failed:" + err.Error()) | |||
| @@ -257,27 +257,29 @@ func NotebookShow(ctx *context.Context) { | |||
| var ID = ctx.Params(":id") | |||
| task, err := models.GetCloudbrainByIDWithDeleted(ID) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | |||
| log.Error("GET job error", err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| result, err := modelarts.GetNotebook2(task.JobID) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | |||
| log.Error("GET job error", err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if result != nil { | |||
| if task.DeletedAt.IsZero() { //normal record | |||
| if task.Status != result.Status { | |||
| oldStatus := task.Status | |||
| task.Status = result.Status | |||
| models.ParseAndSetDurationFromModelArtsNotebook(result, task) | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | |||
| log.Error("GET job error", err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| } | |||
| @@ -510,11 +512,15 @@ func NotebookManage(ctx *context.Context) { | |||
| ID = strconv.FormatInt(newTask.ID, 10) | |||
| notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, ID, task.DisplayJobName, models.ActionCreateDebugNPUTask) | |||
| } else { | |||
| oldStatus := task.Status | |||
| task.Status = res.Status | |||
| if task.EndTime == 0 && models.IsModelArtsDebugJobTerminal(task.Status) { | |||
| task.EndTime = timeutil.TimeStampNow() | |||
| } | |||
| task.ComputeAndSetDuration() | |||
| if oldStatus != task.Status { | |||
| notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||
| } | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) | |||
| @@ -539,7 +545,7 @@ func NotebookDel(ctx *context.Context) { | |||
| var listType = ctx.Query("debugListType") | |||
| task := ctx.Cloudbrain | |||
| if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) { | |||
| if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsDeleted) { | |||
| log.Error("the job(%s) has not been stopped", task.JobName) | |||
| ctx.RenderWithErr("the job has not been stopped", tplDebugJobIndex, nil) | |||
| return | |||
| @@ -772,6 +778,12 @@ func trainJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArts | |||
| ctx.Data["config_list"] = configList.ParaConfigs | |||
| ctx.Data["bootFile"] = form.BootFile | |||
| ctx.Data["uuid"] = form.Attachment | |||
| _, datasetNames, err := models.GetDatasetInfo(form.Attachment) | |||
| if err != nil { | |||
| log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) | |||
| return nil | |||
| } | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["branch_name"] = form.BranchName | |||
| ctx.Data["datasetType"] = models.TypeCloudBrainTwo | |||
| @@ -1643,7 +1655,11 @@ func TrainJobShow(ctx *context.Context) { | |||
| if err != nil { | |||
| log.Error("GetVersionListTasks(%s) failed:%v", jobID, err.Error()) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if len(VersionListTasks) == 0 { | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| //设置权限 | |||
| @@ -2276,6 +2292,12 @@ func inferenceJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModel | |||
| ctx.Data["config_list"] = configList.ParaConfigs | |||
| ctx.Data["bootFile"] = form.BootFile | |||
| ctx.Data["uuid"] = form.Attachment | |||
| _, datasetNames, err := models.GetDatasetInfo(form.Attachment) | |||
| if err != nil { | |||
| log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) | |||
| return nil | |||
| } | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["branch_name"] = form.BranchName | |||
| ctx.Data["model_name"] = form.ModelName | |||
| ctx.Data["model_version"] = form.ModelVersion | |||
| @@ -2297,7 +2319,7 @@ func InferenceJobShow(ctx *context.Context) { | |||
| if err != nil { | |||
| log.Error("GetInferenceTask(%s) failed:%v", jobID, err.Error()) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsInferenceJobShow, nil) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| //设置权限 | |||
| @@ -1016,6 +1016,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }, context.RepoAssignment(), context.RepoMustNotBeArchived(), reqRepoAdmin) | |||
| m.Group("/image/:id", func() { | |||
| m.Get("", repo.GetImage) | |||
| m.Get("/:from", cloudbrain.AdminOrImageCreaterRight, repo.CloudBrainImageEdit) | |||
| m.Post("", cloudbrain.AdminOrImageCreaterRight, bindIgnErr(auth.EditImageCloudBrainForm{}), repo.CloudBrainImageEditPost) | |||
| m.Delete("", cloudbrain.AdminOrImageCreaterRight, repo.CloudBrainImageDelete) | |||
| @@ -313,9 +313,8 @@ func searchRepo(ctx *context.Context, TableName string, Key string, Page int, Pa | |||
| res, err := client.Search(TableName).Query(boolQ).SortBy(getSort(SortBy, ascending, "num_stars", false)...).From(from).Size(Size).Highlight(queryHighlight("alias", "description", "topics")).Do(ctx.Req.Context()) | |||
| if err == nil { | |||
| searchJson, _ := json.Marshal(res) | |||
| log.Info("searchJson=" + string(searchJson)) | |||
| esresult := makeRepoResult(res, Key, OnlyReturnNum, language) | |||
| setForkRepoOrder(esresult) | |||
| resultObj.Total = resultObj.PrivateTotal + esresult.Total | |||
| isNeedSort := false | |||
| if len(resultObj.Result) > 0 { | |||
| @@ -348,6 +347,30 @@ func searchRepo(ctx *context.Context, TableName string, Key string, Page int, Pa | |||
| } | |||
| } | |||
| func setForkRepoOrder(esresult *SearchRes) { | |||
| forkidMap := make(map[string]int, 0) | |||
| for index, re := range esresult.Result { | |||
| if re["fork_id"] != nil { | |||
| fork_id := re["fork_id"].(string) | |||
| if _, ok := forkidMap[fork_id]; !ok { | |||
| forkidMap[fork_id] = index | |||
| } | |||
| } | |||
| } | |||
| for key, value := range forkidMap { | |||
| for index, re := range esresult.Result { | |||
| if re["id"].(string) == key { | |||
| if value < index { //swap | |||
| tmp := esresult.Result[index] | |||
| esresult.Result[index] = esresult.Result[value] | |||
| esresult.Result[value] = tmp | |||
| break | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| func sortRepo(Result []map[string]interface{}, SortBy string, ascending bool) { | |||
| orderBy := "" | |||
| switch SortBy { | |||
| @@ -479,6 +502,7 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool, | |||
| record["num_stars"] = recordSource["num_stars"] | |||
| record["num_forks"] = recordSource["num_forks"] | |||
| record["lower_alias"] = recordSource["lower_alias"] | |||
| record["fork_id"] = recordSource["fork_id"] | |||
| if recordSource["topics"] != nil { | |||
| topicsStr := recordSource["topics"].(string) | |||
| log.Info("topicsStr=" + topicsStr) | |||
| @@ -116,8 +116,8 @@ func Profile(ctx *context.Context) { | |||
| } | |||
| var opts = models.FindOrgMembersOpts{ | |||
| OrgID: org.ID, | |||
| PublicOnly: true, | |||
| OrgID: org.ID, | |||
| PublicOnly: true, | |||
| } | |||
| if ctx.User != nil { | |||
| @@ -261,7 +261,7 @@ func Profile(ctx *context.Context) { | |||
| IsOwner: isOwner, | |||
| ListOptions: models.ListOptions{ | |||
| Page: page, | |||
| PageSize: setting.UI.ExplorePagingNum, | |||
| PageSize: setting.UI.User.RepoPagingNum, | |||
| }, | |||
| CloudBrainType: -1, | |||
| } | |||
| @@ -95,7 +95,7 @@ | |||
| </a> | |||
| {{else if eq .JobType "INFERENCE"}} | |||
| <a class="title" | |||
| href="{{AppSubUrl}}/{{.Repo.OwnerName}}/{{.Repo.Name}}/modelarts/inference-job/{{$JobID}}" | |||
| href="{{AppSubUrl}}/{{.Repo.OwnerName}}/{{.Repo.Name}}/{{if eq .Cloudbrain.Type 1}}modelarts{{else if eq .Cloudbrain.Type 0}}cloudbrain{{end}}/inference-job/{{$JobID}}" | |||
| title="{{.DisplayJobName}}" style="font-size: 14px;"> | |||
| <span class="fitted" | |||
| style="width: 90%;vertical-align: middle;">{{.DisplayJobName}}</span> | |||
| @@ -35,7 +35,7 @@ | |||
| {{range .Datasets}} | |||
| <tr> | |||
| <td>{{.ID}}</td> | |||
| <td style="display: flex;align-items: center;"><a href="{{AppSubUrl}}/{{.Repo.OwnerName}}/{{.Repo.Alias}}/datasets">{{.Title}}</a>{{if .Recommend}}<img src="/img/jian.svg" style="margin-left: 0.5rem;">{{end}}</td> | |||
| <td style="display: flex;align-items: center;"><a href="{{AppSubUrl}}/{{.Repo.OwnerName}}/{{.Repo.Name}}/datasets">{{.Title}}</a>{{if .Recommend}}<img src="/img/jian.svg" style="margin-left: 0.5rem;">{{end}}</td> | |||
| <td><i class="fa fa{{if .IsPrivate}}-check{{end}}-square-o"></i></td> | |||
| <td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td> | |||
| <td>{{if .Recommend}}<span class="set_dataset" style="color: rgb(250, 140, 22);cursor: pointer;" data-url="{{$.Link}}/{{.ID}}/action/unrecommend">{{$.i18n.Tr "admin.datasets.unrecommend"}}</span>{{else}}<span class="set_dataset" style="color: rgb(19, 194, 141);cursor: pointer;" data-url="{{$.Link}}/{{.ID}}/action/recommend">{{$.i18n.Tr "admin.datasets.recommend"}}</span>{{end}}</td> | |||
| @@ -48,4 +48,4 @@ | |||
| {{template "base/paginate" .}} | |||
| </div> | |||
| </div> | |||
| {{template "base/footer" .}} | |||
| {{template "base/footer" .}} | |||
| @@ -109,6 +109,11 @@ | |||
| ], | |||
| {{end}} | |||
| }; | |||
| {{if .IsSigned}} | |||
| window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); | |||
| {{else}} | |||
| window.sessionStorage.removeItem('_csrf'); | |||
| {{end}} | |||
| </script> | |||
| <link rel="shortcut icon" href="{{StaticUrlPrefix}}/img/favicon.png"> | |||
| <link rel="mask-icon" href="{{StaticUrlPrefix}}/img/openi-safari.svg" color="#609926"> | |||
| @@ -109,6 +109,11 @@ | |||
| ], | |||
| {{end}} | |||
| }; | |||
| {{if .IsSigned}} | |||
| window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); | |||
| {{else}} | |||
| window.sessionStorage.removeItem('_csrf'); | |||
| {{end}} | |||
| </script> | |||
| <link rel="shortcut icon" href="{{StaticUrlPrefix}}/img/favicon.png"> | |||
| <link rel="mask-icon" href="{{StaticUrlPrefix}}/img/openi-safari.svg" color="#609926"> | |||
| @@ -109,6 +109,11 @@ | |||
| ], | |||
| {{end}} | |||
| }; | |||
| {{if .IsSigned}} | |||
| window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); | |||
| {{else}} | |||
| window.sessionStorage.removeItem('_csrf'); | |||
| {{end}} | |||
| </script> | |||
| <link rel="shortcut icon" href="{{StaticUrlPrefix}}/img/favicon.png"> | |||
| <link rel="mask-icon" href="{{StaticUrlPrefix}}/img/openi-safari.svg" color="#609926"> | |||
| @@ -109,6 +109,11 @@ | |||
| ], | |||
| {{end}} | |||
| }; | |||
| {{if .IsSigned}} | |||
| window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); | |||
| {{else}} | |||
| window.sessionStorage.removeItem('_csrf'); | |||
| {{end}} | |||
| </script> | |||
| <link rel="shortcut icon" href="{{StaticUrlPrefix}}/img/favicon.png"> | |||
| <link rel="mask-icon" href="{{StaticUrlPrefix}}/img/openi-safari.svg" color="#609926"> | |||
| @@ -42,7 +42,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -73,7 +74,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -41,7 +41,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -71,7 +72,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -33,7 +33,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -64,7 +65,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -43,7 +43,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -74,7 +75,8 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{/* <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> */}} | |||
| <a class="item" href="{{AppSubUrl}}/kanban/index.html" target="_blank" rel="opener">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| <a class="item" href="{{AppSubUrl}}/OpenI">{{.i18n.Tr "custom.head.openi.repo"}}</a> | |||
| </div> | |||
| @@ -109,6 +109,11 @@ | |||
| ], | |||
| {{end}} | |||
| }; | |||
| {{if .IsSigned}} | |||
| window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); | |||
| {{else}} | |||
| window.sessionStorage.removeItem('_csrf'); | |||
| {{end}} | |||
| </script> | |||
| <link rel="shortcut icon" href="{{StaticUrlPrefix}}/img/favicon.png"> | |||
| <link rel="mask-icon" href="{{StaticUrlPrefix}}/img/openi-safari.svg" color="#609926"> | |||
| @@ -24,9 +24,9 @@ | |||
| <div class="ui sixteen wide mobile ten wide tablet ten wide computer colum"> | |||
| {{range .Datasets}} | |||
| <div class="item"> | |||
| <div class="ui header"> | |||
| <a class="name" href="{{.Repo.Link}}/datasets"> | |||
| {{.Repo.OwnerName}} / {{.Repo.Alias}} | |||
| <div class="ui header" style="display: flex;"> | |||
| <a class="name dataset-title-a" title="{{.Title}}" href="{{.Repo.Link}}/datasets"> | |||
| {{.Title}} | |||
| </a> | |||
| <div class="ui right metas"> | |||
| {{if .Task}} | |||
| @@ -40,7 +40,7 @@ | |||
| </div> | |||
| <div class="description"> | |||
| {{if .Description}} | |||
| <p class="has-emoji">{{.Description}}</p> | |||
| <p class="has-emoji" style="word-break: break-all;">{{.Description}}</p> | |||
| {{else if .Repo.DescriptionHTML}} | |||
| <p class="has-emoji">{{.Repo.DescriptionHTML}}</p> | |||
| {{end}} | |||
| @@ -53,4 +53,7 @@ | |||
| </div> | |||
| {{end}} | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <script> | |||
| console.log({{.Datasets}}) | |||
| </script> | |||
| @@ -48,7 +48,7 @@ | |||
| <button class="ui green button"> | |||
| {{.i18n.Tr "org.create_org"}} | |||
| </button> | |||
| <a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a> | |||
| <a class="ui button" href="javascript:history.go(-1)">{{.i18n.Tr "cancel"}}</a> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -353,7 +353,15 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-mirror"> | |||
| {{.Image}} | |||
| <span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer" | |||
| data-clipboard-text="{{.Image}}" | |||
| data-success="{{$.i18n.Tr "repo.copy_link_success"}}" | |||
| data-error="{{$.i18n.Tr "repo.copy_link_error"}}" | |||
| data-content="{{$.i18n.Tr "repo.copy_link"}}" | |||
| data-variation="inverted tiny" | |||
| > | |||
| <span title="{{.Image}}">{{.Image}}</span> | |||
| </span> | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -58,18 +58,16 @@ | |||
| <form class="ui form" action="{{.Link}}" method="post"> | |||
| {{.CsrfTokenHtml}} | |||
| <input type="hidden" name="action" value="update"> | |||
| <input type="hidden" id="ai_engine_name" name="engine_names" value=""> | |||
| <input type="hidden" id="ai_flaver_name" name="flaver_names" value=""> | |||
| {{if $.model_version}} | |||
| <input type="hidden" id="ai_model_version" name="model_version" value="{{$.model_version}}"> | |||
| {{else}} | |||
| <input type="hidden" id="ai_image_name" value="{{.image}}"> | |||
| <input type="hidden" id="ai_model_version" name="model_version" value=""> | |||
| {{end}} | |||
| {{if $.label_names}} | |||
| <input type="hidden" id="ai_model_label" name="label_names" value="{{$.label_names}}"> | |||
| {{else}} | |||
| <input type="hidden" id="ai_model_label" name="label_names" value=""> | |||
| {{end}} | |||
| <input type="hidden" id="failed_train_url" value="{{$.train_url}}"> | |||
| <input type="hidden" id="failed_model_name" value="{{$.model_name}}"> | |||
| <input type="hidden" id="failed_model_version" value="{{$.model_version}}"> | |||
| <input type="hidden" id="failed_ckpt_name" value="{{$.ckpt_name}}"> | |||
| <input type="hidden" id="failed_train_url" value="{{$.train_url}}"> | |||
| <input type="hidden" id="fail_dataset_name" value="{{$.dataset_name}}"> | |||
| <input type="hidden" id="fail_dataset_uuid" value="{{$.attachment}}"> | |||
| <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4> | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.compute_resource"}}</label> | |||
| @@ -102,7 +100,11 @@ | |||
| <div class="unite min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| {{if .description}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea> | |||
| {{else}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{end}} | |||
| </div> | |||
| <div class="ui divider"></div> | |||
| @@ -112,13 +114,8 @@ | |||
| <div class="required eight wide field"> | |||
| <label style="font-weight: normal;white-space: nowrap;width: 210px;text-align: right;">{{.i18n.Tr "repo.modelarts.infer_job.select_model"}}</label> | |||
| <div class="ui fluid search selection dropdown loading " id="select_model"> | |||
| {{if $.ckpt_name}} | |||
| <input type="hidden" name="model_name" value="{{$.model_name}}" required> | |||
| <div class="text">{{$.model_name}}</div> | |||
| {{else}} | |||
| <input type="hidden" name="model_name" required> | |||
| <div class="text"></div> | |||
| {{end}} | |||
| <i class="dropdown icon"></i> | |||
| <div class="menu" id="model_name"> | |||
| </div> | |||
| @@ -126,13 +123,8 @@ | |||
| </div> | |||
| <div class="three wide field"> | |||
| <div class="ui fluid search selection dropdown" id="select_model_version"> | |||
| {{if $.ckpt_name}} | |||
| <input type="hidden" name="train_url" value="{{$.train_url}}" required> | |||
| <div class="text">{{$.model_version}}</div> | |||
| {{else}} | |||
| <input type="hidden" name="train_url" required> | |||
| <div class="text"></div> | |||
| {{end}} | |||
| <i class="dropdown icon"></i> | |||
| <div class="menu" id="model_name_version"> | |||
| </div> | |||
| @@ -141,13 +133,8 @@ | |||
| </div> | |||
| <div class="five wide field"> | |||
| <div class="ui fluid search selection dropdown" id="select_model_checkpoint"> | |||
| {{if $.ckpt_name}} | |||
| <input type="hidden" name="ckpt_name" value="{{$.ckpt_name}}" required> | |||
| <div class="text">{{$.ckpt_name}}</div> | |||
| {{else}} | |||
| <input type="hidden" name="ckpt_name" required> | |||
| <div class="text"></div> | |||
| {{end}} | |||
| <i class="dropdown icon"></i> | |||
| <div class="menu" id="model_checkpoint"> | |||
| </div> | |||
| @@ -186,8 +173,21 @@ | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.gpu_type"}}</label> | |||
| <select id="cloudbrain_gpu_type" class="ui search width48 dropdown gpu-type" placeholder="选择GPU类型" | |||
| style='width:385px' name="gpu_type"> | |||
| {{range .inference_gpu_types}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{if .gpu_type}} | |||
| {{range .inference_gpu_types}} | |||
| {{if eq $.gpu_type .Queue}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .inference_gpu_types}} | |||
| {{if ne $.gpu_type .Queue}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .inference_gpu_types}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -196,8 +196,8 @@ | |||
| <span class="tooltips" style="margin-left: 11.5rem;margin-bottom: 1rem;"></span> | |||
| <div class="inline min_title field required"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label> | |||
| {{if .bootFile}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{if .boot_file}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{else}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" > | |||
| {{end}} | |||
| @@ -213,22 +213,22 @@ | |||
| <span id="add_run_para" style="cursor:pointer;color: rgba(3, 102, 214, 100);font-size: 14px;line-height: 26px;font-family: SourceHanSansSC-medium;"><i class="plus square outline icon"></i>{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}</span> | |||
| <input id="store_run_para" type="hidden" name="run_para_list"> | |||
| <div class="dynamic field" style="margin-top: 1rem;"> | |||
| {{if ne 0 (len .params)}} | |||
| {{range $k ,$v := .params}} | |||
| <div class="two fields width85" id="para{{$k}}"> | |||
| <div class="field"> | |||
| <input type="text" name="shipping_first-name" value={{$v.Label}} required> | |||
| </div> | |||
| <div class="field"> | |||
| <input type="text" name="shipping_last-name" value={{$v.Value}} required> | |||
| </div> | |||
| <span> | |||
| <i class="trash icon"></i> | |||
| </span> | |||
| {{if ne 0 (len .params)}} | |||
| {{range $k ,$v := .params}} | |||
| <div class="two fields width85" id="para{{$k}}"> | |||
| <div class="field"> | |||
| <input type="text" name="shipping_first-name" value={{$v.Label}} required> | |||
| </div> | |||
| <div class="field"> | |||
| <input type="text" name="shipping_last-name" value={{$v.Value}} required> | |||
| </div> | |||
| <span> | |||
| <i class="trash icon"></i> | |||
| </span> | |||
| </div> | |||
| </div> | |||
| {{end}} | |||
| {{end}} | |||
| {{end}} | |||
| </div> | |||
| </div> | |||
| @@ -244,9 +244,22 @@ | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_specification"}}</label> | |||
| <select id="cloudbrain_resource_spec" class="ui search dropdown width80" placeholder="选择资源规格" name="resource_spec_id"> | |||
| {{range .inference_resource_specs}} | |||
| <option name="resource_spec_id" value="{{.Id}}"> | |||
| GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{if .resource_spec_id}} | |||
| {{range .inference_resource_specs}} | |||
| {{if eq $.resource_spec_id .Id}} | |||
| <option value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .inference_resource_specs}} | |||
| {{if ne $.resource_spec_id .Id}} | |||
| <option value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .inference_resource_specs}} | |||
| <option name="resource_spec_id" value="{{.Id}}"> | |||
| GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -270,27 +283,35 @@ | |||
| const RepoLink = {{.RepoLink}} | |||
| let nameMap,nameList | |||
| // 获取模型列表和模型名称对应的模型版本 | |||
| $.get(`${RepoLink}/modelmanage/query_model_for_predict?type=0`, (data) => { | |||
| $(document).ready(function(){ | |||
| modelVersion() | |||
| modelCkpt() | |||
| nameMap = data.nameMap | |||
| nameList = data.nameList | |||
| let html = '' | |||
| nameList.forEach(element => { | |||
| html += `<div class="item" data-value=${element}>${element}</div>` | |||
| }); | |||
| if(nameList.length!==0){ | |||
| const initModelVersion = nameMap[nameList[0]][0] | |||
| const initTrainTaskInfo = JSON.parse(initModelVersion.TrainTaskInfo) | |||
| $('#model_name').append(html) | |||
| $("#select_model").dropdown('set text',nameList[0]) | |||
| $("#select_model").dropdown('set value',nameList[0],nameList[0]) | |||
| } | |||
| $('#select_model').removeClass("loading") | |||
| $.get(`${RepoLink}/modelmanage/query_model_for_predict?type=0`, (data) => { | |||
| nameMap = data.nameMap | |||
| nameList = data.nameList | |||
| let faildModelName = document.getElementById('failed_model_name').value | |||
| let html = '' | |||
| nameList.forEach(element => { | |||
| html += `<div class="item" data-value=${element}>${element}</div>` | |||
| }); | |||
| if(nameList.length!==0){ | |||
| $('#model_name').append(html) | |||
| if(faildModelName){ | |||
| $("#select_model").dropdown('set text',faildModelName) | |||
| $("#select_model").dropdown('set value',faildModelName) | |||
| }else{ | |||
| $("#select_model").dropdown('set text',nameList[0]) | |||
| $("#select_model").dropdown('set value',nameList[0],nameList[0]) | |||
| } | |||
| } | |||
| $('#select_model').removeClass("loading") | |||
| }) | |||
| }) | |||
| // 根据选中的模型名称获取相应的模型版本 | |||
| function modelVersion(){ | |||
| let faildModelVersion = $('#failed_model_version').val() | |||
| let faildTrainUrl = $('#failed_train_url').val() | |||
| $('#select_model').dropdown({ | |||
| onChange: function(value, text, $selectedItem) { | |||
| $("#select_model_version").addClass("loading") | |||
| @@ -305,13 +326,20 @@ | |||
| $("#select_model_version").removeClass("loading") | |||
| const initVersionText = $('#model_name_version div.item:first-child').text() | |||
| const initVersionValue = $('#model_name_version div.item:first-child').data('value') | |||
| $("#select_model_version").dropdown('set text',initVersionText) | |||
| $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| if(faildModelVersion&&faildTrainUrl){ | |||
| $("#select_model_version").dropdown('set text',faildModelVersion) | |||
| $("#select_model_version").dropdown('set value',faildTrainUrl,faildModelVersion,$('#model_name_version div.item:first-child')) | |||
| }else{ | |||
| $("#select_model_version").dropdown('set text',initVersionText) | |||
| $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| } | |||
| } | |||
| }) | |||
| } | |||
| // 根据选中的模型版本获取相应的模型权重文件 | |||
| function modelCkpt(){ | |||
| let faildCkptName = $('#failed_ckpt_name').val() | |||
| $('#select_model_version').dropdown({ | |||
| onChange: function(value, text, $selectedItem) { | |||
| const dataID = $selectedItem[0].getAttribute("data-id") | |||
| @@ -322,21 +350,23 @@ | |||
| loadCheckpointList(dataID).then((res)=>{ | |||
| res.forEach(element => { | |||
| const ckptSuffix = element.FileName.split(".") | |||
| const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7'] | |||
| const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7','pdparams','onnx','pbtxt','keras','mlmodel','cfg','pt'] | |||
| if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){ | |||
| html += `<div class="item" data-value=${element.FileName}>${element.FileName}</div>` | |||
| } | |||
| }) | |||
| $('#model_checkpoint').append(html) | |||
| $("#select_model_checkpoint").removeClass("loading") | |||
| const initVersionText = $('#model_checkpoint div.item:first-child').text() | |||
| const initVersionValue = $('#model_checkpoint div.item:first-child').data('value') | |||
| $("#select_model_checkpoint").dropdown('set text',initVersionText) | |||
| $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| if(faildCkptName){ | |||
| $("#select_model_checkpoint").dropdown('set text',faildCkptName) | |||
| $("#select_model_checkpoint").dropdown('set value',faildCkptName,faildCkptName,$('#model_name_version div.item:first-child')) | |||
| }else{ | |||
| $("#select_model_checkpoint").dropdown('set text',initVersionText) | |||
| $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| } | |||
| }) | |||
| $("input#ai_model_version").val(text) | |||
| $("input#ai_model_label").val(label) | |||
| } | |||
| @@ -397,13 +427,6 @@ | |||
| msg = JSON.stringify(msg) | |||
| $('#store_run_para').val(msg) | |||
| } | |||
| function get_name(){ | |||
| let name1=$("#engine_name .text").text() | |||
| let name2=$("#flaver_name .text").text() | |||
| $("input#ai_engine_name").val(name1) | |||
| $("input#ai_flaver_name").val(name2) | |||
| } | |||
| function validate(){ | |||
| $('.ui.form') | |||
| .form({ | |||
| @@ -421,7 +444,7 @@ | |||
| identifier : 'display_job_name', | |||
| rules: [ | |||
| { | |||
| type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[^-]$/]', | |||
| type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[a-zA-Z0-9_]$/]', | |||
| } | |||
| ] | |||
| }, | |||
| @@ -472,9 +495,8 @@ | |||
| document.getElementById("mask").style.display = "none" | |||
| } | |||
| } | |||
| validate(); | |||
| $('.ui.create_train_job.green.button').click(function(e) { | |||
| send_run_para() | |||
| get_name() | |||
| validate() | |||
| }) | |||
| </script> | |||
| @@ -381,7 +381,15 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-mirror"> | |||
| {{.Image}} | |||
| <span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer" | |||
| data-clipboard-text="{{.Image}}" | |||
| data-success="{{$.i18n.Tr "repo.copy_link_success"}}" | |||
| data-error="{{$.i18n.Tr "repo.copy_link_error"}}" | |||
| data-content="{{$.i18n.Tr "repo.copy_link"}}" | |||
| data-variation="inverted tiny" | |||
| > | |||
| <span title="{{.Image}}">{{.Image}}</span> | |||
| </span> | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -294,6 +294,27 @@ | |||
| context.value = '' | |||
| $(".icon.icons").css("visibility", "hidden") | |||
| } | |||
| function validate(){ | |||
| $('.ui.form').form({ | |||
| on: 'blur', | |||
| fields: { | |||
| display_job_name:{ | |||
| identifier : 'display_job_name', | |||
| rules: [ | |||
| { | |||
| type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]', | |||
| } | |||
| ] | |||
| }, | |||
| }, | |||
| onSuccess: function(){ | |||
| }, | |||
| onFailure: function(e){ | |||
| return false; | |||
| } | |||
| }) | |||
| } | |||
| validate(); | |||
| form.onsubmit = function (e) { | |||
| let value_task = $("input[name='display_job_name']").val() | |||
| let value_image = $("input[name='image']").val() | |||
| @@ -252,7 +252,9 @@ | |||
| </span> | |||
| <span class="cti-mgRight-sm uc-accordionTitle-black" | |||
| id="{{.VersionName}}-duration-span">{{$.duration}}</span> | |||
| <span id="refresh-status" data-tooltip="刷新" style="cursor: pointer;" data-inverted="" data-version="{{.VersionName}}"> | |||
| <i class="redo icon redo-color"></i> | |||
| </span> | |||
| </div> | |||
| </span> | |||
| </span> | |||
| @@ -390,7 +392,15 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-mirror"> | |||
| {{.Image}} | |||
| <span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer" | |||
| data-clipboard-text="{{.Image}}" | |||
| data-success="{{$.i18n.Tr "repo.copy_link_success"}}" | |||
| data-error="{{$.i18n.Tr "repo.copy_link_error"}}" | |||
| data-content="{{$.i18n.Tr "repo.copy_link"}}" | |||
| data-variation="inverted tiny" | |||
| > | |||
| <span title="{{.Image}}">{{.Image}}</span> | |||
| </span> | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -89,8 +89,7 @@ | |||
| <form class="ui form" action="{{.Link}}" method="post"> | |||
| {{.CsrfTokenHtml}} | |||
| <input type="hidden" name="action" value="update"> | |||
| <input type="hidden" id="ai_engine_name" name="engine_names" value=""> | |||
| <input type="hidden" id="ai_flaver_name" name="flaver_names" value=""> | |||
| <input type="hidden" id="ai_image_name" value="{{.image}}"> | |||
| <h4 class="train-job-title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4> | |||
| <div class="required unite min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_cluster"}}</label> | |||
| @@ -140,11 +139,11 @@ | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;" | |||
| for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" | |||
| placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} | |||
| onchange="this.value=this.value.substring(0, 255)" | |||
| onkeydown="this.value=this.value.substring(0, 255)" | |||
| onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{if .description}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea> | |||
| {{else}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{end}} | |||
| </div> | |||
| <div class="ui divider"></div> | |||
| @@ -179,13 +178,25 @@ | |||
| <option name="job_type" value="TRAIN">TRAIN</option> | |||
| </select> | |||
| </div> | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.gpu_type"}}</label> | |||
| <select id="cloudbrain_gpu_type" class="ui search width806 dropdown gpu-type" placeholder="选择GPU类型" | |||
| style='width:385px' name="gpu_type"> | |||
| {{range .train_gpu_types}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{if .gpu_type}} | |||
| {{range .train_gpu_types}} | |||
| {{if eq $.gpu_type .Queue}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .train_gpu_types}} | |||
| {{if ne $.gpu_type .Queue}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .train_gpu_types}} | |||
| <option value="{{.Queue}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -195,8 +206,8 @@ | |||
| <div class="inline field min_title required"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label> | |||
| {{if .bootFile}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" | |||
| {{if .boot_file}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" | |||
| tabindex="3" autofocus required maxlength="255"> | |||
| {{else}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" | |||
| @@ -221,7 +232,6 @@ | |||
| class="plus square outline icon"></i>{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}</span> | |||
| <input id="store_run_para" type="hidden" name="run_para_list"> | |||
| <div class="dynamic field" style="margin-top: 1rem;"> | |||
| {{if .params}} | |||
| {{if ne 0 (len .params)}} | |||
| {{range $k ,$v := .params}} | |||
| <div class="two fields width85" id="para{{$k}}"> | |||
| @@ -238,17 +248,28 @@ | |||
| </div> | |||
| {{end}} | |||
| {{end}} | |||
| {{end}} | |||
| </div> | |||
| </div> | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_specification"}}</label> | |||
| <select id="cloudbrain_resource_spec" class="ui search dropdown" placeholder="选择资源规格" | |||
| style='width:385px' name="resource_spec_id"> | |||
| {{range .train_resource_specs}} | |||
| <option name="resource_spec_id" value="{{.Id}}"> | |||
| GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{if .resource_spec_id}} | |||
| {{range .train_resource_specs}} | |||
| {{if eq $.resource_spec_id .Id}} | |||
| <option value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .train_resource_specs}} | |||
| {{if ne $.resource_spec_id .Id}} | |||
| <option value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .train_resource_specs}} | |||
| <option name="resource_spec_id" value="{{.Id}}"> | |||
| GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -476,16 +497,8 @@ | |||
| msg = JSON.stringify(msg) | |||
| $('#store_run_para').val(msg) | |||
| } | |||
| function get_name() { | |||
| let name1 = $("#engine_name .text").text() | |||
| let name2 = $("#flaver_name .text").text() | |||
| $("input#ai_engine_name").val(name1) | |||
| $("input#ai_flaver_name").val(name2) | |||
| } | |||
| validate(); | |||
| $('.ui.create_train_job.green.button').click(function (e) { | |||
| get_name() | |||
| send_run_para() | |||
| validate() | |||
| send_run_para() | |||
| }) | |||
| </script> | |||
| @@ -384,7 +384,15 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-mirror"> | |||
| {{.Image}} | |||
| <span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer" | |||
| data-clipboard-text="{{.Image}}" | |||
| data-success="{{$.i18n.Tr "repo.copy_link_success"}}" | |||
| data-error="{{$.i18n.Tr "repo.copy_link_error"}}" | |||
| data-content="{{$.i18n.Tr "repo.copy_link"}}" | |||
| data-variation="inverted tiny" | |||
| > | |||
| <span title="{{.Image}}">{{.Image}}</span> | |||
| </span> | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -176,7 +176,7 @@ | |||
| <button class="ui green button" id="submit_reponame"> | |||
| {{.i18n.Tr "repo.create_repo"}} | |||
| </button> | |||
| <a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a> | |||
| <a class="ui button" href="javascript:history.go(-1)">{{.i18n.Tr "cancel"}}</a> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -386,7 +386,7 @@ | |||
| {{$.CsrfTokenHtml}} | |||
| {{if .CanDel}} | |||
| <a id="ai-stop-{{.Cloudbrain.ID}}" | |||
| class='ui basic ai_stop {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING" "SUCCEEDED" "CREATE_FAILED"}}disabled {{else}}blue {{end}}button' | |||
| class='ui basic ai_stop {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING" "SUCCEEDED" "CREATE_FAILED" "DELETED"}}disabled {{else}}blue {{end}}button' | |||
| data-repopath="{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.Cloudbrain.ID}}/stop" | |||
| data-jobid="{{.Cloudbrain.ID}}"> | |||
| {{$.i18n.Tr "repo.stop"}} | |||
| @@ -405,7 +405,7 @@ | |||
| {{$.CsrfTokenHtml}} | |||
| {{if .CanDel}} | |||
| <a id="ai-delete-{{.Cloudbrain.ID}}" | |||
| class='ui basic ai_delete {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "SUCCEEDED" "CREATE_FAILED"}}blue {{else}}disabled {{end}}button' | |||
| class='ui basic ai_delete {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "SUCCEEDED" "CREATE_FAILED" "DELETED"}}blue {{else}}disabled {{end}}button' | |||
| style="border-radius: .28571429rem;"> | |||
| {{$.i18n.Tr "repo.delete"}} | |||
| </a> | |||
| @@ -427,6 +427,7 @@ | |||
| {{if .CanDebug}} | |||
| <a id="model-image-{{.Cloudbrain.ID}}" | |||
| class='imageBtn ui basic {{if ne .Status "RUNNING"}}disabled {{else}}blue {{end}}button' | |||
| target="_blank" | |||
| href="{{$.RepoLink}}/cloudbrain/{{.Cloudbrain.ID}}/commit_image">{{$.i18n.Tr "repo.submit_image"}}</a> | |||
| {{else}} | |||
| <a | |||
| @@ -80,8 +80,9 @@ | |||
| <form class="ui form" action="{{.Link}}" method="post"> | |||
| {{.CsrfTokenHtml}} | |||
| <input type="hidden" name="action" value="update"> | |||
| <input type="hidden" id="ai_engine_name" name="engine_names" value=""> | |||
| <input type="hidden" id="ai_flavor_name" name="flavor_name" value=""> | |||
| <input type="hidden" id="ai_image_name" value="{{.image}}"> | |||
| <input type="hidden" id="fail_dataset_name" value="{{$.dataset_name}}"> | |||
| <input type="hidden" id="fail_dataset_uuid" value="{{$.attachment}}"> | |||
| <h4 class="train-job-title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4> | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_cluster"}}</label> | |||
| @@ -123,7 +124,11 @@ | |||
| <div class="min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| {{if .description}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea> | |||
| {{else}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{end}} | |||
| </div> | |||
| <div class="ui divider"></div> | |||
| @@ -156,8 +161,8 @@ | |||
| <div class="inline min_title field required"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label> | |||
| {{if .bootFile}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{if .boot_file}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{else}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" > | |||
| {{end}} | |||
| @@ -199,8 +204,21 @@ | |||
| <div class="required min_title inline field" id="flavor_name"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label> | |||
| <select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor"> | |||
| {{range .flavor_infos}} | |||
| {{if .flavor}} | |||
| {{range .flavor_infos}} | |||
| {{if eq $.flavor .ID}} | |||
| <option value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .flavor_infos}} | |||
| {{if ne $.flavor .ID}} | |||
| <option value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .flavor_infos}} | |||
| <option name="flavor" value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -426,16 +444,8 @@ | |||
| msg = JSON.stringify(msg) | |||
| $('#store_run_para').val(msg) | |||
| } | |||
| function get_name(){ | |||
| let name1=$("#engine_name .text").text() | |||
| let name2=$("#flavor_name .text").text() | |||
| $("input#ai_engine_name").val(name1) | |||
| $("input#ai_flavor_name").val(name2) | |||
| } | |||
| validate(); | |||
| $('.ui.create_train_job.green.button').click(function(e) { | |||
| get_name() | |||
| send_run_para() | |||
| validate() | |||
| }) | |||
| </script> | |||
| @@ -77,6 +77,8 @@ | |||
| <input type="hidden" name="action" value="update"> | |||
| <input type="hidden" id="ai_engine_name" name="engine_name" value=""> | |||
| <input type="hidden" id="ai_flavor_name" name="flavor_name" value=""> | |||
| <input type="hidden" id="fail_dataset_name" value="{{$.dataset_name}}"> | |||
| <input type="hidden" id="fail_dataset_uuid" value="{{$.attachment}}"> | |||
| <h4 class="train-job-title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4> | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_cluster"}}</label> | |||
| @@ -119,7 +121,11 @@ | |||
| <div class="min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| {{if .description}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea> | |||
| {{else}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{end}} | |||
| </div> | |||
| <div class="ui divider"></div> | |||
| @@ -150,16 +156,29 @@ | |||
| <div class="required min_title inline field" id="engine_name"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.mirror"}}</label> | |||
| <select class="ui dropdown width81" id="trainjob_images" name="image_id"> | |||
| {{range .images}} | |||
| <option name="image_id" value="{{.ID}}">{{.Name}}</option> | |||
| {{if .image_id}} | |||
| {{range .images}} | |||
| {{if eq $.image_id .ID}} | |||
| <option value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .images}} | |||
| {{if ne $.image_id .ID}} | |||
| <option value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .images}} | |||
| <option name="image_id" value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| <div class="inline min_title field required"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label> | |||
| {{if .bootFile}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{if .boot_file}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{else}} | |||
| <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" > | |||
| {{end}} | |||
| @@ -176,14 +195,45 @@ | |||
| <span id="add_run_para" style="margin-left: 0.5rem;cursor:pointer;color: rgba(3, 102, 214, 100);font-size: 14px;line-height: 26px;font-family: SourceHanSansSC-medium;"><i class="plus square outline icon"></i>{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}</span> | |||
| <input id="store_run_para" type="hidden" name="run_para_list"> | |||
| <div class="dynamic field" style="margin-top: 1rem;"> | |||
| {{if .params}} | |||
| {{if ne 0 (len .params)}} | |||
| {{range $k ,$v := .params}} | |||
| <div class="two fields width85" id="para{{$k}}"> | |||
| <div class="field"> | |||
| <input type="text" name="shipping_first-name" value={{$v.Label}} required> | |||
| </div> | |||
| <div class="field"> | |||
| <input type="text" name="shipping_last-name" value={{$v.Value}} required> | |||
| </div> | |||
| <span> | |||
| <i class="trash icon"></i> | |||
| </span> | |||
| </div> | |||
| {{end}} | |||
| {{end}} | |||
| {{end}} | |||
| </div> | |||
| </div> | |||
| <div class="required min_title inline field" id="flavor_name"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label> | |||
| <select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor"> | |||
| {{range .flavor_infos}} | |||
| {{if .flavor}} | |||
| {{range .flavor_infos}} | |||
| {{if eq $.flavor .ID}} | |||
| <option value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .flavor_infos}} | |||
| {{if ne $.flavor .ID}} | |||
| <option value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .flavor_infos}} | |||
| <option name="flavor" value="{{.ID}}">{{.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -425,9 +475,9 @@ | |||
| $("input#trainjob_work_server_num").val(val_server_num_select) | |||
| } | |||
| validate(); | |||
| $('.ui.create_train_job.green.button').click(function(e) { | |||
| get_name() | |||
| send_run_para() | |||
| validate() | |||
| }) | |||
| </script> | |||
| @@ -11,7 +11,7 @@ | |||
| {{template "base/alert" .}} | |||
| <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> | |||
| <label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label> | |||
| <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> | |||
| <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required autocomplete="off" /> | |||
| <span class="help"> | |||
| {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}} | |||
| <br/>{{.i18n.Tr "repo.migrate.migrate_items_options"}} | |||
| @@ -102,7 +102,7 @@ | |||
| <button class="ui green button" id="submit_reponame"> | |||
| {{.i18n.Tr "repo.migrate_repo"}} | |||
| </button> | |||
| <a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a> | |||
| <a class="ui button" href="javascript:history.go(-1)">{{.i18n.Tr "cancel"}}</a> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -58,16 +58,16 @@ | |||
| <input type="hidden" name="action" value="update"> | |||
| <input type="hidden" id="ai_engine_name" name="engine_names" value=""> | |||
| <input type="hidden" id="ai_flaver_name" name="flaver_names" value=""> | |||
| {{if $.model_version}} | |||
| <input type="hidden" id="ai_model_version" name="model_version" value="{{$.model_version}}"> | |||
| {{else}} | |||
| <input type="hidden" id="ai_model_version" name="model_version" value=""> | |||
| {{end}} | |||
| {{if $.label_names}} | |||
| <input type="hidden" id="ai_model_label" name="label_names" value="{{$.label_names}}"> | |||
| {{else}} | |||
| <input type="hidden" id="ai_model_label" name="label_names" value=""> | |||
| {{end}} | |||
| <input type="hidden" id="failed_train_url" value="{{$.train_url}}"> | |||
| <input type="hidden" id="failed_model_name" value="{{$.model_name}}"> | |||
| <input type="hidden" id="failed_model_version" value="{{$.model_version}}"> | |||
| <input type="hidden" id="failed_ckpt_name" value="{{$.ckpt_name}}"> | |||
| <input type="hidden" id="failed_train_url" value="{{$.train_url}}"> | |||
| <input type="hidden" id="fail_dataset_name" value="{{$.dataset_name}}"> | |||
| <input type="hidden" id="fail_dataset_uuid" value="{{$.attachment}}"> | |||
| <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4> | |||
| <div class="required min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.compute_resource"}}</label> | |||
| @@ -99,24 +99,22 @@ | |||
| </div> | |||
| <div class="min_title inline field"> | |||
| <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| {{if .description}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea> | |||
| {{else}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{end}} | |||
| </div> | |||
| <div class="ui divider"></div> | |||
| <!-- 模型相关配置 --> | |||
| <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4> | |||
| <div class="required unite inline min_title fields" style="width: 96.8%;"> | |||
| <div class="required eight wide field"> | |||
| <label style="font-weight: normal;white-space: nowrap;width: 210px;text-align: right;">{{.i18n.Tr "repo.modelarts.infer_job.select_model"}}</label> | |||
| <div class="ui fluid search selection dropdown loading " id="select_model"> | |||
| {{if $.ckpt_name}} | |||
| <input type="hidden" name="model_name" value="{{$.model_name}}" required> | |||
| <div class="text">{{$.model_name}}</div> | |||
| {{else}} | |||
| <input type="hidden" name="model_name" required> | |||
| <div class="text"></div> | |||
| {{end}} | |||
| <i class="dropdown icon"></i> | |||
| <div class="menu" id="model_name"> | |||
| </div> | |||
| @@ -124,13 +122,8 @@ | |||
| </div> | |||
| <div class="three wide field"> | |||
| <div class="ui fluid search selection dropdown" id="select_model_version"> | |||
| {{if $.ckpt_name}} | |||
| <input type="hidden" name="train_url" value="{{$.train_url}}" required> | |||
| <div class="text">{{$.model_version}}</div> | |||
| {{else}} | |||
| <input type="hidden" name="train_url" required> | |||
| <div class="text"></div> | |||
| {{end}} | |||
| <i class="dropdown icon"></i> | |||
| <div class="menu" id="model_name_version"> | |||
| </div> | |||
| @@ -139,13 +132,8 @@ | |||
| </div> | |||
| <div class="five wide field"> | |||
| <div class="ui fluid search selection dropdown" id="select_model_checkpoint"> | |||
| {{if $.ckpt_name}} | |||
| <input type="hidden" name="ckpt_name" value="{{$.ckpt_name}}" required> | |||
| <div class="text">{{$.ckpt_name}}</div> | |||
| {{else}} | |||
| <input type="hidden" name="ckpt_name" required> | |||
| <div class="text"></div> | |||
| {{end}} | |||
| <i class="dropdown icon"></i> | |||
| <div class="menu" id="model_checkpoint"> | |||
| </div> | |||
| @@ -169,9 +157,22 @@ | |||
| <div class="field" style="flex: 2;" id="engine_name"> | |||
| <select class="ui dropdown width" id="trainjob_engine_versions" name="engine_id"> | |||
| {{if .engine_id}} | |||
| {{range .engine_versions}} | |||
| <option name="engine_id" value="{{.ID}}">{{.Value}}</option> | |||
| {{if eq $.engine_id .ID}} | |||
| <option value="{{.ID}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .engine_versions}} | |||
| {{if ne $.engine_id .ID}} | |||
| <option value="{{.ID}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .engine_versions}} | |||
| <option value="{{.ID}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -251,8 +252,21 @@ | |||
| <div class="required min_title inline field" id="flaver_name"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label> | |||
| <select class="ui dropdown width80" id="trainjob-flavor" name="flavor"> | |||
| {{range .flavor_infos}} | |||
| {{if .flavor}} | |||
| {{range .flavor_infos}} | |||
| {{if eq $.flavor .Code}} | |||
| <option value="{{.Code}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .flavor_infos}} | |||
| {{if ne $.flavor .Code}} | |||
| <option value="{{.Code}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .flavor_infos}} | |||
| <option name="flavor" value="{{.Code}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -286,30 +300,38 @@ | |||
| let nameMap,nameList | |||
| $(".ui.button").attr('href',url_href) | |||
| // 获取模型列表和模型名称对应的模型版本 | |||
| $.get(`${RepoLink}/modelmanage/query_model_for_predict?type=1`, (data) => { | |||
| $(document).ready(function(){ | |||
| modelVersion() | |||
| modelCkpt() | |||
| nameMap = data.nameMap | |||
| nameList = data.nameList | |||
| let html = '' | |||
| nameList.forEach(element => { | |||
| html += `<div class="item" data-value=${element}>${element}</div>` | |||
| }); | |||
| if(nameList.length!==0){ | |||
| const initModelVersion = nameMap[nameList[0]][0] | |||
| const initTrainTaskInfo = JSON.parse(initModelVersion.TrainTaskInfo) | |||
| $('#model_name').append(html) | |||
| $("#select_model").dropdown('set text',nameList[0]) | |||
| $("#select_model").dropdown('set value',nameList[0],nameList[0]) | |||
| } | |||
| $('#select_model').removeClass("loading") | |||
| $.get(`${RepoLink}/modelmanage/query_model_for_predict?type=1`, (data) => { | |||
| nameMap = data.nameMap | |||
| nameList = data.nameList | |||
| let faildModelName = document.getElementById('failed_model_name').value | |||
| let html = '' | |||
| nameList.forEach(element => { | |||
| html += `<div class="item" data-value=${element}>${element}</div>` | |||
| }); | |||
| if(nameList.length!==0){ | |||
| $('#model_name').append(html) | |||
| if(faildModelName){ | |||
| $("#select_model").dropdown('set text',faildModelName) | |||
| $("#select_model").dropdown('set value',faildModelName) | |||
| }else{ | |||
| $("#select_model").dropdown('set text',nameList[0]) | |||
| $("#select_model").dropdown('set value',nameList[0],nameList[0]) | |||
| } | |||
| } | |||
| $('#select_model').removeClass("loading") | |||
| }) | |||
| }) | |||
| // 根据选中的模型名称获取相应的模型版本 | |||
| function modelVersion(){ | |||
| let faildModelVersion = $('#failed_model_version').val() | |||
| let faildTrainUrl = $('#failed_train_url').val() | |||
| $('#select_model').dropdown({ | |||
| onChange: function(value, text, $selectedItem) { | |||
| console.log("-----------------") | |||
| $("#select_model_version").addClass("loading") | |||
| $('#model_name_version').empty() | |||
| let html = '' | |||
| @@ -322,13 +344,20 @@ | |||
| $("#select_model_version").removeClass("loading") | |||
| const initVersionText = $('#model_name_version div.item:first-child').text() | |||
| const initVersionValue = $('#model_name_version div.item:first-child').data('value') | |||
| $("#select_model_version").dropdown('set text',initVersionText) | |||
| $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| if(faildModelVersion&&faildTrainUrl){ | |||
| $("#select_model_version").dropdown('set text',faildModelVersion) | |||
| $("#select_model_version").dropdown('set value',faildTrainUrl,faildModelVersion,$('#model_name_version div.item:first-child')) | |||
| }else{ | |||
| $("#select_model_version").dropdown('set text',initVersionText) | |||
| $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| } | |||
| } | |||
| }) | |||
| } | |||
| // 根据选中的模型版本获取相应的模型权重文件 | |||
| function modelCkpt(){ | |||
| let faildCkptName = $('#failed_ckpt_name').val() | |||
| $('#select_model_version').dropdown({ | |||
| onChange: function(value, text, $selectedItem) { | |||
| const dataID = $selectedItem[0].getAttribute("data-id") | |||
| @@ -339,21 +368,23 @@ | |||
| loadCheckpointList(dataID).then((res)=>{ | |||
| res.forEach(element => { | |||
| const ckptSuffix = element.FileName.split(".") | |||
| const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7'] | |||
| const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7','pdparams','onnx','pbtxt','keras','mlmodel','cfg','pt'] | |||
| if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){ | |||
| html += `<div class="item" data-value=${element.FileName}>${element.FileName}</div>` | |||
| } | |||
| }) | |||
| $('#model_checkpoint').append(html) | |||
| $("#select_model_checkpoint").removeClass("loading") | |||
| const initVersionText = $('#model_checkpoint div.item:first-child').text() | |||
| const initVersionValue = $('#model_checkpoint div.item:first-child').data('value') | |||
| $("#select_model_checkpoint").dropdown('set text',initVersionText) | |||
| $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| if(faildCkptName){ | |||
| $("#select_model_checkpoint").dropdown('set text',faildCkptName) | |||
| $("#select_model_checkpoint").dropdown('set value',faildCkptName,faildCkptName,$('#model_name_version div.item:first-child')) | |||
| }else{ | |||
| $("#select_model_checkpoint").dropdown('set text',initVersionText) | |||
| $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) | |||
| } | |||
| }) | |||
| $("input#ai_model_version").val(text) | |||
| $("input#ai_model_label").val(label) | |||
| } | |||
| @@ -419,7 +450,6 @@ | |||
| let name2=$("#flaver_name .text").text() | |||
| $("input#ai_engine_name").val(name1) | |||
| $("input#ai_flaver_name").val(name2) | |||
| } | |||
| function validate(){ | |||
| $('.ui.form') | |||
| @@ -438,7 +468,7 @@ | |||
| identifier : 'display_job_name', | |||
| rules: [ | |||
| { | |||
| type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[^-]$/]', | |||
| type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[a-zA-Z0-9_]$/]', | |||
| } | |||
| ] | |||
| }, | |||
| @@ -489,9 +519,9 @@ | |||
| document.getElementById("mask").style.display = "none" | |||
| } | |||
| } | |||
| validate(); | |||
| $('.ui.create_train_job.green.button').click(function(e) { | |||
| send_run_para() | |||
| get_name() | |||
| validate() | |||
| }) | |||
| </script> | |||
| @@ -110,6 +110,28 @@ | |||
| $('#messageInfo').css('display','none') | |||
| function validate(){ | |||
| $('.ui.form').form({ | |||
| on: 'blur', | |||
| fields: { | |||
| display_job_name:{ | |||
| identifier : 'display_job_name', | |||
| rules: [ | |||
| { | |||
| type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,36}$/]', | |||
| } | |||
| ] | |||
| }, | |||
| }, | |||
| onSuccess: function(){ | |||
| }, | |||
| onFailure: function(e){ | |||
| return false; | |||
| } | |||
| }) | |||
| } | |||
| validate(); | |||
| form.onsubmit = function(e){ | |||
| let value_task = $("input[name='display_job_name']").val() | |||
| @@ -257,7 +257,9 @@ | |||
| class="cti-mgRight-sm">{{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}:</span> | |||
| <span class="cti-mgRight-sm uc-accordionTitle-black" | |||
| id="{{.VersionName}}-duration-span">{{$.duration}}</span> | |||
| <span id="refresh-status" data-tooltip="刷新" style="cursor: pointer;" data-inverted="" data-version="{{.VersionName}}"> | |||
| <i class="redo icon redo-color"></i> | |||
| </span> | |||
| </div> | |||
| </span> | |||
| </span> | |||
| @@ -357,7 +359,15 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-mirror"> | |||
| {{.Image}} | |||
| <span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer" | |||
| data-clipboard-text="{{.Image}}" | |||
| data-success="{{$.i18n.Tr "repo.copy_link_success"}}" | |||
| data-error="{{$.i18n.Tr "repo.copy_link_error"}}" | |||
| data-content="{{$.i18n.Tr "repo.copy_link"}}" | |||
| data-variation="inverted tiny" | |||
| > | |||
| <span title="{{.Image}}">{{.Image}}</span> | |||
| </span> | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -128,7 +128,11 @@ | |||
| <div class="inline min_title field"> | |||
| <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | |||
| {{if .description}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea> | |||
| {{else}} | |||
| <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||
| {{end}} | |||
| </div> | |||
| <div class="ui divider"></div> | |||
| @@ -170,9 +174,22 @@ | |||
| <div class="field" style="flex: 2;" id="engine_name"> | |||
| <select class="ui dropdown width" id="trainjob_engine_versions" name="engine_id"> | |||
| {{if .engine_id}} | |||
| {{range .engine_versions}} | |||
| <option name="engine_id" value="{{.ID}}">{{.Value}}</option> | |||
| {{if eq $.engine_id .ID}} | |||
| <option value="{{.ID}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .engine_versions}} | |||
| {{if ne $.engine_id .ID}} | |||
| <option value="{{.ID}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .engine_versions}} | |||
| <option value="{{.ID}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -220,7 +237,6 @@ | |||
| </div> | |||
| </div> | |||
| <div class="required min_title field " style="display: none;"> | |||
| <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label> | |||
| <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id"> | |||
| @@ -246,12 +262,24 @@ | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="required inline min_title field" id="flaver_name"> | |||
| <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label> | |||
| <select class="ui dropdown width48" id="trainjob-flavor" name="flavor"> | |||
| {{range .flavor_infos}} | |||
| <option name="flavor" value="{{.Code}}">{{.Value}}</option> | |||
| {{if .flavor}} | |||
| {{range .flavor_infos}} | |||
| {{if eq $.flavor .Code}} | |||
| <option value="{{.Code}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{range .flavor_infos}} | |||
| {{if ne $.flavor .Code}} | |||
| <option value="{{.Code}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| {{else}} | |||
| {{range .flavor_infos}} | |||
| <option name="flavor" value="{{.Code}}">{{.Value}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -500,9 +528,9 @@ | |||
| $("input#trainjob_work_server_num").val(val_server_num_select) | |||
| } | |||
| validate(); | |||
| $('.ui.create_train_job.green.button').click(function (e) { | |||
| get_name() | |||
| send_run_para() | |||
| validate() | |||
| }) | |||
| </script> | |||
| @@ -270,7 +270,7 @@ | |||
| {{end}} | |||
| {{if .CanDel}} | |||
| <a class="ti-action-menu-item stop-show-version {{if eq .Status "KILLED" "FAILED" "START_FAILED" "KILLING" "COMPLETED"}}disabled {{end}}" | |||
| <a class="ti-action-menu-item stop-show-version {{if eq .Status "KILLED" "FAILED" "START_FAILED" "KILLING" "COMPLETED" "SUCCEEDED" "STOPPED"}}disabled {{end}}" | |||
| id="{{.VersionName}}-stop" | |||
| data-jobid="{{.JobID}}" | |||
| data-repopath="{{$.RepoRelPath}}/modelarts/train-job" | |||
| @@ -478,7 +478,7 @@ | |||
| } | |||
| function loadModelList(){ | |||
| $.get(`${repolink}/modelmanage/query_model_for_predict?repoId=${repoId}`, (data) => { | |||
| $.get(`${repolink}/modelmanage/query_model_for_predict?repoId=${repoId}&type=-1`, (data) => { | |||
| modelData = data | |||
| let nameList = data.nameList | |||
| const n_length = nameList.length | |||
| @@ -6,7 +6,8 @@ | |||
| text-align: right; | |||
| } | |||
| .inline .ui.dropdown .text { | |||
| color: rgba(0, 0, 0, .87) !important | |||
| color: rgba(0, 0, 0, .87) !important; | |||
| max-width: 360px; | |||
| } | |||
| .newtext{ | |||
| left: 15px !important | |||
| @@ -40,7 +40,7 @@ | |||
| var verifyCode = bindPhoneEl.find('input.verifyCode').val(); | |||
| if (phoneNumber && verifyCode) { | |||
| e.preventDefault(); | |||
| if (!/^1[3578]\d{9}$/.test(phoneNumber)) { | |||
| if (!/^1[3-9]\d{9}$/.test(phoneNumber)) { | |||
| bindPhoneEl.find('.ui.negative.message').show().find('p').text({{.i18n.Tr "phone.please_enter_the_correct_mobile_number"}}); | |||
| return; | |||
| } | |||
| @@ -361,4 +361,4 @@ | |||
| </div> | |||
| </div> | |||
| </div> | |||
| {{template "base/footer" .}} | |||
| {{template "base/footer" .}} | |||
| @@ -135,10 +135,10 @@ export default { | |||
| allUploadLength(len){ | |||
| if(len===this.uploadFiles.length){ | |||
| setTimeout(() => { | |||
| this.dropzoneUploader.removeAllFiles(true) | |||
| this.btnFlag = false | |||
| this.$emit('setcluster',this.btnFlag) | |||
| }, 2000); | |||
| this.dropzoneUploader.removeAllFiles(true) | |||
| this.btnFlag = false | |||
| this.$emit('setcluster',this.btnFlag) | |||
| }, 2000); | |||
| } | |||
| } | |||
| }, | |||
| @@ -254,7 +254,7 @@ export default { | |||
| (currentChunk / chunks) * | |||
| 100 | |||
| ).toFixed(2)}% (${currentChunk}/${chunks})`; | |||
| this.updateProgress(file, ((currentChunk / chunks) * 100).toFixed(2)); | |||
| // this.updateProgress(file, ((currentChunk / chunks) * 100).toFixed(2)); | |||
| loadMd5Next(); | |||
| return; | |||
| } | |||
| @@ -265,7 +265,7 @@ export default { | |||
| file.size | |||
| } 用时:${(new Date().getTime() - time) / 1000} s` | |||
| ); | |||
| this.updateProgress(file,100) | |||
| // this.updateProgress(file,100) | |||
| spark.destroy(); // 释放缓存 | |||
| file.uniqueIdentifier = md5; // 将文件md5赋值给文件唯一标识 | |||
| file.cmd5 = false; // 取消计算md5状态 | |||
| @@ -297,11 +297,11 @@ export default { | |||
| file.chunks = ''; | |||
| this.multipartUpload(file); | |||
| } else { | |||
| // 失败如何处理 | |||
| let info = "上传失败" | |||
| this.allUploadLength++ | |||
| this.uploadError(file,info) | |||
| this.allUploadFiles.push({name:file.name,status:2,info:info}) | |||
| // 失败如何处理 | |||
| let info = "上传失败" | |||
| this.allUploadLength++ | |||
| this.uploadError(file,info) | |||
| this.allUploadFiles.push({name:file.name,status:2,info:info}) | |||
| return; | |||
| } | |||
| return; | |||
| @@ -321,12 +321,16 @@ export default { | |||
| this.uploadError(file,info) | |||
| this.allUploadLength++ | |||
| this.allUploadFiles.push({name:file.name,status:1,info:info}) | |||
| return; | |||
| } | |||
| } | |||
| } | |||
| console.log('文件已上传完成'); | |||
| this.allUploadLength++ | |||
| this.allUploadFiles.push({name:file.name,status:0,info:'上传成功'}) | |||
| this.updateProgress(file, 100); | |||
| this.progress = 100; | |||
| this.status = this.dropzoneParams.data('upload-complete'); | |||
| // this.finishUpload(file); | |||
| this.finishUpload(file); | |||
| } else { | |||
| // 断点续传 | |||
| this.multipartUpload(file); | |||
| @@ -334,6 +338,10 @@ export default { | |||
| } catch (error) { | |||
| this.emitDropzoneFailed(file); | |||
| console.log(error); | |||
| let info = "上传失败" | |||
| this.allUploadLength++ | |||
| this.uploadError(file,info) | |||
| this.allUploadFiles.push({name:file.name,status:2,info:info}) | |||
| } | |||
| async function addAttachment(file) { | |||
| @@ -503,6 +511,7 @@ export default { | |||
| console.log(error); | |||
| //this.emitDropzoneFailed(file); | |||
| //console.log(error); | |||
| throw error; | |||
| } | |||
| } | |||
| @@ -538,6 +547,11 @@ export default { | |||
| await uploadChunk(e); | |||
| }catch(err){ | |||
| console.log(err) | |||
| let info = "上传失败" | |||
| this.allUploadLength++ | |||
| this.uploadError(file,info) | |||
| this.allUploadFiles.push({name:file.name,status:2,info:info}); | |||
| return; | |||
| } | |||
| fileReader.abort(); | |||
| @@ -6,7 +6,7 @@ | |||
| ref="table" | |||
| :data="tableData" | |||
| style="min-width: 100%" | |||
| row-key="ID" | |||
| row-key="rowKey" | |||
| lazy | |||
| :load="load" | |||
| :tree-props="{children: 'Children', hasChildren: 'hasChildren'}" | |||
| @@ -106,7 +106,7 @@ | |||
| <div class="space-around"> | |||
| <a :style="{visibility:!scope.row.Children ? 'visible':'hidden'}" :class="{'disabled':!scope.row.IsCanOper}" @click="showcreateVue(scope.row.Name,scope.row.Version,scope.row.Label)">创建新版本</a> | |||
| <a :href="loadhref+scope.row.ID" :class="{'disabled':!scope.row.IsCanOper}">下载</a> | |||
| <a :class="{'disabled':!scope.row.IsCanDelete}" @click="deleteModel(scope.row.ID,scope.row.cName)">删除</a> | |||
| <a :class="{'disabled':!scope.row.IsCanDelete}" @click="deleteModel(scope.row.ID,scope.row.cName,scope.row.rowKey)">删除</a> | |||
| </div> | |||
| </template> | |||
| @@ -171,6 +171,7 @@ export default { | |||
| tableData[i].EngineName = this.getEngineName(tableData[i]) | |||
| tableData[i].ComputeResource = TrainTaskInfo.ComputeResource | |||
| tableData[i].cName=tableData[i].Name | |||
| tableData[i].rowKey = tableData[i].ID + Math.random() | |||
| tableData[i].Name='' | |||
| tableData[i].VersionCount = '' | |||
| tableData[i].Children = true | |||
| @@ -310,18 +311,18 @@ export default { | |||
| const store = this.$refs.table.store | |||
| if(!this.loadNodeMap.get(row.cName)){ | |||
| const parent = store.states.data | |||
| const index = parent.findIndex(child => child.ID == row.ID) | |||
| const index = parent.findIndex(child => child.rowKey == row.rowKey) | |||
| this.getModelList() | |||
| }else{ | |||
| let {tree,treeNode,resolve} = this.loadNodeMap.get(row.cName) | |||
| const keys = Object.keys(store.states.lazyTreeNodeMap); | |||
| if(keys.includes(row.ID)){ | |||
| if(keys.includes(row.rowKey)){ | |||
| this.getModelList() | |||
| }else{ | |||
| let parentRow = store.states.data.find(child => child.cName == row.cName); | |||
| let childrenIndex = store.states.lazyTreeNodeMap[parentRow.ID].findIndex(child => child.ID == row.ID) | |||
| let childrenIndex = store.states.lazyTreeNodeMap[parentRow.rowKey].findIndex(child => child.rowKey == row.rowKey) | |||
| parentRow.VersionCount = parentRow.VersionCount-1 | |||
| const parent = store.states.lazyTreeNodeMap[parentRow.ID] | |||
| const parent = store.states.lazyTreeNodeMap[parentRow.rowKey] | |||
| if(parent.length===1){ | |||
| this.getModelList() | |||
| }else{ | |||
| @@ -331,8 +332,8 @@ export default { | |||
| } | |||
| }, | |||
| deleteModel(id,name){ | |||
| let row={cName:name,ID:id} | |||
| deleteModel(id,name,rowKey){ | |||
| let row={cName:name,ID:id, rowKey: rowKey} | |||
| let _this = this | |||
| let flag=1 | |||
| $('.ui.basic.modal.first') | |||
| @@ -379,8 +380,8 @@ export default { | |||
| } | |||
| }, | |||
| getModelList(){ | |||
| try { | |||
| this.$refs.table.store.states.lazyTreeNodeMap = {} | |||
| try { | |||
| this.loadNodeMap.clear(); | |||
| this.$axios.get(location.href+'_api',{ | |||
| params:this.params | |||
| }).then((res)=>{ | |||
| @@ -391,6 +392,7 @@ export default { | |||
| for(let i=0;i<this.tableData.length;i++){ | |||
| TrainTaskInfo = JSON.parse(this.tableData[i].TrainTaskInfo) | |||
| this.tableData[i].cName=this.tableData[i].Name | |||
| this.tableData[i].rowKey=this.tableData[i].ID + Math.random() | |||
| this.tableData[i].EngineName = this.getEngineName(this.tableData[i]) | |||
| this.tableData[i].ComputeResource = TrainTaskInfo.ComputeResource | |||
| this.tableData[i].hasChildren = res.data.data[i].VersionCount===1 ? false : true | |||
| @@ -215,16 +215,16 @@ | |||
| <div style="display:flex;align-items: center;justify-content: center;"> | |||
| <span v-if="scope.row.isPrivate" style="color: rgb(250, 140, 22);">私有</span> | |||
| <span v-else style="color: rgb(19, 194, 141);">公开</span> | |||
| <el-tooltip class="item" effect="dark" content="镜像提交中..." placement="top"> | |||
| <i v-if="scope.row.status===0" class="CREATING" style="margin-left:0.3rem"></i> | |||
| <el-tooltip v-if="scope.row.status===0" class="item" effect="dark" content="镜像提交中..." placement="top"> | |||
| <i class="CREATING" style="margin-left:0.3rem"></i> | |||
| </el-tooltip> | |||
| <el-tooltip class="item" effect="dark" content="检测提交镜像是否大小超过20G!" placement="top"> | |||
| <i v-if="scope.row.status===2" class="FAILED" style="margin-left:0.3rem"></i> | |||
| <el-tooltip v-if="scope.row.status===2" class="item" effect="dark" content="检测提交镜像是否大小超过20G!" placement="top"> | |||
| <i class="FAILED" style="margin-left:0.3rem"></i> | |||
| </el-tooltip> | |||
| <el-tooltip class="item" effect="dark" content="镜像提交成功" placement="top"> | |||
| <i v-if="scope.row.status===1" class="SUCCEEDED" style="margin-left:0.3rem"></i> | |||
| <el-tooltip v-if="scope.row.status===1" class="item" effect="dark" content="镜像提交成功" placement="top"> | |||
| <i class="SUCCEEDED" style="margin-left:0.3rem"></i> | |||
| </el-tooltip> | |||
| </div> | |||
| @@ -473,6 +473,7 @@ export default { | |||
| tableDataCustom: [], | |||
| starCustom:[], | |||
| loadingCustom:false, | |||
| refreshCustomTimer: null, | |||
| currentPageStar:1, | |||
| pageSizeStar:10, | |||
| @@ -485,6 +486,7 @@ export default { | |||
| methods: { | |||
| handleClick(tab, event) { | |||
| this.search = '' | |||
| this.stopImageListCustomRefresh(); | |||
| if(tab.name=="first"){ | |||
| this.paramsPublic.q = '' | |||
| this.getImageListPublic() | |||
| @@ -560,9 +562,31 @@ export default { | |||
| }); | |||
| this.loadingCustom = false | |||
| this.getImageListCustomRefresh() | |||
| }) | |||
| }, | |||
| getImageListCustomRefresh() { | |||
| this.stopImageListCustomRefresh(); | |||
| this.refreshCustomTimer = setInterval(() => { | |||
| this.tableDataCustom.forEach(item => { | |||
| if (item.status === 0) { | |||
| this.$axios.get(`/image/${item.id}`, {}).then((res) => { | |||
| const newData = res.data; | |||
| this.tableDataCustom.forEach(it => { | |||
| if (it.id === newData.id) { | |||
| it.status = newData.status; | |||
| } | |||
| }); | |||
| }) | |||
| } | |||
| }); | |||
| }, 5000); | |||
| }, | |||
| stopImageListCustomRefresh() { | |||
| this.refreshCustomTimer && clearInterval(this.refreshCustomTimer); | |||
| }, | |||
| getImageListStar(){ | |||
| this.loadingStar = true | |||
| this.$axios.get('/explore/images/star',{ | |||
| @@ -715,8 +739,10 @@ export default { | |||
| else{ | |||
| this.getImageListPublic() | |||
| } | |||
| }, | |||
| beforeDestroy() { | |||
| this.stopImageListCustomRefresh(); | |||
| } | |||
| }; | |||
| </script> | |||
| @@ -225,6 +225,9 @@ export default { | |||
| }, | |||
| }, | |||
| mounted() { | |||
| if (document.getElementById("ai_image_name")) { | |||
| this.imageAddress = document.getElementById("ai_image_name").value; | |||
| } | |||
| this.getImageListPublic(); | |||
| if ( | |||
| location.href.indexOf("benchmark") !== -1 || | |||
| @@ -498,6 +498,9 @@ export default { | |||
| }, | |||
| }, | |||
| mounted() { | |||
| if (document.getElementById("ai_image_name")) { | |||
| this.imageAddress = document.getElementById("ai_image_name").value; | |||
| } | |||
| this.getImageListPublic(); | |||
| if ( | |||
| location.href.indexOf("train-job") !== -1 || | |||
| @@ -1,23 +1,37 @@ | |||
| export default async function initClipboard() { | |||
| const els = document.querySelectorAll('.clipboard'); | |||
| const els = document.querySelectorAll(".clipboard"); | |||
| if (!els || !els.length) return; | |||
| const { default: ClipboardJS } = await import(/* webpackChunkName: "clipboard" */'clipboard'); | |||
| const { default: ClipboardJS } = await import( | |||
| /* webpackChunkName: "clipboard" */ "clipboard" | |||
| ); | |||
| const clipboard = new ClipboardJS(els); | |||
| clipboard.on('success', (e) => { | |||
| clipboard.on("success", (e) => { | |||
| e.clearSelection(); | |||
| $(`#${e.trigger.getAttribute('id')}`).popup('destroy'); | |||
| e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success')); | |||
| $(`#${e.trigger.getAttribute('id')}`).popup('show'); | |||
| e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); | |||
| $(`#${e.trigger.getAttribute("id")}`).popup("destroy"); | |||
| e.trigger.setAttribute( | |||
| "data-content", | |||
| e.trigger.getAttribute("data-success") | |||
| ); | |||
| $(`#${e.trigger.getAttribute("id")}`).popup("show"); | |||
| e.trigger.setAttribute( | |||
| "data-content", | |||
| e.trigger.getAttribute("data-original") | |||
| ); | |||
| }); | |||
| clipboard.on('error', (e) => { | |||
| $(`#${e.trigger.getAttribute('id')}`).popup('destroy'); | |||
| e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error')); | |||
| $(`#${e.trigger.getAttribute('id')}`).popup('show'); | |||
| e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); | |||
| clipboard.on("error", (e) => { | |||
| $(`#${e.trigger.getAttribute("id")}`).popup("destroy"); | |||
| e.trigger.setAttribute( | |||
| "data-content", | |||
| e.trigger.getAttribute("data-error") | |||
| ); | |||
| $(`#${e.trigger.getAttribute("id")}`).popup("show"); | |||
| e.trigger.setAttribute( | |||
| "data-content", | |||
| e.trigger.getAttribute("data-original") | |||
| ); | |||
| }); | |||
| } | |||
| @@ -168,14 +168,16 @@ export default async function initCloudrainSow() { | |||
| let downloadFlag = $(this).data("download-flag") || ""; | |||
| let gpuFlag = $(this).data("gpu-flag") || ""; | |||
| let version_name = $(this).data("version"); | |||
| let parents = $(this).data("parents") || ""; | |||
| let filename = $(this).data("filename") || ""; | |||
| let parents = $(this).data("parents"); | |||
| let filename = $(this).data("filename"); | |||
| let init = $(this).data("init") || ""; | |||
| let path = $(this).data("path"); | |||
| let url = `/api/v1/repos${path}?version_name=${version_name}&parentDir=${parents}`; | |||
| $.get(url, (data) => { | |||
| $(`#dir_list${version_name}`).empty(); | |||
| renderDir(path, data, version_name, downloadFlag, gpuFlag); | |||
| if(data.Dirs){ | |||
| renderDir(path, data, version_name, downloadFlag, gpuFlag); | |||
| } | |||
| if (init === "init") { | |||
| $(`input[name=model${version_name}]`).val(""); | |||
| $(`input[name=modelback${version_name}]`).val(version_name); | |||
| @@ -189,7 +191,7 @@ export default async function initCloudrainSow() { | |||
| htmlBread += "<div class='divider'> / </div>"; | |||
| $(`#file_breadcrumb${version_name}`).append(htmlBread); | |||
| } else { | |||
| renderBrend(path, version_name, parents, filename, init); | |||
| renderBrend(path, version_name, parents, filename, init, downloadFlag,gpuFlag); | |||
| } | |||
| }).fail(function (err) { | |||
| console.log(err, version_name); | |||
| @@ -217,7 +219,15 @@ export default async function initCloudrainSow() { | |||
| size = size.toFixed(0); //保留的小数位数 | |||
| return size + unitArr[index]; | |||
| } | |||
| function renderBrend(path, version_name, parents, filename, init) { | |||
| function renderBrend( | |||
| path, | |||
| version_name, | |||
| parents, | |||
| filename, | |||
| init, | |||
| downloadFlag, | |||
| gpuFlag | |||
| ) { | |||
| if (init == "folder") { | |||
| let htmlBrend = ""; | |||
| let sectionName = $( | |||
| @@ -227,11 +237,11 @@ export default async function initCloudrainSow() { | |||
| let filename1 = $(`input[name=modelback${version_name}]`).val(); | |||
| if (parents1 === "") { | |||
| $(`#file_breadcrumb${version_name} .active.section`).replaceWith( | |||
| `<a class='section load-model-file' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='' data-init='init'>${sectionName}</a>` | |||
| `<a class='section load-model-file' data-download-flag='${downloadFlag}' data-gpu-flag='${gpuFlag}' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='' data-init='init'>${sectionName}</a>` | |||
| ); | |||
| } else { | |||
| $(`#file_breadcrumb${version_name} .active.section`).replaceWith( | |||
| `<a class='section load-model-file' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='${filename1}'>${sectionName}</a>` | |||
| `<a class='section load-model-file' data-download-flag='${downloadFlag}' data-gpu-flag='${gpuFlag}' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='${filename1}'>${sectionName}</a>` | |||
| ); | |||
| } | |||
| @@ -272,7 +282,7 @@ export default async function initCloudrainSow() { | |||
| html += "<span class='octicon octicon-file-directory'>"; | |||
| html += "</span>"; | |||
| if (data.Dirs[i].IsDir) { | |||
| html += `<a class='load-model-file' data-path='${path}' data-version='${version_name}' data-parents='${data.Dirs[i].ParenDir}' data-filename='${data.Dirs[i].FileName}' data-init='folder'>`; | |||
| html += `<a class='load-model-file' data-download-flag='${downloadFlag}' data-gpu-flag='${gpuFlag}' data-path='${path}' data-version='${version_name}' data-parents='${data.Dirs[i].ParenDir}' data-filename='${data.Dirs[i].FileName}' data-init='folder'>`; | |||
| html += | |||
| "<span class='fitted'><i class='folder icon' width='16' height='16' aria-hidden='true'></i>" + | |||
| data.Dirs[i].FileName + | |||
| @@ -2950,13 +2950,13 @@ $(document).ready(async () => { | |||
| } | |||
| const $cloneAddr = $("#clone_addr"); | |||
| $cloneAddr.on("change", () => { | |||
| $cloneAddr.on("input change", () => { | |||
| const $repoName = $("#alias"); | |||
| const $owner = $("#ownerDropdown div.text").attr("title"); | |||
| const $urlAdd = | |||
| location.href.split("/")[0] + "//" + location.href.split("/")[2]; | |||
| if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { | |||
| // Only modify if repo_name input is blank | |||
| if ($cloneAddr.val().length > 0 /* && $repoName.val().length === 0 */) { | |||
| // modify when clone address change | |||
| const repoValue = $cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]; | |||
| $repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]); | |||
| $.get( | |||
| @@ -3873,6 +3873,10 @@ function initVueDataset() { | |||
| MinioUploader, | |||
| }, | |||
| mounted() { | |||
| if (document.getElementById("fail_dataset_name")) { | |||
| this.dataset_name = document.getElementById("fail_dataset_name").value; | |||
| this.dataset_uuid = document.getElementById("fail_dataset_uuid").value; | |||
| } | |||
| this.getTypeList(); | |||
| if (!!document.getElementById("dataset-repolink-init")) { | |||
| @@ -153,7 +153,7 @@ | |||
| return; | |||
| } | |||
| var phoneNumber = self.dom.find('.phone-num-c input').val(); | |||
| if (!/^1[3578]\d{9}$/.test(phoneNumber)) { | |||
| if (!/^1[3-9]\d{9}$/.test(phoneNumber)) { | |||
| self.dom.find('.phone-num-c').addClass('error'); | |||
| return; | |||
| } else { | |||
| @@ -140,27 +140,26 @@ | |||
| border: 1px solid #ffffff; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| .item { | |||
| border-bottom: 1px solid rgba(34,36,38,.15); | |||
| border-bottom: 1px solid rgba(34, 36, 38, 0.15); | |||
| .ui.buttons { | |||
| .button { | |||
| box-shadow: none !important; | |||
| } | |||
| } | |||
| } | |||
| .ui.grid > .row { | |||
| align-items: center; | |||
| } | |||
| .title { | |||
| font-size: 16px; | |||
| font-weight: bold; | |||
| margin: 0 6px; | |||
| margin: 0 6px; | |||
| overflow: hidden; | |||
| padding-right: 15px; | |||
| white-space: nowrap; | |||
| @@ -195,7 +194,15 @@ | |||
| .name { | |||
| word-break: break-all; | |||
| } | |||
| .dataset-title-a { | |||
| flex: 1; | |||
| overflow: hidden; | |||
| text-overflow: ellipsis; | |||
| min-width: 0; | |||
| word-break: inherit !important; | |||
| margin-right: 3rem; | |||
| white-space: nowrap; | |||
| } | |||
| .metas { | |||
| color: #888888; | |||
| font-size: 14px; | |||
| @@ -222,7 +229,7 @@ | |||
| } | |||
| } | |||
| } | |||
| .panel_creator_reponam{ | |||
| .panel_creator_reponam { | |||
| display: inline-block; | |||
| border-radius: 4px; | |||
| padding: 4px; | |||
| @@ -231,29 +238,28 @@ | |||
| background-color: rgba(161, 220, 255, 0.2); | |||
| color: #101010; | |||
| } | |||
| .panel_dataset_name{ | |||
| .panel_dataset_name { | |||
| font-size: 15px; | |||
| color: #0366D6; | |||
| color: #0366d6; | |||
| text-align: center; | |||
| margin-left: 1rem; | |||
| } | |||
| .panel_datset_desc{ | |||
| .panel_datset_desc { | |||
| white-space: nowrap; | |||
| display: inline-block; | |||
| overflow: hidden; | |||
| width: 90%; | |||
| text-overflow: ellipsis; | |||
| } | |||
| .el-dialog__body{ | |||
| padding-top:0 | |||
| .el-dialog__body { | |||
| padding-top: 0; | |||
| } | |||
| #dataset-base{ | |||
| .active{ | |||
| color: #0087f5!important; | |||
| border: 1px solid #0087f5!important; | |||
| #dataset-base { | |||
| .active { | |||
| color: #0087f5 !important; | |||
| border: 1px solid #0087f5 !important; | |||
| /* margin: -1px!important; */ | |||
| background: #fff!important; | |||
| background: #fff !important; | |||
| } | |||
| } | |||
| } | |||
| @@ -311,6 +311,7 @@ footer .column { | |||
| } | |||
| .FAILED, | |||
| .START_FAILED, | |||
| .DELETED, | |||
| .CREATE_FAILED { | |||
| display: inline-block; | |||
| width: 18px; | |||