| @@ -616,10 +616,10 @@ type GetConfigListResult struct { | |||||
| ErrorMsg string `json:"error_msg"` | ErrorMsg string `json:"error_msg"` | ||||
| IsSuccess bool `json:"is_success"` | IsSuccess bool `json:"is_success"` | ||||
| ConfigTotalCount int `json:"config_total_count"` | ConfigTotalCount int `json:"config_total_count"` | ||||
| ParaConfigs []ParaConfigs `json:"configs"` | |||||
| ParaConfigs []ParaConfig `json:"configs"` | |||||
| } | } | ||||
| type ParaConfigs struct { | |||||
| type ParaConfig struct { | |||||
| ConfigName string `json:"config_name"` | ConfigName string `json:"config_name"` | ||||
| ConfigDesc string `json:"config_desc"` | ConfigDesc string `json:"config_desc"` | ||||
| CreateTime int64 `json:"create_time"` | CreateTime int64 `json:"create_time"` | ||||
| @@ -629,6 +629,34 @@ type ParaConfigs struct { | |||||
| EngineVersion string `json:"engine_version"` | EngineVersion string `json:"engine_version"` | ||||
| UserImageUrl string `json:"user_image_url"` | UserImageUrl string `json:"user_image_url"` | ||||
| UserCommand string `json:"user_command"` | UserCommand string `json:"user_command"` | ||||
| Result GetConfigResult | |||||
| } | |||||
| type GetConfigResult struct { | |||||
| ErrorCode string `json:"error_code"` | |||||
| ErrorMsg string `json:"error_msg"` | |||||
| IsSuccess bool `json:"is_success"` | |||||
| ConfigName string `json:"config_name"` | |||||
| Description string `json:"config_desc"` | |||||
| WorkServerNum int `json:"worker_server_num"` | |||||
| AppUrl string `json:"app_url"` //训练作业的代码目录 | |||||
| BootFileUrl string `json:"boot_file_url"` //训练作业的代码启动文件,需要在代码目录下 | |||||
| Parameter []Parameter `json:"parameter"` | |||||
| DataUrl string `json:"data_url"` //训练作业需要的数据集OBS路径URL | |||||
| //DatasetID string `json:"dataset_id"` | |||||
| //DataVersionID string `json:"dataset_version_id"` | |||||
| //DataSource []DataSource `json:"data_source"` | |||||
| //SpecID int64 `json:"spec_id"` | |||||
| EngineID int64 `json:"engine_id"` | |||||
| //ModelID int64 `json:"model_id"` | |||||
| TrainUrl string `json:"train_url"` //训练作业的输出文件OBS路径URL | |||||
| LogUrl string `json:"log_url"` | |||||
| //UserImageUrl string `json:"user_image_url"` | |||||
| //UserCommand string `json:"user_command"` | |||||
| //CreateVersion bool `json:"create_version"` | |||||
| //Volumes []Volumes `json:"volumes"` | |||||
| Flavor Flavor `json:"flavor"` | |||||
| PoolID string `json:"pool_id"` | |||||
| } | } | ||||
| type ErrorResult struct { | type ErrorResult struct { | ||||
| @@ -474,6 +474,50 @@ sendjob: | |||||
| return &result, nil | return &result, nil | ||||
| } | } | ||||
| func GetParaConfig(configName, configType string) (models.GetConfigResult, error) { | |||||
| checkSetting() | |||||
| client := getRestyClient() | |||||
| var result models.GetConfigResult | |||||
| retry := 0 | |||||
| sendjob: | |||||
| res, err := client.R(). | |||||
| SetQueryParams(map[string]string{ | |||||
| "config_type": configType, | |||||
| }). | |||||
| SetAuthToken(TOKEN). | |||||
| SetResult(&result). | |||||
| Get(HOST + "/v1/" + setting.ProjectID + urlTrainJobConfig + "/" + configName) | |||||
| if err != nil { | |||||
| return result, fmt.Errorf("resty GetParaConfig: %v", err) | |||||
| } | |||||
| if res.StatusCode() == http.StatusUnauthorized && retry < 1 { | |||||
| retry++ | |||||
| _ = getToken() | |||||
| goto sendjob | |||||
| } | |||||
| if res.StatusCode() != http.StatusOK { | |||||
| var temp models.ErrorResult | |||||
| if err = json.Unmarshal([]byte(res.String()), &temp); err != nil { | |||||
| log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | |||||
| return result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | |||||
| } | |||||
| log.Error("GetParaConfig failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||||
| return result, fmt.Errorf("获取参数配置详情失败(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||||
| } | |||||
| if !result.IsSuccess { | |||||
| log.Error("GetParaConfig failed(%s): %s", result.ErrorCode, result.ErrorMsg) | |||||
| return result, fmt.Errorf("获取参数配置详情失败(%s): %s", result.ErrorCode, result.ErrorMsg) | |||||
| } | |||||
| return result, nil | |||||
| } | |||||
| func GetTrainJob(jobID, versionID string) (*models.GetTrainJobResult, error) { | func GetTrainJob(jobID, versionID string) (*models.GetTrainJobResult, error) { | ||||
| checkSetting() | checkSetting() | ||||
| client := getRestyClient() | client := getRestyClient() | ||||
| @@ -352,12 +352,14 @@ func TrainJobNew(ctx *context.Context) { | |||||
| outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath | outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath | ||||
| ctx.Data["train_url"] = outputObsPath | ctx.Data["train_url"] = outputObsPath | ||||
| configList, err := modelarts.GetConfigList(modelarts.PerPage, 1, modelarts.SortByCreateTime, "desc", "", modelarts.ConfigTypeCustom) | |||||
| configList, err := getConfigList(modelarts.PerPage, 1, modelarts.SortByCreateTime, "desc", "", modelarts.ConfigTypeCustom) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.ServerError("GetConfigList failed:", err) | |||||
| ctx.ServerError("getConfigList failed:", err) | |||||
| return | return | ||||
| } | } | ||||
| ctx.Data["config_list"] = configList.ParaConfigs | ctx.Data["config_list"] = configList.ParaConfigs | ||||
| log.Info(configList.ParaConfigs[0].ConfigName) | |||||
| ctx.HTML(200, tplModelArtsTrainJobNew) | ctx.HTML(200, tplModelArtsTrainJobNew) | ||||
| } | } | ||||
| @@ -784,3 +786,25 @@ func TrainJobGetConfigList(ctx *context.Context) { | |||||
| ctx.Data["log"] = result | ctx.Data["log"] = result | ||||
| //ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) | //ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) | ||||
| } | } | ||||
| func getConfigList(perPage, page int, sortBy, order, searchContent, configType string) (*models.GetConfigListResult, error) { | |||||
| var result models.GetConfigListResult | |||||
| list, err := modelarts.GetConfigList(perPage, page, sortBy, order, searchContent, configType) | |||||
| if err != nil { | |||||
| log.Error("GetConfigList failed:", err) | |||||
| return &result, err | |||||
| } | |||||
| for _, config := range list.ParaConfigs { | |||||
| paraConfig, err := modelarts.GetParaConfig(config.ConfigName, configType) | |||||
| if err != nil { | |||||
| log.Error("GetParaConfig failed:", err) | |||||
| return &result, err | |||||
| } | |||||
| config.Result = paraConfig | |||||
| } | |||||
| return list, nil | |||||
| } | |||||
| @@ -33,9 +33,11 @@ | |||||
| <a class="{{if .PageIsTrainJob}}active{{end}} item" href="{{.RepoLink}}/modelarts/train-job"> | <a class="{{if .PageIsTrainJob}}active{{end}} item" href="{{.RepoLink}}/modelarts/train-job"> | ||||
| {{svg "octicon-inbox" 16}} {{.i18n.Tr "repo.modelarts.train_job"}} | {{svg "octicon-inbox" 16}} {{.i18n.Tr "repo.modelarts.train_job"}} | ||||
| </a> | </a> | ||||
| <a class="{{if .PageIsParaManage}}active{{end}} item" href="{{.RepoLink}}/modelarts/train-job/para-manage"> | |||||
| <!-- | |||||
| <a class="{{if .PageIsParaManage}}active{{end}} item" href="{{.RepoLink}}/modelarts/train-job/para-manage" hidden> | |||||
| {{svg "octicon-inbox" 16}} {{.i18n.Tr "repo.modelarts.train_job_para_admin"}} | {{svg "octicon-inbox" 16}} {{.i18n.Tr "repo.modelarts.train_job_para_admin"}} | ||||
| </a> | </a> | ||||
| --> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -28,14 +28,14 @@ | |||||
| <label for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | <label for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label> | ||||
| <textarea id="description" name="description" rows="2"></textarea> | <textarea id="description" name="description" rows="2"></textarea> | ||||
| </div> | </div> | ||||
| <h4 class="ui dividing header">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}</h4> | |||||
| <!-- <h4 class="ui dividing header">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}</h4> | |||||
| <div class="inline field"> | <div class="inline field"> | ||||
| <label>{{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting"}}</label> | <label>{{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting"}}</label> | ||||
| <span> | <span> | ||||
| {{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting_config"}} | {{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting_config"}} | ||||
| <a class="item active parameter_config">{{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting_config_link"}}</a> | <a class="item active parameter_config">{{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting_config_link"}}</a> | ||||
| </span> | </span> | ||||
| </div> | |||||
| </div> --> | |||||
| <div class="required field"> | <div class="required field"> | ||||
| <label>{{.i18n.Tr "repo.modelarts.train_job.algorithm_origin"}}</label> | <label>{{.i18n.Tr "repo.modelarts.train_job.algorithm_origin"}}</label> | ||||
| <div class="ui top attached tabular menu"> | <div class="ui top attached tabular menu"> | ||||
| @@ -99,20 +99,18 @@ | |||||
| <div class="required grouped fields"> | <div class="required grouped fields"> | ||||
| <label for="resource_type">{{.i18n.Tr "repo.modelarts.train_job.resource_type"}}</label> | <label for="resource_type">{{.i18n.Tr "repo.modelarts.train_job.resource_type"}}</label> | ||||
| {{range .benchmark_categories}} | |||||
| <div class="field"> | <div class="field"> | ||||
| <div class="ui grid"> | <div class="ui grid"> | ||||
| <div class="four wide column"> | |||||
| <div class="column"> | |||||
| <div class="ui radio checkbox"> | <div class="ui radio checkbox"> | ||||
| <input type="radio" name="resource_type" checked="" tabindex="0" class="hidden"> | |||||
| <input type="radio" name="resource_type" checked="" tabindex="0"> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="four wide column">train-private-1</div> | |||||
| <div class="four wide column">{{svg "octicon-verified" 16}} 运行中</div> | |||||
| <div class="four wide column"> CPU:192 核 2048GiB</div> | |||||
| <div class="three wide column">train-private-1</div> | |||||
| <div class="three wide column">{{svg "octicon-verified" 16}} 运行中</div> | |||||
| <div class="three wide column"> CPU:192 核 2048GiB</div> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| {{end}} | |||||
| </div> | </div> | ||||
| <div class="required field"> | <div class="required field"> | ||||
| @@ -174,7 +172,7 @@ | |||||
| <div class="menu"> | <div class="menu"> | ||||
| {{range .config_list}} | {{range .config_list}} | ||||
| <a class="item">{{.ConfigName}}</a> | <a class="item">{{.ConfigName}}</a> | ||||
| {{end}} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -182,40 +180,41 @@ | |||||
| <!-- 右侧详情 --> | <!-- 右侧详情 --> | ||||
| <div class="eleven wide column content" style="height:100%"> | <div class="eleven wide column content" style="height:100%"> | ||||
| <div class="ui green segment" style="height:100%; overflow:auto;"> | <div class="ui green segment" style="height:100%; overflow:auto;"> | ||||
| <p>任务结果:</p> | |||||
| <p>配置详情:</p> | |||||
| <table class="ui celled striped table"> | <table class="ui celled striped table"> | ||||
| <tbody> | <tbody> | ||||
| <tr> | <tr> | ||||
| <td class="four wide"> {{.i18n.Tr "repo.modelarts.train_job.job_name"}} </td> | |||||
| <td></td> | |||||
| <td class="four wide"> {{$.i18n.Tr "repo.modelarts.train_job.job_name"}} </td> | |||||
| <td>{{.Result.ConfigName}}</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td> {{.i18n.Tr "repo.modelarts.train_job.description"}} </td> | |||||
| <td> {{$.i18n.Tr "repo.modelarts.train_job.description"}} </td> | |||||
| <td></td> | <td></td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td> {{.i18n.Tr "repo.modelarts.train_job.dataset"}} </td> | |||||
| <td> {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} </td> | |||||
| <td><input id="store_uuid" type="hidden" name="get_uuid"></td> | <td><input id="store_uuid" type="hidden" name="get_uuid"></td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td> {{.i18n.Tr "repo.modelarts.train_job.start_file"}} </td> | |||||
| <td> {{$.i18n.Tr "repo.modelarts.train_job.start_file"}} </td> | |||||
| <td></td> | <td></td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td> {{.i18n.Tr "repo.modelarts.train_job.run_parameter"}} </td> | |||||
| <td> {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}} </td> | |||||
| <td></td> | <td></td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td> {{.i18n.Tr "repo.modelarts.train_job.resource_pool"}} </td> | |||||
| <td> {{$.i18n.Tr "repo.modelarts.train_job.resource_pool"}} </td> | |||||
| <td><input id="store_pool_id" type="hidden" name="get_pool_id"></td> | <td><input id="store_pool_id" type="hidden" name="get_pool_id"></td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td> {{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}} </td> | |||||
| <td> {{$.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}} </td> | |||||
| <td></td> | <td></td> | ||||
| </tr> | </tr> | ||||
| </tbody> | </tbody> | ||||
| {{end}} | |||||
| </table> | </table> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||