| @@ -537,6 +537,10 @@ type Parameter struct { | |||||
| Value string `json:"value"` | Value string `json:"value"` | ||||
| } | } | ||||
| type Parameters struct { | |||||
| Parameter []Parameter `json:"parameter"` | |||||
| } | |||||
| type DataSource struct { | type DataSource struct { | ||||
| DatasetID string `json:"dataset_id"` | DatasetID string `json:"dataset_id"` | ||||
| DatasetVersion string `json:"dataset_version"` | DatasetVersion string `json:"dataset_version"` | ||||
| @@ -23,6 +23,7 @@ type CreateModelArtsTrainJobForm struct { | |||||
| EngineID int `form:"engine_id" binding:"Required"` | EngineID int `form:"engine_id" binding:"Required"` | ||||
| PoolID string `form:"pool_id" binding:"Required"` | PoolID string `form:"pool_id" binding:"Required"` | ||||
| Flavor string `form:"flavor" binding:"Required"` | Flavor string `form:"flavor" binding:"Required"` | ||||
| Params string `form:"run_para_list" binding:"Required"` | |||||
| Description string `form:"description"` | Description string `form:"description"` | ||||
| IsSaveParam string `form:"is_save_para"` | IsSaveParam string `form:"is_save_para"` | ||||
| ParameterTemplateName string `form:"parameter_template_name"` | ParameterTemplateName string `form:"parameter_template_name"` | ||||
| @@ -60,6 +60,7 @@ type GenerateTrainJobReq struct { | |||||
| PoolID string | PoolID string | ||||
| WorkServerNumber int | WorkServerNumber int | ||||
| EngineID int64 | EngineID int64 | ||||
| Parameters []models.Parameter | |||||
| } | } | ||||
| type VersionInfo struct { | type VersionInfo struct { | ||||
| @@ -156,6 +157,7 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) error { | |||||
| Flavor: models.Flavor{ | Flavor: models.Flavor{ | ||||
| Code: req.FlavorCode, | Code: req.FlavorCode, | ||||
| }, | }, | ||||
| Parameter: req.Parameters, | |||||
| }, | }, | ||||
| }) | }) | ||||
| @@ -310,9 +310,8 @@ sendjob: | |||||
| return nil, fmt.Errorf("resty create train-job: %s", err) | return nil, fmt.Errorf("resty create train-job: %s", err) | ||||
| } | } | ||||
| //log.Info("%d", res.StatusCode()) | |||||
| //req, _ := json.Marshal(createJobParams) | |||||
| //log.Info("%s", req) | |||||
| req, _ := json.Marshal(createJobParams) | |||||
| log.Info("%s", req) | |||||
| if res.StatusCode() == http.StatusUnauthorized && retry < 1 { | if res.StatusCode() == http.StatusUnauthorized && retry < 1 { | ||||
| retry++ | retry++ | ||||
| @@ -405,8 +404,8 @@ sendjob: | |||||
| goto sendjob | goto sendjob | ||||
| } | } | ||||
| temp, _ := json.Marshal(req) | |||||
| log.Info("%s", temp) | |||||
| //temp, _ := json.Marshal(req) | |||||
| //log.Info("%s", temp) | |||||
| if res.StatusCode() != http.StatusOK { | if res.StatusCode() != http.StatusOK { | ||||
| var temp models.ErrorResult | var temp models.ErrorResult | ||||
| @@ -339,6 +339,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||||
| engineID := form.EngineID | engineID := form.EngineID | ||||
| bootFile := form.BootFile | bootFile := form.BootFile | ||||
| flavorCode := form.Flavor | flavorCode := form.Flavor | ||||
| params := form.Params | |||||
| poolID := form.PoolID | poolID := form.PoolID | ||||
| isSaveParam := form.IsSaveParam | isSaveParam := form.IsSaveParam | ||||
| repo := ctx.Repo.Repository | repo := ctx.Repo.Repository | ||||
| @@ -382,6 +383,24 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||||
| //todo: del local code? | //todo: del local code? | ||||
| var parameters models.Parameters | |||||
| param := make([]models.Parameter, 0) | |||||
| if len(params) != 0 { | |||||
| err := json.Unmarshal([]byte(params), ¶meters) | |||||
| if err != nil { | |||||
| log.Error("Failed to Unmarshal params: %s (%v)", params, err) | |||||
| ctx.RenderWithErr("运行参数错误", tplModelArtsTrainJobNew, &form) | |||||
| return | |||||
| } | |||||
| for _, parameter := range parameters.Parameter { | |||||
| param = append(param, models.Parameter{ | |||||
| Label: parameter.Label, | |||||
| Value: parameter.Value, | |||||
| }) | |||||
| } | |||||
| } | |||||
| if isSaveParam == "on" { | if isSaveParam == "on" { | ||||
| if form.ParameterTemplateName == "" { | if form.ParameterTemplateName == "" { | ||||
| log.Error("ParameterTemplateName is empty") | log.Error("ParameterTemplateName is empty") | ||||
| @@ -403,9 +422,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||||
| EngineID: int64(engineID), | EngineID: int64(engineID), | ||||
| LogUrl: logObsPath, | LogUrl: logObsPath, | ||||
| PoolID: poolID, | PoolID: poolID, | ||||
| Parameter: []models.Parameter{ | |||||
| }, | |||||
| Parameter: param, | |||||
| }) | }) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -428,6 +445,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||||
| LogUrl: logObsPath, | LogUrl: logObsPath, | ||||
| PoolID: poolID, | PoolID: poolID, | ||||
| Uuid: uuid, | Uuid: uuid, | ||||
| Parameters: param, | |||||
| } | } | ||||
| err := modelarts.GenerateTrainJob(ctx, req) | err := modelarts.GenerateTrainJob(ctx, req) | ||||
| @@ -391,9 +391,9 @@ | |||||
| $(".dynamic.field .two.fields").each(function(){ | $(".dynamic.field .two.fields").each(function(){ | ||||
| var para_name = $(this).find('input[name=shipping_first-name]').val() | var para_name = $(this).find('input[name=shipping_first-name]').val() | ||||
| var para_value = $(this).find('input[name=shipping_last-name]').val() | var para_value = $(this).find('input[name=shipping_last-name]').val() | ||||
| run_parameters.push({"name": para_name, "value": para_value}) | |||||
| run_parameters.push({"label": para_name, "value": para_value}) | |||||
| }) | }) | ||||
| msg["param"] = run_parameters | |||||
| msg["parameter"] = run_parameters | |||||
| msg = JSON.stringify(msg) | msg = JSON.stringify(msg) | ||||
| $('#store_run_para').val(msg) | $('#store_run_para').val(msg) | ||||
| } | } | ||||