| @@ -72,11 +72,11 @@ type CloudBrainLoginResult struct { | |||||
| type TaskRole struct { | type TaskRole struct { | ||||
| Name string `json:"name"` | 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"` | MemoryMB int `json:"memoryMB"` | ||||
| ShmMB int `json:"shmMB"` | ShmMB int `json:"shmMB"` | ||||
| Command string `json:"command"` | Command string `json:"command"` | ||||
| @@ -298,6 +298,25 @@ type ResourceSpec struct { | |||||
| ShareMemMiB int `json:"shareMemMiB"` | 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 { | type CommitImageParams struct { | ||||
| Ip string `json:"ip"` | Ip string `json:"ip"` | ||||
| TaskContainerId string `json:"taskContainerId"` | TaskContainerId string `json:"taskContainerId"` | ||||
| @@ -2,6 +2,7 @@ package modelarts | |||||
| import ( | import ( | ||||
| "code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
| "encoding/json" | |||||
| "path" | "path" | ||||
| "code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
| @@ -27,17 +28,25 @@ const ( | |||||
| FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 256GiB (modelarts.kat1.xlarge)" | 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 { | func GenerateTask(ctx *context.Context, jobName, uuid, description string) error { | ||||
| dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/" | 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{ | jobResult, err := CreateJob(models.CreateNotebookParams{ | ||||
| JobName: jobName, | JobName: jobName, | ||||
| Description: description, | Description: description, | ||||
| ProfileID: profileID, | |||||
| Flavor: flavor, | |||||
| ProfileID: setting.ProfileID, | |||||
| Flavor: setting.Flavor, | |||||
| Pool: models.Pool{ | 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{ | Spec: models.Spec{ | ||||
| Storage: models.Storage{ | Storage: models.Storage{ | ||||
| @@ -473,6 +473,10 @@ var ( | |||||
| ModelArtsUsername string | ModelArtsUsername string | ||||
| ModelArtsPassword string | ModelArtsPassword string | ||||
| ModelArtsDomain string | ModelArtsDomain string | ||||
| ProfileID string | |||||
| PoolInfos string | |||||
| Flavor string | |||||
| FlavorInfos string | |||||
| ) | ) | ||||
| // DateLang transforms standard language locale name to corresponding value in datetime plugin. | // DateLang transforms standard language locale name to corresponding value in datetime plugin. | ||||
| @@ -1182,6 +1186,10 @@ func NewContext() { | |||||
| ModelArtsUsername = sec.Key("USERNAME").MustString("") | ModelArtsUsername = sec.Key("USERNAME").MustString("") | ||||
| ModelArtsPassword = sec.Key("PASSWORD").MustString("") | ModelArtsPassword = sec.Key("PASSWORD").MustString("") | ||||
| ModelArtsDomain = sec.Key("DOMAIN").MustString("cn-south-222") | 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 { | func loadInternalToken(sec *ini.Section) string { | ||||
| @@ -2,6 +2,7 @@ package repo | |||||
| import ( | import ( | ||||
| "code.gitea.io/gitea/modules/modelarts" | "code.gitea.io/gitea/modules/modelarts" | ||||
| "encoding/json" | |||||
| "errors" | "errors" | ||||
| "github.com/unknwon/com" | "github.com/unknwon/com" | ||||
| "strconv" | "strconv" | ||||
| @@ -84,7 +85,10 @@ func ModelArtsNew(ctx *context.Context) { | |||||
| ctx.Data["dataset_path"] = modelarts.DataSetMountPath | ctx.Data["dataset_path"] = modelarts.DataSetMountPath | ||||
| ctx.Data["env"] = modelarts.NotebookEnv | ctx.Data["env"] = modelarts.NotebookEnv | ||||
| ctx.Data["notebook_type"] = modelarts.NotebookType | 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) | ctx.HTML(200, tplModelArtsNew) | ||||
| } | } | ||||
| @@ -132,7 +132,12 @@ | |||||
| </div> | </div> | ||||
| <div class="inline required field"> | <div class="inline required field"> | ||||
| <label>规格</label> | <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> | ||||
| <div class="inline required field"> | <div class="inline required field"> | ||||
| <label>数据集存放路径</label> | <label>数据集存放路径</label> | ||||