22 Commits

Author SHA1 Message Date
  choikeith 79f2ccdbdb Merge remote-tracking branch 'upstream/V20230215' into V20221228 2 years ago
  chenshihai c2f6aa8c7f Merge pull request 'issue 置顶样式和权限' (#3646) from fix-3040 into V20230215 2 years ago
  zhoupzh aa444aac1e Merge branch 'V20230215' into fix-3040 2 years ago
  Gitea 44761a9929 修改置顶样式 2 years ago
  chenyifan01 569d772690 Merge pull request '#3642' (#3644) from fix-3627 into V20230215 2 years ago
  chenyifan01 61dcb09508 Merge branch 'V20230215' into fix-3627 2 years ago
  chenshihai 832b1ceae4 #3642 2 years ago
  Gitea 78b25855ff fix issue 2 years ago
  chenyifan01 6481c68606 #3627 2 years ago
  ychao 9a26d4800e Merge pull request '增加模型转换的结果文件列表查看及文件下载两个接口。' (#3641) from zouap into V20230215 2 years ago
  zouap 765c3c4179 删除无用的代码提交 2 years ago
  zouap 0d45138b41 Merge remote-tracking branch 'origin/V20230215' into zouap 2 years ago
  zouap cdfd64515d 增加模型转换的两个API接口 2 years ago
  zouap c14312e360 Merge pull request '优化分支查询命令,减少代码处理' (#3638) from fix-3325 into V20230215 2 years ago
  zouap 90713542d2 Merge branch 'V20230215' into fix-3325 2 years ago
  chenyifan01 39da38f446 Merge pull request '#3627 【积分消耗】在线运行notebook界面展示积分余额和预计可用时长' (#3637) from fix-3627 into V20230215 2 years ago
  ychao 486f854ebf 优化分支查询命令,减少代码处理 2 years ago
  chenshihai 7c3b9075f6 Merge branch 'V20230215' into fix-3627 2 years ago
  chenshihai ca5da1fdce #3627 【积分消耗】在线运行notebook界面展示积分余额和预计可用时长 2 years ago
  chenyifan01 bd0ef5fbca #3627 2 years ago
  zouap 4939c13908 去掉代码删除数据。 2 years ago
  zouap a44b5d1ebd 增加删除无用数据的函数 2 years ago
9 changed files with 131 additions and 69 deletions
Split View
  1. +6
    -19
      modules/git/repo_branch.go
  2. +2
    -0
      routers/api/v1/api.go
  3. +43
    -37
      routers/api/v1/repo/cloudbrain.go
  4. +17
    -0
      routers/api/v1/repo/modelmanage.go
  5. +10
    -2
      templates/repo/issue/list.tmpl
  6. +1
    -1
      templates/repo/issue/view_content/sidebar.tmpl
  7. +5
    -1
      web_src/vuepages/langs/config/en-US.js
  8. +5
    -1
      web_src/vuepages/langs/config/zh-CN.js
  9. +42
    -8
      web_src/vuepages/pages/notebook/debug/index.vue

+ 6
- 19
modules/git/repo_branch.go View File

@@ -174,20 +174,19 @@ func (repo *Repository) GetBranches(skip, limit int) ([]string, int, error) {
}

func (repo *Repository) GetBranchNames(skip, limit int) ([]string, int, error) {
return callShowRefNew(repo.Path, BranchPrefix, []string{BranchPrefix}, skip, limit)
return callShowRefNew(repo.Path, []string{BranchPrefix}, skip, limit)
}

func callShowRefNew(repoPath, trimPrefix string, extraArgs []string, skip, limit int) (branchNames []string, countAll int, err error) {
func callShowRefNew(repoPath string, extraArgs []string, skip, limit int) (branchNames []string, countAll int, err error) {

countAll, err = walkShowRef(repoPath, extraArgs, skip, limit, func(_, branchName string) error {
branchName = strings.TrimPrefix(branchName, trimPrefix)
countAll, err = walkShowRef(repoPath, extraArgs, skip, limit, func(branchName string) error {
branchNames = append(branchNames, branchName)
return nil
})
return branchNames, countAll, err
}

func walkShowRef(repoPath string, extraArgs []string, skip, limit int, walkfn func(sha1, refname string) error) (countAll int, err error) {
func walkShowRef(repoPath string, extraArgs []string, skip, limit int, walkfn func(refname string) error) (countAll int, err error) {
stdoutReader, stdoutWriter := io.Pipe()
defer func() {
_ = stdoutReader.Close()
@@ -196,7 +195,7 @@ func walkShowRef(repoPath string, extraArgs []string, skip, limit int, walkfn fu

go func() {
stderrBuilder := &strings.Builder{}
args := []string{"for-each-ref", "--format=%(objectname) %(refname)"}
args := []string{"for-each-ref", "--format=%(refname:short)"}
args = append(args, extraArgs...)
err := NewCommand(args...).RunInDirPipeline(repoPath, stdoutWriter, stderrBuilder)
if err != nil {
@@ -227,14 +226,6 @@ func walkShowRef(repoPath string, extraArgs []string, skip, limit int, walkfn fu
for limit == 0 || i < skip+limit {
// The output of show-ref is simply a list:
// <sha> SP <ref> LF
sha, err := bufReader.ReadString(' ')
if err == io.EOF {
return i, nil
}
if err != nil {
return 0, err
}

branchName, err := bufReader.ReadString('\n')
if err == io.EOF {
// This shouldn't happen... but we'll tolerate it for the sake of peace
@@ -248,11 +239,7 @@ func walkShowRef(repoPath string, extraArgs []string, skip, limit int, walkfn fu
branchName = branchName[:len(branchName)-1]
}

if len(sha) > 0 {
sha = sha[:len(sha)-1]
}

err = walkfn(sha, branchName)
err = walkfn(branchName)
if err != nil {
return i, err
}


+ 2
- 0
routers/api/v1/api.go View File

@@ -1036,6 +1036,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/show_model_convert_page", repo.ShowModelConvertPage)
m.Get("/query_model_convert_byId", repo.QueryModelConvertById)
m.Get("/query_model_convert_byName", repo.QueryModelConvertByName)
m.Get("/query_model_convert_resultfile", repo.QueryModeConvertResultFile)
m.Get("/download_model_convert_resultfile", repo.DownloadModeConvertResultFile)

m.Get("/:id", repo.GetCloudbrainModelConvertTask)
m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog)


+ 43
- 37
routers/api/v1/repo/cloudbrain.go View File

@@ -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")


+ 17
- 0
routers/api/v1/repo/modelmanage.go View File

@@ -170,3 +170,20 @@ func MultiModelDownload(ctx *context.APIContext) {
log.Info("MultiModelDownload by api.")
routerRepo.MultiModelDownload(ctx.Context)
}

func QueryModeConvertResultFile(ctx *context.APIContext) {
log.Info("QueryModeConvertResultFile by api.")
result, err := QueryModelConvertResultFileList(ctx, ctx.Query("id"))
if err == nil {
re := convertFileFormat(result)
ctx.JSON(http.StatusOK, re)
} else {
ctx.JSON(http.StatusOK, nil)
}
}

func DownloadModeConvertResultFile(ctx *context.APIContext) {
log.Info("QueryModeConvertResultFile by api.")
ctx.Context.SetParams("id", ctx.Query("id"))
routerRepo.ModelConvertDownloadModel(ctx.Context)
}

+ 10
- 2
templates/repo/issue/list.tmpl View File

@@ -6,6 +6,12 @@
overflow-y:hidden !important;
min-width: 140px!important;
}
.stay-top{
transform: rotate(180deg);
margin-right:0.3rem !important;
vertical-align:bottom;
font-size: 1rem !important;
}
</style>
{{template "base/head" .}}
<div class="repository">
@@ -245,10 +251,12 @@
</div>
{{end}}
<div class="ui {{if .IsClosed}}{{if .IsPull}}{{if .PullRequest.HasMerged}}purple{{else}}red{{end}}{{else}}red{{end}}{{else}}{{if .IsRead}}white{{else}}green{{end}}{{end}} label">#{{.Index}}</div>
<a class="title" href="{{$.Link}}/{{.Index}}">{{RenderEmoji .Title}}</a>
{{if gt .StayTop 0}}
<div class="ui label green" data="{{.StayTop}}">{{$.i18n.Tr "repo.issues.top"}}</div>
<div class="ui basic orange label" data="{{.StayTop}}"><i class="ri-download-line stay-top icon"></i>{{$.i18n.Tr "repo.issues.top"}}</div>
{{end}}
<a class="title" href="{{$.Link}}/{{.Index}}">{{RenderEmoji .Title}}</a>
{{if .IsPull }}
{{if (index $.CommitStatus .PullRequest.ID)}}
{{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}}


+ 1
- 1
templates/repo/issue/view_content/sidebar.tmpl View File

@@ -326,7 +326,7 @@
</div>
{{end}}

{{if and $.IssueWatch (not .Repository.IsArchived)}}
{{ if and .IsRepoAdmin (not .Repository.IsArchived) }}
<div class="ui divider"></div>

<div class="ui isToping">


+ 5
- 1
web_src/vuepages/langs/config/en-US.js View File

@@ -219,7 +219,11 @@ const en = {
graphicMemory: "Graphic Memory",
memory: "Memory",
sharedMemory: "Shared Memory",
tips: 'The newly created debugging task will be placed in the project openi-notebook under your name. If there is no such project, the system will automatically create a new one.'
tips: 'The newly created debugging task will be placed in the project openi-notebook under your name. If there is no such project, the system will automatically create a new one.',
balanceOfPoints: 'Balance of Points:',
points: 'points',
hours: 'Hours',
expected_time: ', expected to be available for',
},
modelManage: {
modelManage: 'Model management',


+ 5
- 1
web_src/vuepages/langs/config/zh-CN.js View File

@@ -220,7 +220,11 @@ const zh = {
graphicMemory: "显存",
memory: "内存",
sharedMemory: "共享内存",
tips: '本次新建的调试任务会放在您名下项目openi-notebook中,如果没有该项目系统会自动新建一个。'
tips: '本次新建的调试任务会放在您名下项目openi-notebook中,如果没有该项目系统会自动新建一个。',
balanceOfPoints: '积分余额:',
points: '积分',
hours: '小时',
expected_time: ',预计可用',
},
tranformImageFailed: '图片脱敏失败',
originPicture: '原始图片',


+ 42
- 8
web_src/vuepages/pages/notebook/debug/index.vue View File

@@ -109,7 +109,7 @@
<div class="resource-footer">
<div class="resource-operate" v-if="selectIndex==0">
<div v-if="btnStatus[0]===0">
<button class="ui green small button" @click="createTask(0)"></i>{{$t('notebook.newTask')}}</button>
<button class="ui green small button" @click="createTask(0)">{{$t('notebook.newTask')}}</button>
<span v-if="notebookInfo.waitCountGpu==0" class="text">{{$t('notebook.noQuene')}}</span>
<span v-else class="text">{{$t('notebook.queneTips1')}} <span style="color: red;">{{notebookInfo.waitCountGpu + 1}}</span> {{$t('notebook.queneTips2')}}</span>
</div>
@@ -132,7 +132,7 @@
<div class="resource-operate" v-if="selectIndex==2">
<div v-if="btnStatus[2]===0">
<button class="ui green small button" @click="createTask(2)"></i>{{$t('notebook.newTask')}}</button>
<button class="ui green small button" @click="createTask(2)">{{$t('notebook.newTask')}}</button>
<span v-if="notebookInfo.waitCountNpu==0" class="text">{{$t('notebook.noQuene')}}</span>
<span v-else class="text">{{$t('notebook.queneTips1')}} <span style="color: red;">{{notebookInfo.waitCountNpu + 1}}</span> {{$t('notebook.queneTips2')}}</span>
</div>
@@ -154,7 +154,7 @@
</div>
<div class="resource-operate" v-if="selectIndex==1">
<div v-if="btnStatus[1]===0">
<button class="ui green small button" @click="createTask(1)"></i>{{$t('notebook.newTask')}}</button>
<button class="ui green small button" @click="createTask(1)">{{$t('notebook.newTask')}}</button>
<span v-if="notebookInfo.waitCountGpu==0" class="text">{{$t('notebook.noQuene')}}</span>
<span v-else class="text">{{$t('notebook.queneTips1')}} <span style="color: red;">{{notebookInfo.waitCountGpu + 1}}</span> {{$t('notebook.queneTips2')}}</span>
</div>
@@ -174,8 +174,17 @@
<button class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>{{$t('notebook.stopping')}}</button>
</div>
</div>
</div>
<div style="max-width:35%;margin-left:15px;">
<div v-if="notebookInfo.cloudBrainPaySwitch && notebookInfo.PointAccount && !loading" class="text">
<span>{{ $t('notebook.balanceOfPoints') }}
<span style="color:rgb(250, 140, 22)">{{ notebookInfo.PointAccount.Balance }}</span>
{{ $t('notebook.points') }}<span v-show="useUnitPrice > 0">{{ $t('notebook.expected_time') }}
<span style="color:rgb(250, 140, 22)"> {{ useTime }} </span>
{{ $t('notebook.hours') }}</span>
</span>
</div>
</div>
</div>
</div>
</el-dialog>
</div>
@@ -228,7 +237,10 @@ export default {
deubgUrlNpuStop:'',
deubgUrlGpuStop:'',
loading:false,
activeLoadFirst:true
activeLoadFirst:true,

useUnitPrice: '',
useTime: '',
};
},
methods: {
@@ -251,6 +263,21 @@ export default {
this.selectIndex = index;
this.initSelect = false
this.alertCb = false
this.getPointInfo()
},
getPointInfo() {
if (this.notebookInfo.cloudBrainPaySwitch && this.notebookInfo.PointAccount) {
const blance = this.notebookInfo.PointAccount.Balance;
if (this.selectIndex == 0) {
this.useUnitPrice = this.notebookInfo.specCpu.unit_price;
} else if (this.selectIndex == 1) {
this.useUnitPrice = this.notebookInfo.specGpu.unit_price;
} else if (this.selectIndex == 2) {
this.useUnitPrice = this.notebookInfo.specNpu.unit_price;
}
this.useTime = (blance / this.useUnitPrice).toFixed(2);
if (blance < this.useUnitPrice) this.useTime = '0.00';
}
},
getNotebookInfo(){
if(this.activeLoadFirst){
@@ -259,6 +286,7 @@ export default {
getFileNotebook().then((res)=>{
if(res.data.code==0){
this.notebookInfo = res.data
this.getPointInfo()
}else{
Message.error(res.data.message)
}
@@ -449,12 +477,14 @@ export default {
that.getNotebookInfo()
that.dialogVisible = true;
that.selectIndex = Number(new URLSearchParams(window.location.search).get("card"))
that.getPointInfo()
}
document
.querySelector("#notebook-debug")
.addEventListener("click", function () {
that.getNotebookInfo()
that.dialogVisible = true;
that.getPointInfo()
});
},
};
@@ -508,7 +538,7 @@ export default {
color: #f2711c;
}
.alert-info{
width: 70%;
width: 75%;
background-color: rgba(242, 113, 28, 0.05);
border: 1px solid rgb(242, 113, 28);
border-radius: 5px;
@@ -519,7 +549,7 @@ export default {
border:none;
}
.three-resource-type {
width: 70%;
width: 75%;
margin: 0 auto;
display: flex;
border-top: 1px solid rgba(16, 16, 16, 0.1);
@@ -621,6 +651,7 @@ export default {
height: 71px;
display: flex;
align-items: center;
justify-content: space-between;
.resource-operate {
display: flex;
align-items: center;
@@ -629,6 +660,9 @@ export default {
margin-left: 20px;
}
}
.text {
color: #101010;
}
}
.slide-in-top {
-webkit-animation: slide-in-top 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;


Loading…
Cancel
Save
Baidu
map