Browse Source

index

tags/v1.22.3.2^2
lewis 3 years ago
parent
commit
647ff435e5
5 changed files with 44 additions and 20 deletions
  1. +7
    -0
      models/cloudbrain.go
  2. +0
    -5
      models/file_chunk.go
  3. +0
    -1
      modules/modelarts/modelarts.go
  4. +3
    -3
      routers/admin/cloudbrains.go
  5. +34
    -11
      routers/repo/modelarts.go

+ 7
- 0
models/cloudbrain.go View File

@@ -19,9 +19,16 @@ type CloudbrainStatus string
type JobType string type JobType string
type ModelArtsJobStatus string type ModelArtsJobStatus string


const (
TypeCloudBrainAll = -1
TypeCloudBrainOne int = iota
TypeCloudBrainTwo
)

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


//notebook storage category //notebook storage category
EVSCategory = "EVS" EVSCategory = "EVS"


+ 0
- 5
models/file_chunk.go View File

@@ -13,11 +13,6 @@ const (
FileUploaded FileUploaded
) )


const (
TypeCloudBrainOne int = iota
TypeCloudBrainTwo
)

type FileChunk struct { type FileChunk struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
UUID string `xorm:"uuid UNIQUE"` UUID string `xorm:"uuid UNIQUE"`


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

@@ -54,7 +54,6 @@ const (
PerPage = 10 PerPage = 10
IsLatestVersion = "1" IsLatestVersion = "1"
NotLatestVersion = "0" NotLatestVersion = "0"
DebugType = -1
VersionCount = 1 VersionCount = 1


SortByCreateTime = "create_time" SortByCreateTime = "create_time"


+ 3
- 3
routers/admin/cloudbrains.go View File

@@ -41,7 +41,7 @@ func CloudBrains(ctx *context.Context) {
if page <= 0 { if page <= 0 {
page = 1 page = 1
} }
debugType := modelarts.DebugType
debugType := models.TypeCloudBrainAll
if listType == models.GPUResource { if listType == models.GPUResource {
debugType = models.TypeCloudBrainOne debugType = models.TypeCloudBrainOne
} else if listType == models.NPUResource { } else if listType == models.NPUResource {
@@ -121,7 +121,7 @@ func DownloadCloudBrains(ctx *context.Context) {
Page: page, Page: page,
PageSize: 1, PageSize: 1,
}, },
Type: modelarts.DebugType,
Type: models.TypeCloudBrainAll,
NeedRepoInfo: false, NeedRepoInfo: false,
IsLatestVersion: modelarts.IsLatestVersion, IsLatestVersion: modelarts.IsLatestVersion,
}) })
@@ -151,7 +151,7 @@ func DownloadCloudBrains(ctx *context.Context) {
Page: page, Page: page,
PageSize: pageSize, PageSize: pageSize,
}, },
Type: modelarts.DebugType,
Type: models.TypeCloudBrainAll,
NeedRepoInfo: true, NeedRepoInfo: true,
IsLatestVersion: modelarts.IsLatestVersion, IsLatestVersion: modelarts.IsLatestVersion,
}) })


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

@@ -46,20 +46,26 @@ const (
) )


func DebugJobIndex(ctx *context.Context) { func DebugJobIndex(ctx *context.Context) {
debugListType := ctx.Query("debugListType")
ctx.Data["ListType"] = debugListType
listType := ctx.Query("debugListType")
ctx.Data["ListType"] = listType
MustEnableCloudbrain(ctx) MustEnableCloudbrain(ctx)
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
page := ctx.QueryInt("page") page := ctx.QueryInt("page")
if page <= 0 { if page <= 0 {
page = 1 page = 1
} }
debugType := modelarts.DebugType
typeCloudBrain := models.TypeCloudBrainAll
jobTypeNot := false jobTypeNot := false
if debugListType == models.GPUResource {
debugType = models.TypeCloudBrainOne
} else if debugListType == models.NPUResource {
debugType = models.TypeCloudBrainTwo
if listType == models.GPUResource {
typeCloudBrain = models.TypeCloudBrainOne
} else if listType == models.NPUResource {
typeCloudBrain = models.TypeCloudBrainTwo
} else if listType == models.AllResource {
typeCloudBrain = models.TypeCloudBrainAll
} else {
log.Error("listType(%s) error", listType)
ctx.ServerError("listType error", errors.New("listType error"))
return
} }


var jobTypes []string var jobTypes []string
@@ -70,7 +76,7 @@ func DebugJobIndex(ctx *context.Context) {
PageSize: setting.UI.IssuePagingNum, PageSize: setting.UI.IssuePagingNum,
}, },
RepoID: repo.ID, RepoID: repo.ID,
Type: debugType,
Type: typeCloudBrain,
JobTypeNot: jobTypeNot, JobTypeNot: jobTypeNot,
JobTypes: jobTypes, JobTypes: jobTypes,
}) })
@@ -92,7 +98,7 @@ func DebugJobIndex(ctx *context.Context) {
ctx.Data["Tasks"] = ciTasks ctx.Data["Tasks"] = ciTasks
ctx.Data["CanCreate"] = cloudbrain.CanCreateOrDebugJob(ctx) ctx.Data["CanCreate"] = cloudbrain.CanCreateOrDebugJob(ctx)
ctx.Data["RepoIsEmpty"] = repo.IsEmpty ctx.Data["RepoIsEmpty"] = repo.IsEmpty
ctx.Data["debugListType"] = debugListType
ctx.Data["debugListType"] = listType
ctx.HTML(200, tplDebugJobIndex) ctx.HTML(200, tplDebugJobIndex)
} }


@@ -473,6 +479,23 @@ func TrainJobIndex(ctx *context.Context) {
page = 1 page = 1
} }


listType := ctx.Query("listType")
ctx.Data["ListType"] = listType

typeCloudBrain := models.TypeCloudBrainAll
if listType == models.GPUResource {
typeCloudBrain = models.TypeCloudBrainOne
} else if listType == models.NPUResource {
typeCloudBrain = models.TypeCloudBrainTwo
} else if listType == models.AllResource {
typeCloudBrain = models.TypeCloudBrainAll
}
//else {
// log.Error("listType(%s) error", listType)
// ctx.ServerError("listType error", errors.New("listType error"))
// return
//}

var jobTypes []string var jobTypes []string
jobTypes = append(jobTypes, string(models.JobTypeTrain)) jobTypes = append(jobTypes, string(models.JobTypeTrain))
tasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ tasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{
@@ -481,7 +504,7 @@ func TrainJobIndex(ctx *context.Context) {
PageSize: setting.UI.IssuePagingNum, PageSize: setting.UI.IssuePagingNum,
}, },
RepoID: repo.ID, RepoID: repo.ID,
Type: models.TypeCloudBrainTwo,
Type: typeCloudBrain,
JobTypeNot: false, JobTypeNot: false,
JobTypes: jobTypes, JobTypes: jobTypes,
IsLatestVersion: modelarts.IsLatestVersion, IsLatestVersion: modelarts.IsLatestVersion,
@@ -2246,7 +2269,7 @@ func SetJobCount(ctx *context.Context) {
repoId := ctx.Repo.Repository.ID repoId := ctx.Repo.Repository.ID
_, jobCount, err := models.Cloudbrains(&models.CloudbrainsOptions{ _, jobCount, err := models.Cloudbrains(&models.CloudbrainsOptions{
RepoID: repoId, RepoID: repoId,
Type: modelarts.DebugType,
Type: models.TypeCloudBrainAll,
}) })
if err != nil { if err != nil {
ctx.ServerError("Get job faild:", err) ctx.ServerError("Get job faild:", err)


Loading…
Cancel
Save