| @@ -72,11 +72,11 @@ type CloudBrainLoginResult struct { | |||
| type TaskRole struct { | |||
| Name string `json:"name"` | |||
| TaskNumber int `json:"taskNumber"` | |||
| MinSucceededTaskCount int `json:"minSucceededTaskCount"` | |||
| MinFailedTaskCount int `json:"minFailedTaskCount"` | |||
| CPUNumber int `json:"cpuNumber"` | |||
| GPUNumber int `json:"gpuNumber"` | |||
| TaskNumber int `json:"taskNumber"` | |||
| MinSucceededTaskCount int `json:"minSucceededTaskCount"` | |||
| MinFailedTaskCount int `json:"minFailedTaskCount"` | |||
| CPUNumber int `json:"cpuNumber"` | |||
| GPUNumber int `json:"gpuNumber"` | |||
| MemoryMB int `json:"memoryMB"` | |||
| ShmMB int `json:"shmMB"` | |||
| Command string `json:"command"` | |||
| @@ -298,6 +298,25 @@ type ResourceSpec struct { | |||
| ShareMemMiB int `json:"shareMemMiB"` | |||
| } | |||
| type FlavorInfos struct { | |||
| FlavorInfo []*FlavorInfo `json:"flavor_info"` | |||
| } | |||
| type FlavorInfo struct { | |||
| Id int `json:"id"` | |||
| Value string `json:"value"` | |||
| } | |||
| type PoolInfos struct { | |||
| PoolInfo []*PoolInfo `json:"pool_info"` | |||
| } | |||
| type PoolInfo struct { | |||
| PoolId string `json:"pool_id"` | |||
| PoolName string `json:"pool_name"` | |||
| PoolType string `json:"pool_type"` | |||
| } | |||
| type CommitImageParams struct { | |||
| Ip string `json:"ip"` | |||
| TaskContainerId string `json:"taskContainerId"` | |||
| @@ -2,6 +2,7 @@ package modelarts | |||
| import ( | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "encoding/json" | |||
| "path" | |||
| "code.gitea.io/gitea/models" | |||
| @@ -27,17 +28,25 @@ const ( | |||
| FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 256GiB (modelarts.kat1.xlarge)" | |||
| ) | |||
| var ( | |||
| poolInfos *models.PoolInfos | |||
| FlavorInfos *models.FlavorInfos | |||
| ) | |||
| func GenerateTask(ctx *context.Context, jobName, uuid, description string) error { | |||
| dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/" | |||
| if poolInfos == nil { | |||
| json.Unmarshal([]byte(setting.PoolInfos), &poolInfos) | |||
| } | |||
| jobResult, err := CreateJob(models.CreateNotebookParams{ | |||
| JobName: jobName, | |||
| Description: description, | |||
| ProfileID: profileID, | |||
| Flavor: flavor, | |||
| ProfileID: setting.ProfileID, | |||
| Flavor: setting.Flavor, | |||
| Pool: models.Pool{ | |||
| ID: poolID, | |||
| Name: poolName, | |||
| Type: poolType, | |||
| ID: poolInfos.PoolInfo[0].PoolId, | |||
| Name: poolInfos.PoolInfo[0].PoolName, | |||
| Type: poolInfos.PoolInfo[0].PoolType, | |||
| }, | |||
| Spec: models.Spec{ | |||
| Storage: models.Storage{ | |||
| @@ -473,6 +473,10 @@ var ( | |||
| ModelArtsUsername string | |||
| ModelArtsPassword string | |||
| ModelArtsDomain string | |||
| ProfileID string | |||
| PoolInfos string | |||
| Flavor string | |||
| FlavorInfos string | |||
| ) | |||
| // DateLang transforms standard language locale name to corresponding value in datetime plugin. | |||
| @@ -1182,6 +1186,10 @@ func NewContext() { | |||
| ModelArtsUsername = sec.Key("USERNAME").MustString("") | |||
| ModelArtsPassword = sec.Key("PASSWORD").MustString("") | |||
| ModelArtsDomain = sec.Key("DOMAIN").MustString("cn-south-222") | |||
| ProfileID = sec.Key("PROFILE_ID").MustString("") | |||
| PoolInfos = sec.Key("POOL_INFOS").MustString("") | |||
| Flavor = sec.Key("FLAVOR").MustString("") | |||
| FlavorInfos = sec.Key("FLAVOR_INFOS").MustString("") | |||
| } | |||
| func loadInternalToken(sec *ini.Section) string { | |||
| @@ -2,6 +2,7 @@ package repo | |||
| import ( | |||
| "code.gitea.io/gitea/modules/modelarts" | |||
| "encoding/json" | |||
| "errors" | |||
| "github.com/unknwon/com" | |||
| "strconv" | |||
| @@ -84,7 +85,10 @@ func ModelArtsNew(ctx *context.Context) { | |||
| ctx.Data["dataset_path"] = modelarts.DataSetMountPath | |||
| ctx.Data["env"] = modelarts.NotebookEnv | |||
| ctx.Data["notebook_type"] = modelarts.NotebookType | |||
| ctx.Data["flavor"] = modelarts.FlavorInfo | |||
| if modelarts.FlavorInfos == nil { | |||
| json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) | |||
| } | |||
| ctx.Data["flavors"] = modelarts.FlavorInfos.FlavorInfo | |||
| ctx.HTML(200, tplModelArtsNew) | |||
| } | |||
| @@ -132,7 +132,12 @@ | |||
| </div> | |||
| <div class="inline required field"> | |||
| <label>规格</label> | |||
| <input name="flavor" id="cloudbrain_flavor" value="{{.flavor}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | |||
| <select id="cloudbrain_flavor" class="ui search dropdown" placeholder="选择规格" style='width:385px' name="flavor"> | |||
| {{range .flavors}} | |||
| <option name="flavor" value="{{.Value}}">{{.Value}}</option> | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| <div class="inline required field"> | |||
| <label>数据集存放路径</label> | |||