#156 master

Merged
yangxzh1 merged 7 commits from OpenI/octopus:master into master 3 months ago
  1. +6
    -0
      admin-portal/src/views/devManager/components/notebook/notebookProfile.vue
  2. +9
    -1
      deploy/upgrade.md
  3. +23
    -6
      openai-portal/src/views/modelDev/components/notebook/notebookCreation.vue
  4. +6
    -0
      openai-portal/src/views/modelDev/components/notebook/notebookProfile.vue
  5. +1
    -0
      server/admin-server/api/v1/develop.proto
  6. +2
    -0
      server/base-server/api/v1/develop.proto
  7. +1
    -0
      server/base-server/internal/data/dao/model/develop.go
  8. +3
    -0
      server/base-server/internal/service/develop/develop.go
  9. +29
    -8
      server/base-server/internal/service/develop/task.go
  10. +2
    -0
      server/openai-server/api/v1/develop.proto

+ 6
- 0
admin-portal/src/views/devManager/components/notebook/notebookProfile.vue View File

@@ -63,6 +63,12 @@
<span>{{ profileInfo.command }}</span>
</div>
</el-col>
<el-col :span="12">
<div>
自动停止:
<span>{{profileInfo.autoStopDuration == -1 ? '任务不会自动停止' : profileInfo.autoStopDuration/3600 + '小时'}}</span>
</div>
</el-col>
</el-row>
</div>
</template>


+ 9
- 1
deploy/upgrade.md View File

@@ -72,8 +72,16 @@ kubectl delete -f nvidia-device-plugin.yml

## v4.3.2

升级前
升级前
1. 执行
```
kubectl create ns fluid-system
```

## v4.3.4

升级后
1. 执行以下sql语句,其中auto_stop_duration为当前默认的notebook自动停止时间(秒),可替换为当前部署配置文件autoStopIntervalSec配置项的值
```
update notebook set auto_stop_duration = 14400 where auto_stop_duration = 0
```

+ 23
- 6
openai-portal/src/views/modelDev/components/notebook/notebookCreation.vue View File

@@ -98,6 +98,17 @@
</el-select>
</el-form-item>
</div>
<el-form-item label="自动停止" prop="autoStopDuration">
<el-switch
v-model="isAutoStop"
active-color="#3296fa"
inactive-color="gray">
</el-switch>
<span v-if="isAutoStop" style="margin-left: 10px">
<el-input-number v-model="ruleForm.autoStopDuration" :precision="1" :step="1" :min="1"></el-input-number>
<span style="color: #B3B3B3;margin-left: 10px">小时</span>
</span>
</el-form-item>
<el-form-item>
<el-button type="text" @click="showMultitask">高级设置</el-button>
</el-form-item>
@@ -109,11 +120,11 @@
</el-select>
</el-form-item>
<el-form-item label="自定义启动命令" prop="command">
<el-input v-model="ruleForm.command"></el-input>
<el-input v-model="ruleForm.command" type="textarea"></el-input>
</el-form-item>
<div class="tip"><i
class="el-alert__icon el-icon-warning"></i>服务端口环境变量为<span>OCTOPUS_NOTEBOOK_PORT</span>,基础URL环境变量为<span>OCTOPUS_NOTEBOOK_BASE_URL</span>
</div>
<div class="tip">
<i class="el-alert__icon el-icon-warning"></i>服务端口环境变量为<span>OCTOPUS_NOTEBOOK_PORT</span>,基础URL环境变量为<span>OCTOPUS_NOTEBOOK_BASE_URL</span>
</div>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
@@ -155,6 +166,7 @@
return callback();
};
return {
isAutoStop: true,
specificationVisible: false,
poolList: [],
ruleForm: {
@@ -171,7 +183,8 @@
taskNumber: 1,
resourcePool: "",
specification: "",
command: ""
command: "",
autoStopDuration: 4
},
rules: {
name: [
@@ -358,8 +371,12 @@
datasetVersion: this.ruleForm.dataSetVersion || "",
taskNumber: this.ruleForm.taskNumber,
resourcePool: this.ruleForm.resourcePool,
command: this.ruleForm.command
command: this.ruleForm.command,
autoStopDuration: this.ruleForm.autoStopDuration * 3600
};
if(!this.isAutoStop) {
param.autoStopDuration = -1
}
const confirmInfo = this.$createElement
this.$confirm(
'温馨提示', {


+ 6
- 0
openai-portal/src/views/modelDev/components/notebook/notebookProfile.vue View File

@@ -63,6 +63,12 @@
<span>{{ profileInfo.command }}</span>
</div>
</el-col>
<el-col :span="12">
<div>
自动停止:
<span>{{profileInfo.autoStopDuration == -1 ? '任务不会自动停止' : profileInfo.autoStopDuration/3600 + '小时'}}</span>
</div>
</el-col>
</el-row>
</div>
</template>


+ 1
- 0
server/admin-server/api/v1/develop.proto View File

@@ -93,6 +93,7 @@ message Notebook {
string resourcePool=27;
string exitMsg = 28;
string command = 29;
int64 autoStopDuration = 30;
}

message ListNotebookReply {


+ 2
- 0
server/base-server/api/v1/develop.proto View File

@@ -52,6 +52,7 @@ message CreateNotebookRequest {
map<string, string> envs = 15;
string command = 16;
bool disableMountUserHome = 17;
int64 autoStopDuration = 18;
}

message CreateNotebookReply {
@@ -127,6 +128,7 @@ message Notebook {
string imageUrl = 25;
string exitMsg = 26;
string command = 27;
int64 autoStopDuration = 28;
}

message ListNotebookReply {


+ 1
- 0
server/base-server/internal/data/dao/model/develop.go View File

@@ -38,6 +38,7 @@ type Notebook struct {
Envs sql.Map `gorm:"type:json;comment:环境变量"`
Command string `gorm:"type:text;comment:启动命令"`
DisableMountUserHome bool `gorm:"default:false;comment:是否不挂载userhome目录"`
AutoStopDuration int64 `gorm:"type:int;not null;default:0;comment:自动停止时间(秒)"`
DeletedAt soft_delete.DeletedAt `gorm:"uniqueIndex:name_userId_spaceId,priority:4"`
}



+ 3
- 0
server/base-server/internal/service/develop/develop.go View File

@@ -417,6 +417,9 @@ func (s *developService) CreateNotebook(ctx context.Context, req *api.CreateNote
nb.Status = constant.PREPARING
nb.NotebookJobId = jobId
nb.TaskNumber = int(req.TaskNumber)
if req.AutoStopDuration == 0 {
nb.AutoStopDuration = s.conf.Service.Develop.AutoStopIntervalSec
}

nbJob := &model.NotebookJob{
Id: jobId,


+ 29
- 8
server/base-server/internal/service/develop/task.go View File

@@ -59,10 +59,10 @@ func (s *developService) startNotebookTask() {
utils.HandlePanic(ctx, func(i ...interface{}) {
for pageIndex := 1; ; pageIndex++ {
notebookJobs, err := s.data.DevelopDao.ListNotebookJob(ctx, &model.NotebookJobQuery{
PageIndex: pageIndex,
PageSize: taskPageSize,
StartedAtLt: time.Now().Add(-time.Second * time.Duration(s.conf.Service.Develop.AutoStopIntervalSec)).Unix(),
StatusList: utils.NonCompletedStates(),
PageIndex: pageIndex,
PageSize: taskPageSize,
//StartedAtLt: time.Now().Add(-time.Second * time.Duration(s.conf.Service.Develop.AutoStopIntervalSec)).Unix(),
StatusList: utils.NonCompletedStates(),
})

if err != nil {
@@ -74,12 +74,33 @@ func (s *developService) startNotebookTask() {
break
}

nbs := make(map[string]*model.Notebook)
nbIds := make([]string, 0)
for _, j := range notebookJobs {
_, err := s.StopNotebook(ctx, &api.StopNotebookRequest{Id: j.NotebookId})
if err != nil {
s.log.Errorf(ctx, "StopNotebook err: %s", err)
continue
nbIds = append(nbIds, j.NotebookId)
}

notebooks, _, err := s.data.DevelopDao.ListNotebook(ctx, &model.NotebookQuery{Ids: nbIds})
for _, n := range notebooks {
nbs[n.Id] = n
}

for _, j := range notebookJobs {
duration := int64(0)
if nbs[j.NotebookId].AutoStopDuration == 0 {
duration = s.conf.Service.Develop.AutoStopIntervalSec
} else {
duration = nbs[j.NotebookId].AutoStopDuration
}

if duration > 0 && j.StartedAt != nil && time.Now().Sub(*j.StartedAt).Seconds() >= float64(duration) {
_, err := s.StopNotebook(ctx, &api.StopNotebookRequest{Id: j.NotebookId})
if err != nil {
s.log.Errorf(ctx, "StopNotebook err: %s", err)
continue
}
}

}
}
})()


+ 2
- 0
server/openai-server/api/v1/develop.proto View File

@@ -92,6 +92,7 @@ message CreateNotebookRequest {
map<string, string> envs = 13;
string command = 14;
bool disableMountUserHome = 15;
int64 autoStopDuration = 16;
}

message CreateNotebookReply {
@@ -171,6 +172,7 @@ message Notebook {
string imageUrl = 24;
string exitMsg = 25;
string command = 26;
int64 autoStopDuration = 27;
}

message ListNotebookReply {


Loading…
Cancel
Save