Browse Source

解决冲突

tags/v1.22.7.2^2
zhoupzh 3 years ago
parent
commit
b9d2ee2dd4
19 changed files with 110 additions and 58 deletions
  1. +14
    -10
      models/dbsql/dataset_foreigntable_for_es.sql
  2. +1
    -1
      models/dbsql/repo_foreigntable_for_es.sql
  3. +3
    -0
      models/repo_activity_custom.go
  4. +1
    -1
      models/user_analysis_for_activity.go
  5. +2
    -2
      modules/cloudbrain/cloudbrain.go
  6. +1
    -1
      modules/git/repo_stats_custom.go
  7. +14
    -8
      routers/repo/cloudbrain.go
  8. +1
    -1
      routers/repo/modelarts.go
  9. +26
    -2
      routers/search.go
  10. +3
    -3
      routers/user/profile.go
  11. +2
    -2
      templates/admin/cloudbrain/list.tmpl
  12. +2
    -2
      templates/repo/cloudbrain/benchmark/show.tmpl
  13. +2
    -2
      templates/repo/cloudbrain/inference/show.tmpl
  14. +2
    -2
      templates/repo/cloudbrain/show.tmpl
  15. +2
    -2
      templates/repo/cloudbrain/trainjob/show.tmpl
  16. +2
    -2
      templates/repo/modelarts/notebook/show.tmpl
  17. +27
    -13
      web_src/js/components/MinioUploader.vue
  18. +3
    -3
      web_src/js/components/Model.vue
  19. +2
    -1
      web_src/js/components/dataset/selectDataset.vue

+ 14
- 10
models/dbsql/dataset_foreigntable_for_es.sql View File

@@ -158,16 +158,20 @@ DROP TRIGGER IF EXISTS es_update_dataset on public.dataset;
CREATE OR REPLACE FUNCTION public.update_dataset() RETURNS trigger AS
$def$
BEGIN
UPDATE public.dataset_es
SET description=NEW.description,
title=NEW.title,
category=NEW.category,
task=NEW.task,
download_times=NEW.download_times,
updated_unix=NEW.updated_unix,
file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false),
file_desc=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false)
where id=NEW.id;
if (NEW.status=0) then
delete from public.dataset_es where id=NEW.id;
elsif (NEW.status=1) then
UPDATE public.dataset_es
SET description=NEW.description,
title=NEW.title,
category=NEW.category,
task=NEW.task,
download_times=NEW.download_times,
updated_unix=NEW.updated_unix,
file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false),
file_desc=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false)
where id=NEW.id;
end if;
return new;
END
$def$


+ 1
- 1
models/dbsql/repo_foreigntable_for_es.sql View File

@@ -461,7 +461,7 @@ $def$

if not OLD.is_private and NEW.is_private then
delete from public.issue_es where repo_id=NEW.id;
delete from public.dataset_es where repo_id=NEW.id;
-- delete from public.dataset_es where repo_id=NEW.id;
delete from public.repository_es where id=NEW.id;
end if;



+ 3
- 0
models/repo_activity_custom.go View File

@@ -238,6 +238,9 @@ func GetAllUserPublicRepoKPIStats(startTime time.Time, endTime time.Time) (map[s
CommitLines: 0,
}
}
if value.Email == "1250125907@qq.com" || value.Email == "peiyongyu-34@163.com" {
log.Info("repo path=" + repository.RepoPath())
}
authors[key].Commits += value.Commits
authors[key].CommitLines += value.CommitLines



+ 1
- 1
models/user_analysis_for_activity.go View File

@@ -195,7 +195,7 @@ func queryPullRequestPublic(start_unix int64, end_unix int64, publicAllRepo map[
sess := x.NewSession()
defer sess.Close()
resultMap := make(map[int64]int)
cond := "pull_request.merged_unix>=" + fmt.Sprint(start_unix) + " and pull_request.merged_unix<=" + fmt.Sprint(end_unix)
cond := "issue.created_unix>=" + fmt.Sprint(start_unix) + " and issue.created_unix<=" + fmt.Sprint(end_unix)
count, err := sess.Table("issue").Join("inner", "pull_request", "issue.id=pull_request.issue_id").Where(cond).Count(new(Issue))
if err != nil {
log.Info("query issue error. return.")


+ 2
- 2
modules/cloudbrain/cloudbrain.go View File

@@ -326,7 +326,7 @@ func GenerateTask(req GenerateCloudBrainTaskReq) error {
ReadOnly: true,
},
})
} else {
} else if len(req.DatasetInfos) > 1 {
for _, dataset := range req.DatasetInfos {
volumes = append(volumes, models.Volume{
HostPath: models.StHostPath{
@@ -547,7 +547,7 @@ func RestartTask(ctx *context.Context, task *models.Cloudbrain, newID *string) e
GPUNumber: resourceSpec.GpuNum,
MemoryMB: resourceSpec.MemMiB,
ShmMB: resourceSpec.ShareMemMiB,
Command: GetCloudbrainDebugCommand(),//Command,
Command: GetCloudbrainDebugCommand(), //Command,
NeedIBDevice: false,
IsMainRole: false,
UseNNI: false,


+ 1
- 1
modules/git/repo_stats_custom.go View File

@@ -62,7 +62,7 @@ func GetUserKPIStats(repoPath string, startTime time.Time, endTime time.Time) (m

after := startTime.Format(time.RFC3339)
until := endTime.Format(time.RFC3339)
args := []string{"log", "--numstat", "--no-merges", "--branches=*", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--after='%s'", after), fmt.Sprintf("--until=='%s'", until)}
args := []string{"log", "--numstat", "--no-merges", "--branches=*", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--after='%s'", after), fmt.Sprintf("--until='%s'", until)}
stdout, err := NewCommand(args...).RunInDirBytes(repoPath)
if err != nil {
return nil, err


+ 14
- 8
routers/repo/cloudbrain.go View File

@@ -2,7 +2,6 @@ package repo

import (
"bufio"
"code.gitea.io/gitea/modules/notification"
"encoding/json"
"errors"
"fmt"
@@ -16,6 +15,8 @@ import (
"time"
"unicode/utf8"

"code.gitea.io/gitea/modules/notification"

"code.gitea.io/gitea/modules/grampus"

"code.gitea.io/gitea/modules/timeutil"
@@ -475,6 +476,7 @@ func CloudBrainNew(ctx *context.Context) {
ctx.ServerError("get new cloudbrain info failed", err)
return
}
ctx.Data["PageIsGPUDebug"] = true
ctx.HTML(200, tplCloudBrainNew)
}

@@ -540,13 +542,17 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
return
}
}

datasetInfos, datasetNames, err := models.GetDatasetInfo(uuids)
if err != nil {
log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"])
cloudBrainTrainJobErrorPrepare(ctx, form)
ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tpl, &form)
return
var datasetInfos map[string]models.DatasetInfo
var datasetNames string
//var
if uuids != "" {
datasetInfos, datasetNames, err = models.GetDatasetInfo(uuids)
if err != nil {
log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tpl, &form)
return
}
}

command := cloudbrain.GetCloudbrainDebugCommand()


+ 1
- 1
routers/repo/modelarts.go View File

@@ -545,7 +545,7 @@ func NotebookDel(ctx *context.Context) {
var listType = ctx.Query("debugListType")
task := ctx.Cloudbrain

if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) {
if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsDeleted) {
log.Error("the job(%s) has not been stopped", task.JobName)
ctx.RenderWithErr("the job has not been stopped", tplDebugJobIndex, nil)
return


+ 26
- 2
routers/search.go View File

@@ -313,9 +313,8 @@ func searchRepo(ctx *context.Context, TableName string, Key string, Page int, Pa

res, err := client.Search(TableName).Query(boolQ).SortBy(getSort(SortBy, ascending, "num_stars", false)...).From(from).Size(Size).Highlight(queryHighlight("alias", "description", "topics")).Do(ctx.Req.Context())
if err == nil {
searchJson, _ := json.Marshal(res)
log.Info("searchJson=" + string(searchJson))
esresult := makeRepoResult(res, Key, OnlyReturnNum, language)
setForkRepoOrder(esresult)
resultObj.Total = resultObj.PrivateTotal + esresult.Total
isNeedSort := false
if len(resultObj.Result) > 0 {
@@ -348,6 +347,30 @@ func searchRepo(ctx *context.Context, TableName string, Key string, Page int, Pa
}
}

func setForkRepoOrder(esresult *SearchRes) {
forkidMap := make(map[string]int, 0)
for index, re := range esresult.Result {
if re["fork_id"] != nil {
fork_id := re["fork_id"].(string)
if _, ok := forkidMap[fork_id]; !ok {
forkidMap[fork_id] = index
}
}
}
for key, value := range forkidMap {
for index, re := range esresult.Result {
if re["id"].(string) == key {
if value < index { //swap
tmp := esresult.Result[index]
esresult.Result[index] = esresult.Result[value]
esresult.Result[value] = tmp
break
}
}
}
}
}

func sortRepo(Result []map[string]interface{}, SortBy string, ascending bool) {
orderBy := ""
switch SortBy {
@@ -479,6 +502,7 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool,
record["num_stars"] = recordSource["num_stars"]
record["num_forks"] = recordSource["num_forks"]
record["lower_alias"] = recordSource["lower_alias"]
record["fork_id"] = recordSource["fork_id"]
if recordSource["topics"] != nil {
topicsStr := recordSource["topics"].(string)
log.Info("topicsStr=" + topicsStr)


+ 3
- 3
routers/user/profile.go View File

@@ -116,8 +116,8 @@ func Profile(ctx *context.Context) {
}

var opts = models.FindOrgMembersOpts{
OrgID: org.ID,
PublicOnly: true,
OrgID: org.ID,
PublicOnly: true,
}

if ctx.User != nil {
@@ -261,7 +261,7 @@ func Profile(ctx *context.Context) {
IsOwner: isOwner,
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.ExplorePagingNum,
PageSize: setting.UI.User.RepoPagingNum,
},
CloudBrainType: -1,
}


+ 2
- 2
templates/admin/cloudbrain/list.tmpl View File

@@ -107,8 +107,8 @@
</a>
{{else if eq .JobType "INFERENCE"}}
<a class="title"
href="{{AppSubUrl}}/{{.Repo.OwnerName}}/{{.Repo.Name}}/modelarts/inference-job/{{$JobID}}"
title="{{.DisplayJobName}}" style="font-size: 14px;padding-right:0px">
href="{{AppSubUrl}}/{{.Repo.OwnerName}}/{{.Repo.Name}}/{{if eq .Cloudbrain.Type 1}}modelarts{{else if eq .Cloudbrain.Type 0}}cloudbrain{{end}}/inference-job/{{$JobID}}"
title="{{.DisplayJobName}}" style="font-size: 14px;">
<span class="fitted"
style="width: 90%;vertical-align: middle;">{{.DisplayJobName}}</span>
</a>


+ 2
- 2
templates/repo/cloudbrain/benchmark/show.tmpl View File

@@ -353,14 +353,14 @@

<td class="ti-text-form-content">
<div class="text-span text-span-w" id="{{.VersionName}}-mirror">
<span class="ui poping up clipboard" title="{{.Image}}" data-position="top center" id="clipboard-btn" style="cursor:pointer"
<span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer"
data-clipboard-text="{{.Image}}"
data-success="{{$.i18n.Tr "repo.copy_link_success"}}"
data-error="{{$.i18n.Tr "repo.copy_link_error"}}"
data-content="{{$.i18n.Tr "repo.copy_link"}}"
data-variation="inverted tiny"
>
{{.Image}}
<span title="{{.Image}}">{{.Image}}</span>
</span>
</div>
</td>


+ 2
- 2
templates/repo/cloudbrain/inference/show.tmpl View File

@@ -381,14 +381,14 @@

<td class="ti-text-form-content">
<div class="text-span text-span-w" id="{{.VersionName}}-mirror">
<span class="ui poping up clipboard" title="{{.Image}}" data-position="top center" id="clipboard-btn" style="cursor:pointer"
<span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer"
data-clipboard-text="{{.Image}}"
data-success="{{$.i18n.Tr "repo.copy_link_success"}}"
data-error="{{$.i18n.Tr "repo.copy_link_error"}}"
data-content="{{$.i18n.Tr "repo.copy_link"}}"
data-variation="inverted tiny"
>
{{.Image}}
<span title="{{.Image}}">{{.Image}}</span>
</span>
</div>
</td>


+ 2
- 2
templates/repo/cloudbrain/show.tmpl View File

@@ -392,14 +392,14 @@

<td class="ti-text-form-content">
<div class="text-span text-span-w" id="{{.VersionName}}-mirror">
<span class="ui poping up clipboard" title="{{.Image}}" data-position="top center" id="clipboard-btn" style="cursor:pointer"
<span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer"
data-clipboard-text="{{.Image}}"
data-success="{{$.i18n.Tr "repo.copy_link_success"}}"
data-error="{{$.i18n.Tr "repo.copy_link_error"}}"
data-content="{{$.i18n.Tr "repo.copy_link"}}"
data-variation="inverted tiny"
>
{{.Image}}
<span title="{{.Image}}">{{.Image}}</span>
</span>
</div>
</td>


+ 2
- 2
templates/repo/cloudbrain/trainjob/show.tmpl View File

@@ -384,14 +384,14 @@

<td class="ti-text-form-content">
<div class="text-span text-span-w" id="{{.VersionName}}-mirror">
<span class="ui poping up clipboard" title="{{.Image}}" data-position="top center" id="clipboard-btn" style="cursor:pointer"
<span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer"
data-clipboard-text="{{.Image}}"
data-success="{{$.i18n.Tr "repo.copy_link_success"}}"
data-error="{{$.i18n.Tr "repo.copy_link_error"}}"
data-content="{{$.i18n.Tr "repo.copy_link"}}"
data-variation="inverted tiny"
>
{{.Image}}
<span title="{{.Image}}">{{.Image}}</span>
</span>
</div>
</td>


+ 2
- 2
templates/repo/modelarts/notebook/show.tmpl View File

@@ -359,14 +359,14 @@

<td class="ti-text-form-content">
<div class="text-span text-span-w" id="{{.VersionName}}-mirror">
<span class="ui poping up clipboard" title="{{.Image}}" data-position="top center" id="clipboard-btn" style="cursor:pointer"
<span class="ui poping up clipboard" data-position="top center" id="clipboard-btn" style="cursor:pointer"
data-clipboard-text="{{.Image}}"
data-success="{{$.i18n.Tr "repo.copy_link_success"}}"
data-error="{{$.i18n.Tr "repo.copy_link_error"}}"
data-content="{{$.i18n.Tr "repo.copy_link"}}"
data-variation="inverted tiny"
>
{{.Image}}
<span title="{{.Image}}">{{.Image}}</span>
</span>
</div>
</td>


+ 27
- 13
web_src/js/components/MinioUploader.vue View File

@@ -135,10 +135,10 @@ export default {
allUploadLength(len){
if(len===this.uploadFiles.length){
setTimeout(() => {
this.dropzoneUploader.removeAllFiles(true)
this.btnFlag = false
this.$emit('setcluster',this.btnFlag)
}, 2000);
this.dropzoneUploader.removeAllFiles(true)
this.btnFlag = false
this.$emit('setcluster',this.btnFlag)
}, 2000);
}
}
},
@@ -254,7 +254,7 @@ export default {
(currentChunk / chunks) *
100
).toFixed(2)}% (${currentChunk}/${chunks})`;
this.updateProgress(file, ((currentChunk / chunks) * 100).toFixed(2));
// this.updateProgress(file, ((currentChunk / chunks) * 100).toFixed(2));
loadMd5Next();
return;
}
@@ -265,7 +265,7 @@ export default {
file.size
} 用时:${(new Date().getTime() - time) / 1000} s`
);
this.updateProgress(file,100)
// this.updateProgress(file,100)
spark.destroy(); // 释放缓存
file.uniqueIdentifier = md5; // 将文件md5赋值给文件唯一标识
file.cmd5 = false; // 取消计算md5状态
@@ -297,11 +297,11 @@ export default {
file.chunks = '';
this.multipartUpload(file);
} else {
// 失败如何处理
let info = "上传失败"
this.allUploadLength++
this.uploadError(file,info)
this.allUploadFiles.push({name:file.name,status:2,info:info})
// 失败如何处理
let info = "上传失败"
this.allUploadLength++
this.uploadError(file,info)
this.allUploadFiles.push({name:file.name,status:2,info:info})
return;
}
return;
@@ -321,12 +321,16 @@ export default {
this.uploadError(file,info)
this.allUploadLength++
this.allUploadFiles.push({name:file.name,status:1,info:info})
return;
}
}
}
console.log('文件已上传完成');
this.allUploadLength++
this.allUploadFiles.push({name:file.name,status:0,info:'上传成功'})
this.updateProgress(file, 100);
this.progress = 100;
this.status = this.dropzoneParams.data('upload-complete');
// this.finishUpload(file);
this.finishUpload(file);
} else {
// 断点续传
this.multipartUpload(file);
@@ -334,6 +338,10 @@ export default {
} catch (error) {
this.emitDropzoneFailed(file);
console.log(error);
let info = "上传失败"
this.allUploadLength++
this.uploadError(file,info)
this.allUploadFiles.push({name:file.name,status:2,info:info})
}

async function addAttachment(file) {
@@ -503,6 +511,7 @@ export default {
console.log(error);
//this.emitDropzoneFailed(file);
//console.log(error);
throw error;
}
}

@@ -538,6 +547,11 @@ export default {
await uploadChunk(e);
}catch(err){
console.log(err)
let info = "上传失败"
this.allUploadLength++
this.uploadError(file,info)
this.allUploadFiles.push({name:file.name,status:2,info:info});
return;
}
fileReader.abort();


+ 3
- 3
web_src/js/components/Model.vue View File

@@ -106,7 +106,7 @@
<div class="space-around">
<a :style="{visibility:!scope.row.Children ? 'visible':'hidden'}" :class="{'disabled':!scope.row.IsCanOper}" @click="showcreateVue(scope.row.Name,scope.row.Version,scope.row.Label)">创建新版本</a>
<a :href="loadhref+scope.row.ID" :class="{'disabled':!scope.row.IsCanOper}">下载</a>
<a :class="{'disabled':!scope.row.IsCanDelete}" @click="deleteModel(scope.row.ID,scope.row.cName)">删除</a>
<a :class="{'disabled':!scope.row.IsCanDelete}" @click="deleteModel(scope.row.ID,scope.row.cName,scope.row.rowKey)">删除</a>
</div>
</template>
@@ -332,8 +332,8 @@ export default {
}
},
deleteModel(id,name){
let row={cName:name,ID:id}
deleteModel(id,name,rowKey){
let row={cName:name,ID:id, rowKey: rowKey}
let _this = this
let flag=1
$('.ui.basic.modal.first')


+ 2
- 1
web_src/js/components/dataset/selectDataset.vue View File

@@ -955,7 +955,8 @@ export default {
) {
this.benchmarkNew = true;
}
if (location.href.indexOf("modelarts/notebook/create") !== -1) {
if (location.href.indexOf("modelarts/notebook/create") !== -1 || location.href.indexOf("/cloudbrain/create") !== -1) {
console.log("required is false;");
this.required = false;
}
window.onresize = () => {


Loading…
Cancel
Save