@@ -18,6 +18,8 @@ import (
"strings"
"time"
"code.gitea.io/gitea/services/reward/point/account"
"code.gitea.io/gitea/modules/grampus"
cloudbrainService "code.gitea.io/gitea/services/cloudbrain"
@@ -148,6 +150,12 @@ func GetFileNoteBookInfo(ctx *context.APIContext) {
return
}
waitCountGPU := (*queuesMap)[specGpuQueueCode]
var a *models.PointAccount
if ctx.User != nil {
a, _ = account.GetAccount(ctx.User.ID)
}
if !setting.ModelartsCD.Enabled {
ctx.JSON(http.StatusOK, map[string]interface{}{
"code": 0,
@@ -161,6 +169,7 @@ func GetFileNoteBookInfo(ctx *context.APIContext) {
"imageGpuDescription": setting.FileNoteBook.ImageGPUDescription,
"imageNpuDescription": setting.FileNoteBook.ImageNPUDescription,
"cloudBrainPaySwitch": setting.CloudBrainPaySwitch,
"PointAccount": a,
})
} else {
ctx.JSON(http.StatusOK, map[string]interface{}{
@@ -175,6 +184,7 @@ func GetFileNoteBookInfo(ctx *context.APIContext) {
"imageGpuDescription": setting.FileNoteBook.ImageGPUDescription,
"imageNpuDescription": setting.FileNoteBook.ImageNPUCDDescription,
"cloudBrainPaySwitch": setting.CloudBrainPaySwitch,
"PointAccount": a,
})
}
@@ -992,34 +1002,56 @@ func getLogFromModelDir(jobName string, startLine int, endLine int, resultPath s
}
func CloudBrainModelConvertList(ctx *context.APIContext) {
var (
err error
)
ID := ctx.Params(":id")
parentDir := ctx.Query("parentDir")
dirArray := strings.Split(parentDir, "/")
var versionName = "V0001"
job, err := models.QueryModelConvertById(ID)
if err != nil {
log.Error("GetCloudbrainByJobID(%s) failed:%v", job.Name, err.Error())
ctx.ServerError("GetModelDirs failed:", err)
return
}
result, err := QueryModelConvertResultFileList(ctx, ID)
if err == nil {
ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": job.ID,
"VersionName": versionName,
"StatusOK": 0,
"Path": dirArray,
"Dirs": result,
"task": job,
"PageIsCloudBrain": true,
})
} else {
log.Error("GetCloudbrainByJobID failed:%v", err.Error())
ctx.ServerError("GetModelDirs failed:", err)
return
}
}
func QueryModelConvertResultFileList(ctx *context.APIContext, id string) ([]storage.FileInfo, error) {
ID := id
parentDir := ctx.Query("parentDir")
job, err := models.QueryModelConvertById(ID)
if err != nil {
log.Error("GetCloudbrainByJobID(%s) failed:%v", job.Name, err.Error())
return nil, err
}
if job.IsGpuTrainTask() {
//get dirs
dirs, err := routerRepo.GetModelDirs(job.ID, parentDir)
if err != nil {
log.Error("GetModelDirs failed:%v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("GetModelDirs failed:", err)
return
return nil, err
}
var fileInfos []storage.FileInfo
err = json.Unmarshal([]byte(dirs), &fileInfos)
if err != nil {
log.Error("json.Unmarshal failed:%v", err.Error(), ctx.Data["msgID"])
//ctx.ServerError("json.Unmarshal failed:", err)
return
return nil, err
}
for i, fileInfo := range fileInfos {
@@ -1031,46 +1063,20 @@ func CloudBrainModelConvertList(ctx *context.APIContext) {
return fileInfos[i].ModTime > fileInfos[j].ModTime
})
ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": ID,
"VersionName": "",
"StatusOK": 0,
"Path": dirArray,
"Dirs": fileInfos,
"task": job,
"PageIsCloudBrain": true,
})
return fileInfos, nil
} else {
var jobID = ctx.Params(":id")
var versionName = "V0001"
parentDir := ctx.Query("parentDir")
dirArray := strings.Split(parentDir, "/")
models, err := storage.GetObsListObject(job.ID, "output/", parentDir, versionName)
if err != nil {
log.Info("get TrainJobListModel failed:", err)
//ctx.ServerError("GetObsListObject:", err)
return
return nil, err
}
ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": jobID,
"VersionName": versionName,
"StatusOK": 0,
"Path": dirArray,
"Dirs": models,
"task": job,
"PageIsCloudBrain": true,
})
return models, nil
}
}
func CloudBrainModelList(ctx *context.APIContext) {
var (
err error
)
var jobID = ctx.Params(":jobid")
var versionName = ctx.Query("version_name")
parentDir := ctx.Query("parentDir")