Browse Source

Merge branch 'V202108' into fix-231

pull/235/head
avadesian 3 years ago
parent
commit
2220b89c4e
7 changed files with 67 additions and 19 deletions
  1. +17
    -5
      models/cloudbrain.go
  2. +1
    -0
      modules/auth/cloudbrain.go
  3. +22
    -5
      modules/cloudbrain/cloudbrain.go
  4. +3
    -1
      modules/setting/setting.go
  5. +7
    -1
      routers/repo/cloudbrain.go
  6. +15
    -5
      templates/repo/cloudbrain/new.tmpl
  7. +2
    -2
      web_src/js/components/EditAboutInfo.vue

+ 17
- 5
models/cloudbrain.go View File

@@ -72,11 +72,11 @@ type CloudBrainLoginResult struct {


type TaskRole struct { type TaskRole struct {
Name string `json:"name"` Name string `json:"name"`
TaskNumber int8 `json:"taskNumber"`
MinSucceededTaskCount int8 `json:"minSucceededTaskCount"`
MinFailedTaskCount int8 `json:"minFailedTaskCount"`
CPUNumber int8 `json:"cpuNumber"`
GPUNumber int8 `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"`
@@ -286,6 +286,18 @@ type GpuInfo struct {
Queue string `json:"queue"` Queue string `json:"queue"`
} }


type ResourceSpecs struct {
ResourceSpec []*ResourceSpec `json:"resorce_specs"`
}

type ResourceSpec struct {
Id int `json:"id"`
CpuNum int `json:"cpu"`
GpuNum int `json:"gpu"`
MemMiB int `json:"memMiB"`
ShareMemMiB int `json:"shareMemMiB"`
}

type CommitImageParams struct { type CommitImageParams struct {
Ip string `json:"ip"` Ip string `json:"ip"`
TaskContainerId string `json:"taskContainerId"` TaskContainerId string `json:"taskContainerId"`


+ 1
- 0
modules/auth/cloudbrain.go View File

@@ -13,6 +13,7 @@ type CreateCloudBrainForm struct {
JobType string `form:"job_type" binding:"Required"` JobType string `form:"job_type" binding:"Required"`
BenchmarkCategory string `form:"get_benchmark_category"` BenchmarkCategory string `form:"get_benchmark_category"`
GpuType string `form:"gpu_type"` GpuType string `form:"gpu_type"`
ResourceSpecId int `form:"resource_spec_id" binding:"Required"`
} }


type CommitImageCloudBrainForm struct { type CommitImageCloudBrainForm struct {


+ 22
- 5
modules/cloudbrain/cloudbrain.go View File

@@ -23,12 +23,29 @@ const (
Success = "S000" Success = "S000"
) )


func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue string) error {
var (
ResourceSpecs *models.ResourceSpecs
)

func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue string, resourceSpecId int) error {
dataActualPath := setting.Attachment.Minio.RealPath + dataActualPath := setting.Attachment.Minio.RealPath +
setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.Bucket + "/" +
setting.Attachment.Minio.BasePath + setting.Attachment.Minio.BasePath +
models.AttachmentRelativePath(uuid) + models.AttachmentRelativePath(uuid) +
uuid uuid

var resourceSpec *models.ResourceSpec
for _, spec := range ResourceSpecs.ResourceSpec {
if resourceSpecId == spec.Id {
resourceSpec = spec
}
}

if resourceSpec == nil {
log.Error("no such resourceSpecId(%d)", resourceSpecId, ctx.Data["MsgID"])
return errors.New("no such resourceSpec")
}
jobResult, err := CreateJob(jobName, models.CreateJobParams{ jobResult, err := CreateJob(jobName, models.CreateJobParams{
JobName: jobName, JobName: jobName,
RetryCount: 1, RetryCount: 1,
@@ -40,10 +57,10 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath,
TaskNumber: 1, TaskNumber: 1,
MinSucceededTaskCount: 1, MinSucceededTaskCount: 1,
MinFailedTaskCount: 1, MinFailedTaskCount: 1,
CPUNumber: 2,
GPUNumber: 1,
MemoryMB: 16384,
ShmMB: 8192,
CPUNumber: resourceSpec.CpuNum,
GPUNumber: resourceSpec.GpuNum,
MemoryMB: resourceSpec.MemMiB,
ShmMB: resourceSpec.ShareMemMiB,
Command: command, Command: command,
NeedIBDevice: false, NeedIBDevice: false,
IsMainRole: false, IsMainRole: false,


+ 3
- 1
modules/setting/setting.go View File

@@ -439,6 +439,7 @@ var (
JobType string JobType string
GpuTypes string GpuTypes string
DebugServerHost string DebugServerHost string
ResourceSpecs string


//benchmark config //benchmark config
IsBenchmarkEnabled bool IsBenchmarkEnabled bool
@@ -1147,7 +1148,8 @@ func NewContext() {
JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/") JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/")
DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73") DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73")
JobType = sec.Key("GPU_TYPE_DEFAULT").MustString("openidebug") JobType = sec.Key("GPU_TYPE_DEFAULT").MustString("openidebug")
GpuTypes = sec.Key("GPU_TYPES").MustString("openidebug,openidgx")
GpuTypes = sec.Key("GPU_TYPES").MustString("")
ResourceSpecs = sec.Key("RESOURCE_SPECS").MustString("")


sec = Cfg.Section("benchmark") sec = Cfg.Section("benchmark")
IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false) IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false)


+ 7
- 1
routers/repo/cloudbrain.go View File

@@ -148,6 +148,11 @@ func CloudBrainNew(ctx *context.Context) {
json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos)
} }
ctx.Data["gpu_types"] = gpuInfos.GpuInfo ctx.Data["gpu_types"] = gpuInfos.GpuInfo

if cloudbrain.ResourceSpecs == nil {
json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs)
}
ctx.Data["resource_specs"] = cloudbrain.ResourceSpecs.ResourceSpec
ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath
ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled
ctx.HTML(200, tplCloudBrainNew) ctx.HTML(200, tplCloudBrainNew)
@@ -162,6 +167,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
jobType := form.JobType jobType := form.JobType
gpuQueue := setting.JobType gpuQueue := setting.JobType
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath
resourceSpecId := form.ResourceSpecId


if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) { if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) {
log.Error("jobtype error:", jobType, ctx.Data["msgID"]) log.Error("jobtype error:", jobType, ctx.Data["msgID"])
@@ -208,7 +214,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath, "", "") downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath, "", "")
} }


err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue)
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType, gpuQueue, resourceSpecId)
if err != nil { if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return return


+ 15
- 5
templates/repo/cloudbrain/new.tmpl View File

@@ -161,14 +161,15 @@


<div class="inline required field"> <div class="inline required field">
<label>镜像</label> <label>镜像</label>
<select class="ui search" id="cloudbrain_image" placeholder="选择镜像" style='width:385px;' name="image">
<input type="text" list="cloudbrain_image" placeholder="选择镜像" name="image">
<datalist class="ui search" id="cloudbrain_image" style='width:385px;' name="image">
{{range .images}} {{range .images}}
<option name="image" value="{{.Place}}">{{.PlaceView}}</option> <option name="image" value="{{.Place}}">{{.PlaceView}}</option>
{{end}} {{end}}
{{range .public_images}} {{range .public_images}}
<option name="image" value="{{.Place}}">{{.PlaceView}}</option> <option name="image" value="{{.Place}}">{{.PlaceView}}</option>
{{end}} {{end}}
</select>
</datalist>
</div> </div>


<div class="inline required field"> <div class="inline required field">
@@ -181,6 +182,15 @@
</div> </div>


<div class="inline required field"> <div class="inline required field">
<label>资源规格</label>
<select id="cloudbrain_resource_spec" class="ui search dropdown" placeholder="选择资源规格" style='width:385px' name="resource_spec_id">
{{range .resource_specs}}
<option name="resource_spec_id" value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option>
{{end}}
</select>
</div>

<div class="inline required field">
<label>数据集存放路径</label> <label>数据集存放路径</label>
<input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly">
</div> </div>
@@ -242,9 +252,9 @@
.dropdown(); .dropdown();


$('#cloudbrain_image').select2({
placeholder: "选择镜像"
});
// $('#cloudbrain_image').select2({
// placeholder: "选择镜像"
// });


$(".ui.button.reset").click(function(e){ $(".ui.button.reset").click(function(e){


+ 2
- 2
web_src/js/components/EditAboutInfo.vue View File

@@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<h4 id="about-desc" class="ui header">简介 <h4 id="about-desc" class="ui header">简介
<a class="edit-icon" href="javascript:void(0)" @click="editClick">
<!-- <a class="edit-icon" href="javascript:void(0)" @click="editClick">
<i class="gray edit outline icon"></i> <i class="gray edit outline icon"></i>
</a>
</a> -->
</h4> </h4>
<edit-dialog-cmpt <edit-dialog-cmpt
:vmContext="vmContext" :vmContext="vmContext"


Loading…
Cancel
Save