@@ -611,6 +611,26 @@ type Specs struct { | |||
InterfaceType int `json:"interface_type"` | |||
} | |||
type GetConfigListResult struct { | |||
ErrorCode string `json:"error_code"` | |||
ErrorMsg string `json:"error_msg"` | |||
IsSuccess bool `json:"is_success"` | |||
ConfigTotalCount int `json:"config_total_count"` | |||
ParaConfigs []ParaConfigs `json:"configs"` | |||
} | |||
type ParaConfigs struct { | |||
ConfigName string `json:"config_name"` | |||
ConfigDesc string `json:"config_desc"` | |||
CreateTime int64 `json:"create_time"` | |||
EngineType int `json:"engine_type"` | |||
EngineName string `json:"engine_name"` | |||
EngineId int64 `json:"engine_id"` | |||
EngineVersion string `json:"engine_version"` | |||
UserImageUrl string `json:"user_image_url"` | |||
UserCommand string `json:"user_command"` | |||
} | |||
type ErrorResult struct { | |||
ErrorCode string `json:"error_code"` | |||
ErrorMsg string `json:"error_message"` | |||
@@ -48,6 +48,10 @@ const ( | |||
Lines = 20 | |||
TrainUrl = "train_url" | |||
DataUrl = "data_url" | |||
PerPage = 10 | |||
SortByCreateTime = "create_time" | |||
ConfigTypeCustom = "custom" | |||
) | |||
type GenerateTrainJobReq struct { | |||
@@ -425,22 +425,29 @@ sendjob: | |||
return &result, nil | |||
} | |||
func GetConfigList() (*models.GetResourceSpecsResult, error) { | |||
func GetConfigList(perPage, page int, sortBy, order, searchContent, configType string) (*models.GetConfigListResult, error) { | |||
checkSetting() | |||
client := getRestyClient() | |||
var result models.GetResourceSpecsResult | |||
var result models.GetConfigListResult | |||
retry := 0 | |||
sendjob: | |||
res, err := client.R(). | |||
SetHeader("Content-Type", "application/json"). | |||
SetQueryParams(map[string]string{ | |||
"per_page": strconv.Itoa(perPage), | |||
"page": strconv.Itoa(page), | |||
"sortBy": sortBy, | |||
"order": order, | |||
"search_content": searchContent, | |||
"config_type": configType, | |||
}). | |||
SetAuthToken(TOKEN). | |||
SetResult(&result). | |||
Get(HOST + "/v1/" + setting.ProjectID + urlTrainJobConfig) | |||
if err != nil { | |||
return nil, fmt.Errorf("resty GetResourceSpecs: %v", err) | |||
return nil, fmt.Errorf("resty GetConfigList: %v", err) | |||
} | |||
if res.StatusCode() == http.StatusUnauthorized && retry < 1 { | |||
@@ -455,13 +462,13 @@ sendjob: | |||
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("GetResourceSpecs failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
return &result, fmt.Errorf("GetResourceSpecs failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
log.Error("GetConfigList 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("GetResourceSpecs failed(%s): %s", result.ErrorCode, result.ErrorMsg) | |||
return &result, fmt.Errorf("GetResourceSpecs failed(%s): %s", result.ErrorCode, result.ErrorMsg) | |||
log.Error("GetConfigList failed(%s): %s", result.ErrorCode, result.ErrorMsg) | |||
return &result, fmt.Errorf("获取参数配置列表失败(%s): %s", result.ErrorCode, result.ErrorMsg) | |||
} | |||
return &result, nil | |||
@@ -497,7 +504,7 @@ sendjob: | |||
return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | |||
} | |||
log.Error("GetTrainJob failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) | |||
return &result, fmt.Errorf("GetTrainJob 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 { | |||
@@ -352,6 +352,13 @@ func TrainJobNew(ctx *context.Context) { | |||
outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath | |||
ctx.Data["train_url"] = outputObsPath | |||
configList, err := modelarts.GetConfigList(modelarts.PerPage, 1, modelarts.SortByCreateTime, "desc", "", modelarts.ConfigTypeCustom) | |||
if err != nil { | |||
ctx.ServerError("GetConfigList failed:", err) | |||
return | |||
} | |||
ctx.Data["config_list"] = configList.ParaConfigs | |||
ctx.HTML(200, tplModelArtsTrainJobNew) | |||
} | |||
@@ -447,6 +454,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
} | |||
} | |||
//save param config | |||
if isSaveParam == "on" { | |||
if form.ParameterTemplateName == "" { | |||
log.Error("ParameterTemplateName is empty") | |||
@@ -744,3 +752,35 @@ func canUserCreateTrainJob(uid int64) (bool, error) { | |||
return org.IsOrgMember(uid) | |||
} | |||
func TrainJobGetConfigList(ctx *context.Context) { | |||
ctx.Data["PageIsTrainJob"] = true | |||
var jobID = ctx.Params(":jobid") | |||
var logFileName = ctx.Query("file_name") | |||
var baseLine = ctx.Query("base_line") | |||
var order = ctx.Query("order") | |||
if order != modelarts.OrderDesc && order != modelarts.OrderAsc { | |||
log.Error("order(%s) check failed", order) | |||
ctx.HTML(http.StatusBadRequest, tplModelArtsTrainJobShow) | |||
return | |||
} | |||
task, err := models.GetCloudbrainByJobID(jobID) | |||
if err != nil { | |||
log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) | |||
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
return | |||
} | |||
result, err := modelarts.GetTrainJobLog(jobID, strconv.FormatInt(task.VersionID, 10), baseLine, logFileName, order, modelarts.Lines) | |||
if err != nil { | |||
log.Error("GetTrainJobLog(%s) failed:%v", jobID, err.Error()) | |||
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
return | |||
} | |||
ctx.Data["log"] = result | |||
//ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) | |||
} |
@@ -937,8 +937,9 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
m.Post("/del", reqRepoCloudBrainWriter, repo.TrainJobDel) | |||
m.Get("/log", reqRepoCloudBrainReader, repo.TrainJobGetLog) | |||
}) | |||
m.Get("/create", reqRepoCloudBrainWriter, repo.TrainJobNew) | |||
m.Get("/create", reqRepoCloudBrainReader, repo.TrainJobNew) | |||
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreate) | |||
m.Get("/para-config-list", reqRepoCloudBrainReader, repo.TrainJobGetConfigList) | |||
}) | |||
}, context.RepoRef()) | |||
@@ -172,8 +172,8 @@ | |||
</div> | |||
<div class="item" style="height:85%; overflow:auto;"> | |||
<div class="menu"> | |||
{{range .flavor_infos}} | |||
<a class="item">{{.Value}}</a> | |||
{{range .config_list}} | |||
<a class="item">{{.ConfigName}}</a> | |||
{{end}} | |||
</div> | |||
</div> | |||