Browse Source

Merge branch 'V20211228' into fix-838

pull/1185/head
zhoupzh 3 years ago
parent
commit
b7e817aff5
8 changed files with 49 additions and 34 deletions
  1. +1
    -1
      models/attachment.go
  2. +4
    -1
      models/cloudbrain.go
  3. +1
    -0
      modules/cloudbrain/cloudbrain.go
  4. +13
    -16
      modules/modelarts/modelarts.go
  5. +21
    -2
      modules/repository/elk_pagedata.go
  6. +2
    -2
      routers/repo/cloudbrain.go
  7. +5
    -11
      routers/repo/modelarts.go
  8. +2
    -1
      templates/repo/debugjob/index.tmpl

+ 1
- 1
models/attachment.go View File

@@ -429,7 +429,7 @@ func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) {
func getModelArtsUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { func getModelArtsUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) {
attachments := make([]*AttachmentUsername, 0, 10) attachments := make([]*AttachmentUsername, 0, 10)
if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+
"= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?)", TypeCloudBrainTwo, userID, false).Find(&attachments); err != nil {
"= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?) and attachment.decompress_state = ?", TypeCloudBrainTwo, userID, false, DecompressStateDone).Find(&attachments); err != nil {
return nil, err return nil, err
} }
return attachments, nil return attachments, nil


+ 4
- 1
models/cloudbrain.go View File

@@ -19,6 +19,9 @@ type JobType string
type ModelArtsJobStatus string type ModelArtsJobStatus string


const ( const (
NPUResource = "NPU"
GPUResource = "CPU/GPU"

JobWaiting CloudbrainStatus = "WAITING" JobWaiting CloudbrainStatus = "WAITING"
JobStopped CloudbrainStatus = "STOPPED" JobStopped CloudbrainStatus = "STOPPED"
JobSucceeded CloudbrainStatus = "SUCCEEDED" JobSucceeded CloudbrainStatus = "SUCCEEDED"
@@ -105,7 +108,7 @@ type Cloudbrain struct {
IsLatestVersion string //是否是最新版本,1是,0否 IsLatestVersion string //是否是最新版本,1是,0否
CommitID string //提交的仓库代码id CommitID string //提交的仓库代码id
PreVersionName string //父版本名称 PreVersionName string //父版本名称
ComputeResource string `xorm:"-"` //计算资源,例如npu
ComputeResource string //计算资源,例如npu
EngineID int64 //引擎id EngineID int64 //引擎id


TrainUrl string //输出的obs路径 TrainUrl string //输出的obs路径


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

@@ -212,6 +212,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath,
Image: image, Image: image,
GpuQueue: gpuQueue, GpuQueue: gpuQueue,
ResourceSpecId: resourceSpecId, ResourceSpecId: resourceSpecId,
ComputeResource: models.GPUResource,
}) })


if err != nil { if err != nil {


+ 13
- 16
modules/modelarts/modelarts.go View File

@@ -48,12 +48,8 @@ const (
PerPage = 10 PerPage = 10
IsLatestVersion = "1" IsLatestVersion = "1"
NotLatestVersion = "0" NotLatestVersion = "0"
// ComputeResource = "NPU"
NPUResource = "NPU"
GPUResource = "CPU/GPU"
AllResource = "all"
DebugType = -1
VersionCount = 1
DebugType = -1
VersionCount = 1


SortByCreateTime = "create_time" SortByCreateTime = "create_time"
ConfigTypeCustom = "custom" ConfigTypeCustom = "custom"
@@ -215,14 +211,15 @@ func GenerateTask(ctx *context.Context, jobName, uuid, description, flavor strin
} }
err = models.CreateCloudbrain(&models.Cloudbrain{ err = models.CreateCloudbrain(&models.Cloudbrain{


Status: string(models.JobWaiting),
UserID: ctx.User.ID,
RepoID: ctx.Repo.Repository.ID,
JobID: jobResult.ID,
JobName: jobName,
JobType: string(models.JobTypeDebug),
Type: models.TypeCloudBrainTwo,
Uuid: uuid,
Status: string(models.JobWaiting),
UserID: ctx.User.ID,
RepoID: ctx.Repo.Repository.ID,
JobID: jobResult.ID,
JobName: jobName,
JobType: string(models.JobTypeDebug),
Type: models.TypeCloudBrainTwo,
Uuid: uuid,
ComputeResource: models.NPUResource,
}) })


if err != nil { if err != nil {
@@ -277,7 +274,7 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error
DatasetName: attach.Name, DatasetName: attach.Name,
CommitID: req.CommitID, CommitID: req.CommitID,
IsLatestVersion: req.IsLatestVersion, IsLatestVersion: req.IsLatestVersion,
//ComputeResource: NPUResource,
ComputeResource: models.NPUResource,
EngineID: req.EngineID, EngineID: req.EngineID,
TrainUrl: req.TrainUrl, TrainUrl: req.TrainUrl,
BranchName: req.BranchName, BranchName: req.BranchName,
@@ -360,7 +357,7 @@ func GenerateTrainJobVersion(ctx *context.Context, req *GenerateTrainJobReq, job
CommitID: req.CommitID, CommitID: req.CommitID,
IsLatestVersion: req.IsLatestVersion, IsLatestVersion: req.IsLatestVersion,
PreVersionName: req.PreVersionName, PreVersionName: req.PreVersionName,
ComputeResource: NPUResource,
ComputeResource: models.GPUResource,
EngineID: req.EngineID, EngineID: req.EngineID,
TrainUrl: req.TrainUrl, TrainUrl: req.TrainUrl,
BranchName: req.BranchName, BranchName: req.BranchName,


+ 21
- 2
modules/repository/elk_pagedata.go View File

@@ -21,7 +21,8 @@ type Fields struct {
Format string `json:"format"` Format string `json:"format"`
} }
type MatchPhrase struct { type MatchPhrase struct {
Message string `json:"message"`
Message string `json:"message,omitempty"`
TagName string `json:"tagName.keyword,omitempty"`
} }
type Should struct { type Should struct {
MatchPhrase MatchPhrase `json:"match_phrase"` MatchPhrase MatchPhrase `json:"match_phrase"`
@@ -144,7 +145,7 @@ func ProjectViewInit(User string, Project string, Gte string, Lte string) (proje
inputStruct.Batch[0].Request.Params.Body.Fields = make([]Fields, 1) inputStruct.Batch[0].Request.Params.Body.Fields = make([]Fields, 1)
inputStruct.Batch[0].Request.Params.Body.Fields[0].Field = setting.TimeField inputStruct.Batch[0].Request.Params.Body.Fields[0].Field = setting.TimeField
inputStruct.Batch[0].Request.Params.Body.Fields[0].Format = setting.ElkTimeFormat inputStruct.Batch[0].Request.Params.Body.Fields[0].Format = setting.ElkTimeFormat
inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter = make([]Filter, 3)
inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter = make([]Filter, 4)
//限定查询时间 //限定查询时间
var timeRange Range var timeRange Range
timeRange.Timestamptest.Gte = Gte timeRange.Timestamptest.Gte = Gte
@@ -159,6 +160,24 @@ func ProjectViewInit(User string, Project string, Gte string, Lte string) (proje
var projectName FilterMatchPhrase var projectName FilterMatchPhrase
projectName.ProjectName = Project projectName.ProjectName = Project
inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter[2].FilterMatchPhrase = &projectName inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter[2].FilterMatchPhrase = &projectName
//限定页面
var bool Bool
bool.Should = make([]Should, 14)
bool.Should[0].MatchPhrase.TagName = "%{[request][3]}"
bool.Should[1].MatchPhrase.TagName = "datasets?type=0"
bool.Should[2].MatchPhrase.TagName = "datasets?type=1"
bool.Should[3].MatchPhrase.TagName = "issues"
bool.Should[4].MatchPhrase.TagName = "labels"
bool.Should[5].MatchPhrase.TagName = "pulls"
bool.Should[6].MatchPhrase.TagName = "wiki"
bool.Should[7].MatchPhrase.TagName = "activity"
bool.Should[8].MatchPhrase.TagName = "cloudbrain"
bool.Should[9].MatchPhrase.TagName = "modelarts"
bool.Should[10].MatchPhrase.TagName = "blockchain"
bool.Should[11].MatchPhrase.TagName = "watchers"
bool.Should[12].MatchPhrase.TagName = "stars"
bool.Should[13].MatchPhrase.TagName = "forks"
inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter[3].Bool = &bool
return inputStruct return inputStruct
} }




+ 2
- 2
routers/repo/cloudbrain.go View File

@@ -245,7 +245,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return return
} }
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all")
} }


func CloudBrainRestart(ctx *context.Context) { func CloudBrainRestart(ctx *context.Context) {
@@ -568,7 +568,7 @@ func CloudBrainDel(ctx *context.Context) {
} }


deleteJobStorage(task.JobName, models.TypeCloudBrainOne) deleteJobStorage(task.JobName, models.TypeCloudBrainOne)
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all")
} }


func CloudBrainShowModels(ctx *context.Context) { func CloudBrainShowModels(ctx *context.Context) {


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

@@ -51,11 +51,11 @@ func DebugJobIndex(ctx *context.Context) {
} }
debugType := modelarts.DebugType debugType := modelarts.DebugType
jobType := string(models.JobTypeDebug) jobType := string(models.JobTypeDebug)
if debugListType == modelarts.GPUResource {
if debugListType == models.GPUResource {
debugType = models.TypeCloudBrainOne debugType = models.TypeCloudBrainOne
jobType = "" jobType = ""
} }
if debugListType == modelarts.NPUResource {
if debugListType == models.NPUResource {
debugType = models.TypeCloudBrainTwo debugType = models.TypeCloudBrainTwo
} }


@@ -76,16 +76,10 @@ func DebugJobIndex(ctx *context.Context) {
for i, task := range ciTasks { for i, task := range ciTasks {
ciTasks[i].CanDebug = cloudbrain.CanCreateOrDebugJob(ctx) ciTasks[i].CanDebug = cloudbrain.CanCreateOrDebugJob(ctx)
ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)

if task.Cloudbrain.Type == models.TypeCloudBrainOne {
ciTasks[i].Cloudbrain.ComputeResource = modelarts.GPUResource
} else if task.Cloudbrain.Type == models.TypeCloudBrainTwo {
ciTasks[i].Cloudbrain.ComputeResource = modelarts.NPUResource
}
ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource
} }


pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5)
//pager.SetDefaultParams(ctx)
pager.AddParam(ctx, "debugListType", "ListType") pager.AddParam(ctx, "debugListType", "ListType")
ctx.Data["Page"] = pager ctx.Data["Page"] = pager
ctx.Data["PageIsCloudBrain"] = true ctx.Data["PageIsCloudBrain"] = true
@@ -345,7 +339,7 @@ func NotebookDel(ctx *context.Context) {
return return
} }


ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all")
} }


func TrainJobIndex(ctx *context.Context) { func TrainJobIndex(ctx *context.Context) {
@@ -375,7 +369,7 @@ func TrainJobIndex(ctx *context.Context) {
for i, task := range tasks { for i, task := range tasks {
tasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) tasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)
tasks[i].CanModify = cloudbrain.CanModifyJob(ctx, &task.Cloudbrain) tasks[i].CanModify = cloudbrain.CanModifyJob(ctx, &task.Cloudbrain)
tasks[i].ComputeResource = modelarts.NPUResource
tasks[i].ComputeResource = models.NPUResource
} }


pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5)


+ 2
- 1
templates/repo/debugjob/index.tmpl View File

@@ -568,9 +568,10 @@
$('#' + JobID+'-icon').removeClass().addClass(res.status) $('#' + JobID+'-icon').removeClass().addClass(res.status)
$('#' + JobID+ '-text').text(res.status) $('#' + JobID+ '-text').text(res.status)
if(res.status==="STOPPED"){ if(res.status==="STOPPED"){
$('#model-debug-'+JobID).removeClass('blue').addClass('disabled').text("再次调试").css("margin","0")
$('#model-debug-'+JobID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0")
$('#model-image-'+JobID).removeClass('blue').addClass('disabled') $('#model-image-'+JobID).removeClass('blue').addClass('disabled')
$('#stop-model-debug-'+JobID).removeClass('blue').addClass('disabled') $('#stop-model-debug-'+JobID).removeClass('blue').addClass('disabled')
$('#model-delete-'+JobID).removeClass('disabled').addClass('blue')
} }
else{ else{
$('#model-debug-'+JobID).removeClass('blue').addClass('disabled') $('#model-debug-'+JobID).removeClass('blue').addClass('disabled')


Loading…
Cancel
Save