Browse Source

Merge branch 'V202108' into fixs-249

pull/264/head
zhoupzh 3 years ago
parent
commit
21ebec3574
5 changed files with 57 additions and 19 deletions
  1. +24
    -5
      models/cloudbrain.go
  2. +14
    -12
      modules/modelarts/modelarts.go
  3. +8
    -0
      modules/setting/setting.go
  4. +5
    -1
      routers/repo/modelarts.go
  5. +6
    -1
      templates/repo/modelarts/new.tmpl

+ 24
- 5
models/cloudbrain.go View File

@@ -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"`


+ 14
- 12
modules/modelarts/modelarts.go View File

@@ -2,6 +2,7 @@ package modelarts

import (
"code.gitea.io/gitea/modules/setting"
"encoding/json"
"path"

"code.gitea.io/gitea/models"
@@ -12,30 +13,31 @@ import (
const (
storageTypeOBS = "obs"
autoStopDuration = 4 * 60 * 60
flavor = "modelarts.kat1.xlarge"
//profileID = "Python3-ascend910-arm"
profileID = "efa847c0-7359-11eb-b34f-0255ac100057"
poolID = "pool1328035d"
poolName = "train-private-1"
poolType = "USER_DEFINED"

DataSetMountPath = "/home/ma-user/work"
NotebookEnv = "Python3"
NotebookType = "Ascend"
FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 96GiB (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{


+ 8
- 0
modules/setting/setting.go View File

@@ -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 {


+ 5
- 1
routers/repo/modelarts.go View File

@@ -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)
}



+ 6
- 1
templates/repo/modelarts/new.tmpl View File

@@ -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>


Loading…
Cancel
Save