From 36e88d0ab48cb5f7811b512257cab1a7de52a9b9 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 14 Mar 2022 17:43:48 +0800 Subject: [PATCH 001/129] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=86=E6=9E=90=E4=B8=AD=E7=9A=84=E4=BB=A3=E7=A0=81=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 61 ++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 288762161..1c87f5d08 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -6,7 +6,6 @@ import ( "strconv" "time" - "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" @@ -353,7 +352,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus return userBusinessAnalysisReturnList, count } -func refreshUserStaticTable(wikiCountMap map[string]int, CommitCodeSizeMap map[string]*git.UserKPIStats, tableName string, pageStartTime time.Time, pageEndTime time.Time) { +func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageStartTime time.Time, pageEndTime time.Time) { sess := x.NewSession() defer sess.Close() @@ -379,7 +378,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, CommitCodeSizeMap map[s FocusRepoCountMap := queryWatch(start_unix, end_unix) StarRepoCountMap := queryStar(start_unix, end_unix) WatchedCountMap := queryFollow(start_unix, end_unix) - + CommitCodeSizeMap := queryCommitCodeSize(start_unix, end_unix) CommitDatasetSizeMap := queryDatasetSize(start_unix, end_unix) SolveIssueCountMap := querySolveIssue(start_unix, end_unix) CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) @@ -455,10 +454,10 @@ func refreshUserStaticTable(wikiCountMap map[string]int, CommitCodeSizeMap map[s dateRecordAll.WatchedCount = WatchedCountMap[dateRecordAll.ID] } - if _, ok := CommitCodeSizeMap[dateRecordAll.Email]; !ok { + if _, ok := CommitCodeSizeMap[dateRecordAll.ID]; !ok { dateRecordAll.CommitCodeSize = 0 } else { - dateRecordAll.CommitCodeSize = int(CommitCodeSizeMap[dateRecordAll.Email].CommitLines) + dateRecordAll.CommitCodeSize = CommitCodeSizeMap[dateRecordAll.ID] } if _, ok := CommitDatasetSizeMap[dateRecordAll.ID]; !ok { @@ -546,36 +545,36 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static statictisSess.Exec(insertBatchSql) } -func RefreshUserStaticAllTabel(wikiCountMap map[string]int, CommitCodeSizeMap map[string]*git.UserKPIStats) { +func RefreshUserStaticAllTabel(wikiCountMap map[string]int) { currentTimeNow := time.Now() pageStartTime := time.Date(2021, 11, 5, 0, 0, 0, 0, currentTimeNow.Location()) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_all", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_all", pageStartTime, pageEndTime) log.Info("refresh all data finished.") pageStartTime = time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_current_year", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_year", pageStartTime, pageEndTime) thisMonth := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_current_month", thisMonth, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_month", thisMonth, pageEndTime) offset := int(time.Monday - currentTimeNow.Weekday()) if offset > 0 { offset = -6 } pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_current_week", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_week", pageStartTime, pageEndTime) pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -30) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_last30_day", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_last30_day", pageStartTime, pageEndTime) pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -1) pageEndTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_yesterday", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_yesterday", pageStartTime, pageEndTime) pageStartTime = thisMonth.AddDate(0, -1, 0) pageEndTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) - refreshUserStaticTable(wikiCountMap, CommitCodeSizeMap, "user_business_analysis_last_month", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_last_month", pageStartTime, pageEndTime) } @@ -747,7 +746,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } } - RefreshUserStaticAllTabel(wikiCountMap, CommitCodeSizeMap) + RefreshUserStaticAllTabel(wikiCountMap) return nil } @@ -1212,6 +1211,40 @@ func queryLoginCount(start_unix int64, end_unix int64) map[int64]int { return resultMap } +func queryCommitCodeSize(start_unix int64, end_unix int64) map[int64]int { + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + + resultMap := make(map[int64]int) + cond := "count_date>=" + fmt.Sprint(start_unix) + " and count_date<=" + fmt.Sprint(end_unix) + count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) + if err != nil { + log.Info("query commit code size error. return.") + return resultMap + } + var indexTotal int64 + indexTotal = 0 + for { + statictisSess.Select("id,commit_code_size").Table("user_business_analysis").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) + userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) + statictisSess.Find(&userBusinessAnalysisList) + log.Info("query user login size=" + fmt.Sprint(len(userBusinessAnalysisList))) + for _, analysisRecord := range userBusinessAnalysisList { + if _, ok := resultMap[analysisRecord.ID]; !ok { + resultMap[analysisRecord.ID] = analysisRecord.CommitCodeSize + } else { + resultMap[analysisRecord.ID] += analysisRecord.CommitCodeSize + } + } + indexTotal += PAGE_SIZE + if indexTotal >= count { + break + } + } + log.Info("user commit code size=" + fmt.Sprint(len(resultMap))) + return resultMap +} + func subMonth(t1, t2 time.Time) (month int) { y1 := t1.Year() y2 := t2.Year() From 292236988b38327f9c7527462cc97307b1f6efa2 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 17 Mar 2022 10:21:46 +0800 Subject: [PATCH 002/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 365 +++++++++++++++++-------------- models/user_business_struct.go | 72 ++++++ 2 files changed, 278 insertions(+), 159 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 1c87f5d08..e059ef3e4 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -80,6 +80,19 @@ type UserBusinessAnalysisAll struct { Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + //cloudbraintask + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysis struct { @@ -145,6 +158,18 @@ type UserBusinessAnalysis struct { Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysisQueryOptions struct { @@ -333,6 +358,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus resultMap[userRecord.ID].WatchedCount += userRecord.WatchedCount resultMap[userRecord.ID].CommitCodeSize += userRecord.CommitCodeSize resultMap[userRecord.ID].CommitDatasetSize += userRecord.CommitDatasetSize + resultMap[userRecord.ID].CommitDatasetNum += userRecord.CommitDatasetNum resultMap[userRecord.ID].CommitModelCount += userRecord.CommitModelCount resultMap[userRecord.ID].SolveIssueCount += userRecord.SolveIssueCount resultMap[userRecord.ID].EncyclopediasCount += userRecord.EncyclopediasCount @@ -379,13 +405,14 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS StarRepoCountMap := queryStar(start_unix, end_unix) WatchedCountMap := queryFollow(start_unix, end_unix) CommitCodeSizeMap := queryCommitCodeSize(start_unix, end_unix) - CommitDatasetSizeMap := queryDatasetSize(start_unix, end_unix) + CommitDatasetSizeMap, CommitDatasetNumMap := queryDatasetSize(start_unix, end_unix) SolveIssueCountMap := querySolveIssue(start_unix, end_unix) CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) LoginCountMap := queryLoginCount(start_unix, end_unix) OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) - + CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) + AiModelManageMap := queryUserModel(start_unix, end_unix) DataDate := currentTimeNow.Format("2006-01-02") + " 00:01" cond := "type != 1 and is_active=true" @@ -411,84 +438,22 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.Name = userRecord.Name dateRecordAll.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) dateRecordAll.DataDate = DataDate - - if _, ok := CodeMergeCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.CodeMergeCount = 0 - } else { - dateRecordAll.CodeMergeCount = CodeMergeCountMap[dateRecordAll.ID] - } - - if _, ok := CommitCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.CommitCount = 0 - } else { - dateRecordAll.CommitCount = CommitCountMap[dateRecordAll.ID] - } - - if _, ok := IssueCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.IssueCount = 0 - } else { - dateRecordAll.IssueCount = IssueCountMap[dateRecordAll.ID] - } - - if _, ok := CommentCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.CommentCount = 0 - } else { - dateRecordAll.CommentCount = CommentCountMap[dateRecordAll.ID] - } - - if _, ok := FocusRepoCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.FocusRepoCount = 0 - } else { - dateRecordAll.FocusRepoCount = FocusRepoCountMap[dateRecordAll.ID] - } - - if _, ok := StarRepoCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.StarRepoCount = 0 - } else { - dateRecordAll.StarRepoCount = StarRepoCountMap[dateRecordAll.ID] - } - - if _, ok := WatchedCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.WatchedCount = 0 - } else { - dateRecordAll.WatchedCount = WatchedCountMap[dateRecordAll.ID] - } - - if _, ok := CommitCodeSizeMap[dateRecordAll.ID]; !ok { - dateRecordAll.CommitCodeSize = 0 - } else { - dateRecordAll.CommitCodeSize = CommitCodeSizeMap[dateRecordAll.ID] - } - - if _, ok := CommitDatasetSizeMap[dateRecordAll.ID]; !ok { - dateRecordAll.CommitDatasetSize = 0 - } else { - dateRecordAll.CommitDatasetSize = CommitDatasetSizeMap[dateRecordAll.ID] - } - - if _, ok := SolveIssueCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.SolveIssueCount = 0 - } else { - dateRecordAll.SolveIssueCount = SolveIssueCountMap[dateRecordAll.ID] - } - - if _, ok := wikiCountMap[dateRecordAll.Name]; !ok { - dateRecordAll.EncyclopediasCount = 0 - } else { - dateRecordAll.EncyclopediasCount = wikiCountMap[dateRecordAll.Name] - } - - if _, ok := CreateRepoCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.CreateRepoCount = 0 - } else { - dateRecordAll.CreateRepoCount = CreateRepoCountMap[dateRecordAll.ID] - } - - if _, ok := LoginCountMap[dateRecordAll.ID]; !ok { - dateRecordAll.LoginCount = 0 - } else { - dateRecordAll.LoginCount = LoginCountMap[dateRecordAll.ID] - } + dateRecordAll.UserLocation = userRecord.Location + + dateRecordAll.CodeMergeCount = getMapValue(dateRecordAll.ID, CodeMergeCountMap) + dateRecordAll.CommitCount = getMapValue(dateRecordAll.ID, CommitCountMap) + dateRecordAll.IssueCount = getMapValue(dateRecordAll.ID, IssueCountMap) + dateRecordAll.CommentCount = getMapValue(dateRecordAll.ID, CommentCountMap) + dateRecordAll.FocusRepoCount = getMapValue(dateRecordAll.ID, FocusRepoCountMap) + dateRecordAll.StarRepoCount = getMapValue(dateRecordAll.ID, StarRepoCountMap) + dateRecordAll.WatchedCount = getMapValue(dateRecordAll.ID, WatchedCountMap) + dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) + dateRecordAll.CommitDatasetSize = getMapValue(dateRecordAll.ID, CommitDatasetSizeMap) + dateRecordAll.CommitDatasetNum = getMapValue(dateRecordAll.ID, CommitDatasetNumMap) + dateRecordAll.SolveIssueCount = getMapValue(dateRecordAll.ID, SolveIssueCountMap) + dateRecordAll.EncyclopediasCount = getMapKeyStringValue(dateRecordAll.Name, wikiCountMap) + dateRecordAll.CreateRepoCount = getMapValue(dateRecordAll.ID, CreateRepoCountMap) + dateRecordAll.LoginCount = getMapValue(dateRecordAll.ID, LoginCountMap) if _, ok := OpenIIndexMap[dateRecordAll.ID]; !ok { dateRecordAll.OpenIIndex = 0 @@ -496,7 +461,15 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.OpenIIndex = OpenIIndexMap[dateRecordAll.ID] } - dateRecordAll.CommitModelCount = 0 + dateRecordAll.CloudBrainTaskNum = getMapValue(dateRecordAll.ID, CloudBrainTaskMap) + dateRecordAll.GpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuDebugJob", CloudBrainTaskItemMap) + dateRecordAll.NpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuDebugJob", CloudBrainTaskItemMap) + dateRecordAll.GpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuTrainJob", CloudBrainTaskItemMap) + dateRecordAll.NpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuTrainJob", CloudBrainTaskItemMap) + dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) + dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) + dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) + //dateRecordAll.UserIndex = getUserIndex(dateRecordAll) dateRecordBatch = append(dateRecordBatch, dateRecordAll) if len(dateRecordBatch) >= BATCH_INSERT_SIZE { @@ -528,7 +501,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static insertBatchSql := "INSERT INTO public." + tableName + "(id, count_date, code_merge_count, commit_count, issue_count, comment_count, focus_repo_count, star_repo_count, watched_count, gitea_age_month, commit_code_size, commit_dataset_size, " + - "commit_model_count, solve_issue_count, encyclopedias_count, regist_date, create_repo_count, login_count, open_i_index, email, name, data_date) " + + "commit_model_count, solve_issue_count, encyclopedias_count, regist_date, create_repo_count, login_count, open_i_index, email, name, data_date,cloud_brain_task_num,gpu_debug_job,npu_debug_job,gpu_train_job,npu_train_job,npu_inference_job,gpu_bench_mark_job,cloud_brain_run_time,commit_dataset_num,user_index,user_location) " + "VALUES" for i, record := range dateRecords { @@ -536,7 +509,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static ", " + fmt.Sprint(record.IssueCount) + ", " + fmt.Sprint(record.CommentCount) + ", " + fmt.Sprint(record.FocusRepoCount) + ", " + fmt.Sprint(record.StarRepoCount) + ", " + fmt.Sprint(record.WatchedCount) + ", " + fmt.Sprint(record.GiteaAgeMonth) + ", " + fmt.Sprint(record.CommitCodeSize) + ", " + fmt.Sprint(record.CommitDatasetSize) + ", " + fmt.Sprint(record.CommitModelCount) + ", " + fmt.Sprint(record.SolveIssueCount) + ", " + fmt.Sprint(record.EncyclopediasCount) + ", " + fmt.Sprint(record.RegistDate) + - ", " + fmt.Sprint(record.CreateRepoCount) + ", " + fmt.Sprint(record.LoginCount) + ", " + fmt.Sprint(record.OpenIIndex) + ", '" + record.Email + "', '" + record.Name + "', '" + record.DataDate + "')" + ", " + fmt.Sprint(record.CreateRepoCount) + ", " + fmt.Sprint(record.LoginCount) + ", " + fmt.Sprint(record.OpenIIndex) + ", '" + record.Email + "', '" + record.Name + "', '" + record.DataDate + "'," + fmt.Sprint(record.CloudBrainTaskNum) + "," + fmt.Sprint(record.GpuDebugJob) + "," + fmt.Sprint(record.NpuDebugJob) + "," + fmt.Sprint(record.GpuTrainJob) + "," + fmt.Sprint(record.NpuTrainJob) + "," + fmt.Sprint(record.NpuInferenceJob) + "," + fmt.Sprint(record.GpuBenchMarkJob) + "," + fmt.Sprint(record.CloudBrainRunTime) + "," + fmt.Sprint(record.CommitDatasetNum) + "," + fmt.Sprint(record.UserIndex) + ",'" + record.UserLocation + "')" if i < (len(dateRecords) - 1) { insertBatchSql += "," } @@ -612,12 +585,13 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } else { log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) } - CommitDatasetSizeMap := queryDatasetSize(start_unix, end_unix) + CommitDatasetSizeMap, CommitDatasetNumMap := queryDatasetSize(start_unix, end_unix) SolveIssueCountMap := querySolveIssue(start_unix, end_unix) CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) LoginCountMap := queryLoginCount(start_unix, end_unix) OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix) - + CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) + AiModelManageMap := queryUserModel(start_unix, end_unix) statictisSess := xStatistic.NewSession() defer statictisSess.Close() @@ -647,47 +621,14 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.Name = userRecord.Name dateRecord.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) dateRecord.DataDate = DataDate - if _, ok := CodeMergeCountMap[dateRecord.ID]; !ok { - dateRecord.CodeMergeCount = 0 - } else { - dateRecord.CodeMergeCount = CodeMergeCountMap[dateRecord.ID] - } - if _, ok := CommitCountMap[dateRecord.ID]; !ok { - dateRecord.CommitCount = 0 - } else { - dateRecord.CommitCount = CommitCountMap[dateRecord.ID] - } - - if _, ok := IssueCountMap[dateRecord.ID]; !ok { - dateRecord.IssueCount = 0 - } else { - dateRecord.IssueCount = IssueCountMap[dateRecord.ID] - } - - if _, ok := CommentCountMap[dateRecord.ID]; !ok { - dateRecord.CommentCount = 0 - } else { - dateRecord.CommentCount = CommentCountMap[dateRecord.ID] - } - - if _, ok := FocusRepoCountMap[dateRecord.ID]; !ok { - dateRecord.FocusRepoCount = 0 - } else { - dateRecord.FocusRepoCount = FocusRepoCountMap[dateRecord.ID] - } - - if _, ok := StarRepoCountMap[dateRecord.ID]; !ok { - dateRecord.StarRepoCount = 0 - } else { - dateRecord.StarRepoCount = StarRepoCountMap[dateRecord.ID] - } - - if _, ok := WatchedCountMap[dateRecord.ID]; !ok { - dateRecord.WatchedCount = 0 - } else { - dateRecord.WatchedCount = WatchedCountMap[dateRecord.ID] - } + dateRecord.CodeMergeCount = getMapValue(dateRecord.ID, CodeMergeCountMap) + dateRecord.CommitCount = getMapValue(dateRecord.ID, CommitCountMap) + dateRecord.IssueCount = getMapValue(dateRecord.ID, IssueCountMap) + dateRecord.CommentCount = getMapValue(dateRecord.ID, CommentCountMap) + dateRecord.FocusRepoCount = getMapValue(dateRecord.ID, FocusRepoCountMap) + dateRecord.StarRepoCount = getMapValue(dateRecord.ID, StarRepoCountMap) + dateRecord.WatchedCount = getMapValue(dateRecord.ID, WatchedCountMap) if _, ok := CommitCodeSizeMap[dateRecord.Email]; !ok { dateRecord.CommitCodeSize = 0 @@ -695,35 +636,15 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.CommitCodeSize = int(CommitCodeSizeMap[dateRecord.Email].CommitLines) } - if _, ok := CommitDatasetSizeMap[dateRecord.ID]; !ok { - dateRecord.CommitDatasetSize = 0 - } else { - dateRecord.CommitDatasetSize = CommitDatasetSizeMap[dateRecord.ID] - } - - if _, ok := SolveIssueCountMap[dateRecord.ID]; !ok { - dateRecord.SolveIssueCount = 0 - } else { - dateRecord.SolveIssueCount = SolveIssueCountMap[dateRecord.ID] - } + dateRecord.CommitDatasetSize = getMapValue(dateRecord.ID, CommitDatasetSizeMap) + dateRecord.CommitDatasetNum = getMapValue(dateRecord.ID, CommitDatasetNumMap) + dateRecord.SolveIssueCount = getMapValue(dateRecord.ID, SolveIssueCountMap) - if _, ok := wikiCountMap[dateRecord.Name]; !ok { - dateRecord.EncyclopediasCount = 0 - } else { - dateRecord.EncyclopediasCount = wikiCountMap[dateRecord.Name] - } + dateRecord.EncyclopediasCount = getMapKeyStringValue(dateRecord.Name, wikiCountMap) - if _, ok := CreateRepoCountMap[dateRecord.ID]; !ok { - dateRecord.CreateRepoCount = 0 - } else { - dateRecord.CreateRepoCount = CreateRepoCountMap[dateRecord.ID] - } + dateRecord.CreateRepoCount = getMapValue(dateRecord.ID, CreateRepoCountMap) - if _, ok := LoginCountMap[dateRecord.ID]; !ok { - dateRecord.LoginCount = 0 - } else { - dateRecord.LoginCount = LoginCountMap[dateRecord.ID] - } + dateRecord.LoginCount = getMapValue(dateRecord.ID, LoginCountMap) if _, ok := OpenIIndexMap[dateRecord.ID]; !ok { dateRecord.OpenIIndex = 0 @@ -731,7 +652,16 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.OpenIIndex = OpenIIndexMap[dateRecord.ID] } - dateRecord.CommitModelCount = 0 + dateRecord.CloudBrainTaskNum = getMapValue(dateRecord.ID, CloudBrainTaskMap) + dateRecord.GpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuDebugJob", CloudBrainTaskItemMap) + dateRecord.NpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuDebugJob", CloudBrainTaskItemMap) + dateRecord.GpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuTrainJob", CloudBrainTaskItemMap) + dateRecord.NpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuTrainJob", CloudBrainTaskItemMap) + dateRecord.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) + dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) + + dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) + dateRecord.UserIndex = getUserIndex(dateRecord) _, err = statictisSess.Insert(&dateRecord) if err != nil { @@ -751,6 +681,27 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, return nil } +func getUserIndex(dateRecord UserBusinessAnalysis) float64 { + + return 0 +} + +func getMapKeyStringValue(key string, valueMap map[string]int) int { + if _, ok := valueMap[key]; !ok { + return 0 + } else { + return valueMap[key] + } +} + +func getMapValue(userId int64, valueMap map[int64]int) int { + if _, ok := valueMap[userId]; !ok { + return 0 + } else { + return valueMap[userId] + } +} + func getInt(str string) int { re, err := strconv.ParseInt(str, 10, 32) if err != nil { @@ -1051,16 +1002,17 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int { return resultMap } -func queryDatasetSize(start_unix int64, end_unix int64) map[int64]int { +func queryDatasetSize(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { sess := x.NewSession() defer sess.Close() - resultMap := make(map[int64]int) + resultSizeMap := make(map[int64]int) + resultNumMap := make(map[int64]int) cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) count, err := sess.Where(cond).Count(new(Attachment)) if err != nil { log.Info("query attachment error. return.") - return resultMap + return resultSizeMap, resultNumMap } var indexTotal int64 indexTotal = 0 @@ -1071,10 +1023,12 @@ func queryDatasetSize(start_unix int64, end_unix int64) map[int64]int { log.Info("query Attachment size=" + fmt.Sprint(len(attachmentList))) for _, attachRecord := range attachmentList { - if _, ok := resultMap[attachRecord.UploaderID]; !ok { - resultMap[attachRecord.UploaderID] = int(attachRecord.Size / (1024 * 1024)) //MB + if _, ok := resultSizeMap[attachRecord.UploaderID]; !ok { + resultSizeMap[attachRecord.UploaderID] = int(attachRecord.Size / (1024 * 1024)) //MB + resultNumMap[attachRecord.UploaderID] = 1 } else { - resultMap[attachRecord.UploaderID] += int(attachRecord.Size / (1024 * 1024)) //MB + resultSizeMap[attachRecord.UploaderID] += int(attachRecord.Size / (1024 * 1024)) //MB + resultNumMap[attachRecord.UploaderID] += 1 } } @@ -1084,7 +1038,7 @@ func queryDatasetSize(start_unix int64, end_unix int64) map[int64]int { } } - return resultMap + return resultSizeMap, resultNumMap } func queryUserCreateRepo(start_unix int64, end_unix int64) map[int64]int { @@ -1245,6 +1199,99 @@ func queryCommitCodeSize(start_unix int64, end_unix int64) map[int64]int { return resultMap } +func queryUserModel(start_unix int64, end_unix int64) map[int64]int { + sess := x.NewSession() + defer sess.Close() + resultMap := make(map[int64]int) + cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) + count, err := sess.Where(cond).Count(new(AiModelManage)) + if err != nil { + log.Info("query AiModelManage error. return.") + return resultMap + } + var indexTotal int64 + indexTotal = 0 + for { + sess.Select("id,user_id").Table("ai_model_manage").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) + aiModelList := make([]*AiModelManage, 0) + sess.Find(&aiModelList) + log.Info("query AiModelManage size=" + fmt.Sprint(len(aiModelList))) + for _, aiModelRecord := range aiModelList { + if _, ok := resultMap[aiModelRecord.UserId]; !ok { + resultMap[aiModelRecord.UserId] = 1 + } else { + resultMap[aiModelRecord.UserId] += 1 + } + } + indexTotal += PAGE_SIZE + if indexTotal >= count { + break + } + } + return resultMap +} + +func queryCloudBrainTask(start_unix int64, end_unix int64) (map[int64]int, map[string]int) { + sess := x.NewSession() + defer sess.Close() + resultMap := make(map[int64]int) + resultItemMap := make(map[string]int) + + cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) + count, err := sess.Where(cond).Count(new(Cloudbrain)) + if err != nil { + log.Info("query cloudbrain error. return.") + return resultMap, resultItemMap + } + var indexTotal int64 + indexTotal = 0 + for { + sess.Select("id,job_type,user_id,duration,train_job_duration,type").Table("cloudbrain").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) + cloudTaskList := make([]*Cloudbrain, 0) + sess.Find(&cloudTaskList) + log.Info("query cloudbrain size=" + fmt.Sprint(len(cloudTaskList))) + for _, cloudTaskRecord := range cloudTaskList { + if _, ok := resultMap[cloudTaskRecord.UserID]; !ok { + resultMap[cloudTaskRecord.UserID] = 1 + } else { + resultMap[cloudTaskRecord.UserID] += 1 + } + setMapKey("time", cloudTaskRecord.UserID, int(cloudTaskRecord.Duration), resultItemMap) + if cloudTaskRecord.Type == 1 { //npu + if cloudTaskRecord.JobType == "TRAIN" { + setMapKey("NpuTrainJob", cloudTaskRecord.UserID, 1, resultItemMap) + } else if cloudTaskRecord.JobType == "INFERENCE" { + setMapKey("NpuInferenceJob", cloudTaskRecord.UserID, 1, resultItemMap) + } else { + setMapKey("NpuDebugJob", cloudTaskRecord.UserID, 1, resultItemMap) + } + } else { //type=0 gpu + if cloudTaskRecord.JobType == "TRAIN" { + setMapKey("GpuTrainJob", cloudTaskRecord.UserID, 1, resultItemMap) + } else if cloudTaskRecord.JobType == "BENCHMARK" { + setMapKey("GpuBenchMarkJob", cloudTaskRecord.UserID, 1, resultItemMap) + } else { + setMapKey("GpuDebugJob", cloudTaskRecord.UserID, 1, resultItemMap) + } + } + } + indexTotal += PAGE_SIZE + if indexTotal >= count { + break + } + } + + return resultMap, resultItemMap +} +func setMapKey(key string, userId int64, value int, resultItemMap map[string]int) { + newKey := fmt.Sprint(userId) + "_" + key + if _, ok := resultItemMap[newKey]; !ok { + resultItemMap[newKey] = value + } else { + resultItemMap[newKey] += value + } +} + func subMonth(t1, t2 time.Time) (month int) { y1 := t1.Year() y2 := t2.Year() diff --git a/models/user_business_struct.go b/models/user_business_struct.go index c435c0b07..066e11314 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -44,6 +44,18 @@ type UserBusinessAnalysisCurrentYear struct { //user Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysisLast30Day struct { @@ -88,6 +100,18 @@ type UserBusinessAnalysisLast30Day struct { //user Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysisLastMonth struct { @@ -132,6 +156,18 @@ type UserBusinessAnalysisLastMonth struct { //user Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysisCurrentMonth struct { @@ -176,6 +212,18 @@ type UserBusinessAnalysisCurrentMonth struct { //user Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysisCurrentWeek struct { @@ -220,6 +268,18 @@ type UserBusinessAnalysisCurrentWeek struct { //user Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } type UserBusinessAnalysisYesterday struct { @@ -264,4 +324,16 @@ type UserBusinessAnalysisYesterday struct { //user Name string `xorm:"NOT NULL"` DataDate string `xorm:"NULL"` + + CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` + GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` + GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` + NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` + GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` + CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` + CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` + UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` + UserLocation string `xorm:"NULL"` } From 491de2004c253c6422108a43f8d08faa38b2d91c Mon Sep 17 00:00:00 2001 From: yanchao Date: Sun, 20 Mar 2022 11:33:21 +0800 Subject: [PATCH 003/129] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=B9=BF=E5=9C=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/models.go | 1 + models/org.go | 99 +++++++++++++++++++++++++++++++++++++ models/repo_statistic.go | 10 ++++ modules/cron/tasks_basic.go | 12 +++++ routers/home.go | 39 +++++++++++---- routers/private/internal.go | 2 + routers/private/tool.go | 4 ++ 7 files changed, 158 insertions(+), 9 deletions(-) diff --git a/models/models.go b/models/models.go index 0f4679b4f..fafb63018 100755 --- a/models/models.go +++ b/models/models.go @@ -137,6 +137,7 @@ func init() { new(OfficialTag), new(OfficialTagRepos), new(WechatBindLog), + new(OrgStatistic), ) tablesStatistic = append(tablesStatistic, diff --git a/models/org.go b/models/org.go index 85fb157ae..8b3e60ef8 100755 --- a/models/org.go +++ b/models/org.go @@ -8,6 +8,7 @@ package models import ( "fmt" "os" + "strconv" "strings" "code.gitea.io/gitea/modules/log" @@ -19,6 +20,17 @@ import ( "xorm.io/xorm" ) +type OrgStatistic struct { + ID int64 `xorm:"pk autoincr"` + OrgID int64 `xorm:"UNIQUE"` + NumScore int `xorm:"INDEX NOT NULL DEFAULT 0"` +} + +type OrgScore struct { + *User + Score string +} + // IsOwnedBy returns true if given user is in the owner team. func (org *User) IsOwnedBy(uid int64) (bool, error) { return IsOrganizationOwner(org.ID, uid) @@ -135,6 +147,93 @@ func (org *User) RemoveOrgRepo(repoID int64) error { return org.removeOrgRepo(x, repoID) } +func UpdateOrgStatistics() { + ids, err := GetOrganizationsId() + if err != nil { + return + } + for _, id := range ids { + org := User{ID: id} + orgStat := &OrgStatistic{OrgID: id} + numScore, err := org.getOrgStatistics() + if err == nil { + has, _ := x.Get(orgStat) + + orgStat.NumScore = numScore + if has { + x.ID(orgStat.ID).Cols("num_score").Update(&orgStat) + } else { + x.Insert(orgStat) + } + + } + } + +} + +func (org *User) getOrgStatistics() (int, error) { + count, err := getRepositoryCount(x, org) + if err != nil { + return 0, err + } + + err = org.GetRepositories(ListOptions{int(count), 1}) + + if err != nil { + return 0, err + } + var numScore = 0 + for _, repo := range org.Repos { + + numScore += int(getOpenIByRepoId(repo.ID)) + } + + return numScore, nil + +} + +func FindTopNStarsOrgs(n int) ([]*OrgScore, error) { + sql := "select a.id,sum(b.num_stars) score from \"user\" a ,repository b where a.id=b.owner_id and a.type=1 group by a.id order by score desc limit " + strconv.Itoa(n) + + return findTopNOrgs(sql) +} +func FindTopNMembersOrgs(n int) ([]*OrgScore, error) { + sql := "select id, count(user_id) score from" + + " (select org_id as id, uid as user_id from org_user " + + "union select a.id,b.user_id from \"user\" a,collaboration b,repository c " + + "where a.type=1 and a.id=c.owner_id and b.repo_id=c.id) d " + + "group by id order by score desc limit " + strconv.Itoa(n) + + return findTopNOrgs(sql) +} + +func FindTopNOpenIOrgs(n int) ([]*OrgScore, error) { + sql := "select org_id id,num_score score from org_statistic order by num_score desc limit 10" + strconv.Itoa(n) + + return findTopNOrgs(sql) +} + +func findTopNOrgs(sql string) ([]*OrgScore, error) { + resutls, err := x.QueryString(sql) + + if err != nil { + return nil, err + } + var orgScore []*OrgScore + for _, record := range resutls { + id, _ := strconv.ParseInt(record["id"], 10, 64) + user, err := getUserByID(x, id) + if err != nil { + continue + } + orgScore = append(orgScore, &OrgScore{user, record["score"]}) + + } + + return orgScore, nil + +} + // CreateOrganization creates record of a new organization. func CreateOrganization(org, owner *User) (err error) { if !owner.CanCreateOrganization() { diff --git a/models/repo_statistic.go b/models/repo_statistic.go index a9e9593af..4f8f13ed7 100755 --- a/models/repo_statistic.go +++ b/models/repo_statistic.go @@ -73,6 +73,16 @@ func (repo *RepoStatistic) DisplayName() string { return repo.Alias } +func getOpenIByRepoId(repoId int64) float64 { + repoStatistic := new(RepoStatistic) + has, err := xStatistic.Cols("radar_total").Where("repo_id=?", repoId).Desc("id").Limit(1).Get(repoStatistic) + if !has || err != nil { + return 0 + } + return repoStatistic.RadarTotal + +} + func DeleteRepoStatDaily(date string) error { sess := xStatistic.NewSession() defer sess.Close() diff --git a/modules/cron/tasks_basic.go b/modules/cron/tasks_basic.go index b9838e66f..b3a6c02a1 100755 --- a/modules/cron/tasks_basic.go +++ b/modules/cron/tasks_basic.go @@ -185,6 +185,17 @@ func registerHandleSummaryStatistic() { }) } +func registerHandleOrgStatistic() { + RegisterTaskFatal("handle_org_statistic", &BaseConfig{ + Enabled: true, + RunAtStart: false, + Schedule: "0 0 2 * * ?", + }, func(ctx context.Context, _ *models.User, _ Config) error { + models.UpdateOrgStatistics() + return nil + }) +} + func registerSyncCloudbrainStatus() { RegisterTaskFatal("sync_cloudbrain_status", &BaseConfig{ Enabled: true, @@ -215,4 +226,5 @@ func initBasicTasks() { registerHandleSummaryStatistic() registerSyncCloudbrainStatus() + registerHandleOrgStatistic() } diff --git a/routers/home.go b/routers/home.go index 2db8d2112..a9f05067b 100755 --- a/routers/home.go +++ b/routers/home.go @@ -418,17 +418,38 @@ func ExploreOrganizations(ctx *context.Context) { ctx.Data["PageIsExploreOrganizations"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled - visibleTypes := []structs.VisibleType{structs.VisibleTypePublic} - if ctx.User != nil { - visibleTypes = append(visibleTypes, structs.VisibleTypeLimited, structs.VisibleTypePrivate) + N := 10 + starInfo, err := models.FindTopNStarsOrgs(N) + if err != nil { + log.Error("GetStarOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) + ctx.ServerError("GetStarOrgInfos", err) + return + } + memberInfo, err := models.FindTopNMembersOrgs(N) + if err != nil { + log.Error("GetMemberOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) + ctx.ServerError("GetMemberOrgInfos", err) + return + } + openIInfo, err := models.FindTopNOpenIOrgs(N) + if err != nil { + log.Error("GetOpenIOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) + ctx.ServerError("GetOpenIOrgInfos", err) + return } - RenderUserSearch(ctx, &models.SearchUserOptions{ - Actor: ctx.User, - Type: models.UserTypeOrganization, - ListOptions: models.ListOptions{PageSize: setting.UI.ExplorePagingNum}, - Visible: visibleTypes, - }, tplExploreOrganizations) + recommendOrgs, err := models.GetRecommendOrgInfos() + if err != nil { + log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) + ctx.ServerError("GetRecommendOrgInfos", err) + return + } + ctx.Data["RecommendOrgs"] = recommendOrgs + ctx.Data["StarOrgs"] = starInfo + ctx.Data["MemberOrgs"] = memberInfo + ctx.Data["ActiveOrgs"] = openIInfo + + ctx.HTML(http.StatusOK, tplExploreOrganizations) } // ExploreCode render explore code page diff --git a/routers/private/internal.go b/routers/private/internal.go index 0dd725ca3..18dad5537 100755 --- a/routers/private/internal.go +++ b/routers/private/internal.go @@ -44,6 +44,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/manager/flush-queues", bind(private.FlushOptions{}), FlushQueues) m.Post("/tool/update_all_repo_commit_cnt", UpdateAllRepoCommitCnt) m.Post("/tool/repo_stat/:date", RepoStatisticManually) + + m.Get("/tool/org_stat", OrgStatisticManually) m.Post("/tool/update_repo_visit/:date", UpdateRepoVisit) }, CheckInternalToken) diff --git a/routers/private/tool.go b/routers/private/tool.go index d01c5b2ab..122a41afe 100755 --- a/routers/private/tool.go +++ b/routers/private/tool.go @@ -45,6 +45,10 @@ func RepoStatisticManually(ctx *macaron.Context) { repo.TimingCountDataByDate(date) } +func OrgStatisticManually() { + models.UpdateOrgStatistics() +} + func UpdateRepoVisit(ctx *macaron.Context) { date := ctx.Params("date") log.Info("date(%s)", date) From 478dc4c59d3f364a19cfb8b25b44bf3393224d40 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 21 Mar 2022 09:19:36 +0800 Subject: [PATCH 004/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/user.go b/models/user.go index f7857248b..a181a4d72 100755 --- a/models/user.go +++ b/models/user.go @@ -2103,6 +2103,12 @@ func GetOrganizationsCount() (int64, error) { } +func GetOrganizationsId() ([]int64, error) { + var ids []int64 + err := x.Table("user").Where("type=1").Cols("id").Find(&ids) + return ids, err +} + func GetBlockChainUnSuccessUsers() ([]*User, error) { users := make([]*User, 0, 10) err := x.Where("public_key = ''"). From ccb70b0c4a021b94b0026c3cc31f60b0f9127094 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 22 Mar 2022 10:13:03 +0800 Subject: [PATCH 005/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/home.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/routers/home.go b/routers/home.go index a9f05067b..8ce709c6d 100755 --- a/routers/home.go +++ b/routers/home.go @@ -438,7 +438,7 @@ func ExploreOrganizations(ctx *context.Context) { return } - recommendOrgs, err := models.GetRecommendOrgInfos() + recommendOrgs, err := GetRecommendOrg() if err != nil { log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) ctx.ServerError("GetRecommendOrgInfos", err) @@ -581,12 +581,12 @@ func NotFound(ctx *context.Context) { ctx.NotFound("home.NotFound", nil) } -func RecommendOrgFromPromote(ctx *context.Context) { +func GetRecommendOrg() ([]map[string]interface{}, error) { url := setting.RecommentRepoAddr + "organizations" result, err := repository.RecommendFromPromote(url) + if err != nil { - ctx.ServerError("500", err) - return + return nil, err } resultOrg := make([]map[string]interface{}, 0) for _, userName := range result { @@ -606,7 +606,15 @@ func RecommendOrgFromPromote(ctx *context.Context) { log.Info("query user error," + err.Error()) } } + return resultOrg, nil +} +func RecommendOrgFromPromote(ctx *context.Context) { + resultOrg, err := GetRecommendOrg() + if err != nil { + ctx.ServerError("500", err) + return + } ctx.JSON(200, resultOrg) } From 3b6e6e5f36392fa807d22d2b1f3a04e8e3902562 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 22 Mar 2022 11:08:05 +0800 Subject: [PATCH 006/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/home.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/home.go b/routers/home.go index 8ce709c6d..aeb67b638 100755 --- a/routers/home.go +++ b/routers/home.go @@ -596,6 +596,7 @@ func GetRecommendOrg() ([]map[string]interface{}, error) { userMap["Name"] = user.Name userMap["Description"] = user.Description userMap["FullName"] = user.FullName + userMap["HomeLink"] = user.HomeLink() userMap["ID"] = user.ID userMap["Avatar"] = user.RelAvatarLink() userMap["NumRepos"] = user.NumRepos From 0e3c44921daf56e0b1b40f6db2359e330231e624 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 22 Mar 2022 16:31:12 +0800 Subject: [PATCH 007/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 86 ++++++++++++++++++++++++++++++-- models/user_business_struct.go | 5 ++ 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index e059ef3e4..04c0eb5f0 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -421,6 +421,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS log.Info("query user error. return.") return } + ParaWeight := getParaWeight() var indexTotal int64 indexTotal = 0 insertCount := 0 @@ -469,7 +470,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) - //dateRecordAll.UserIndex = getUserIndex(dateRecordAll) + dateRecordAll.UserIndex = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) dateRecordBatch = append(dateRecordBatch, dateRecordAll) if len(dateRecordBatch) >= BATCH_INSERT_SIZE { @@ -601,6 +602,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("query user error. return.") return err } + + ParaWeight := getParaWeight() + var indexTotal int64 indexTotal = 0 for { @@ -661,7 +665,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) - dateRecord.UserIndex = getUserIndex(dateRecord) + dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) _, err = statictisSess.Insert(&dateRecord) if err != nil { @@ -681,9 +685,83 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, return nil } -func getUserIndex(dateRecord UserBusinessAnalysis) float64 { +func getParaWeight() map[string]float64 { + result := make(map[string]float64) + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + statictisSess.Select("*").Table(new(UserAnalysisPara)) + paraList := make([]*UserAnalysisPara, 0) + statictisSess.Find(¶List) + for _, paraRecord := range paraList { + result[paraRecord.Key] = paraRecord.Value + } + return result +} + +func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight map[string]float64) float64 { + var result float64 + // PR数 0.20 + // commit数 0.20 + // 提出任务数 0.20 + // 评论数 0.20 + // 关注项目数 0.10 + // 点赞项目数 0.10 + // 登录次数 0.10 + result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) + result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", ParaWeight, 0.2) + log.Info("1 result=" + fmt.Sprint(result)) + result += float64(dateRecord.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2) + result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) + result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) + result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) + result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) + result += float64(dateRecord.WatchedCount) * getParaWeightValue("WatchedCount", ParaWeight, 0.3) + result += float64(dateRecord.CommitCodeSize) * getParaWeightValue("CommitCodeSize", ParaWeight, 0.1) + result += float64(dateRecord.SolveIssueCount) * getParaWeightValue("SolveIssueCount", ParaWeight, 0.2) + result += float64(dateRecord.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) + result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) + result += float64(dateRecord.CloudBrainTaskNum) * getParaWeightValue("CloudBrainTaskNum", ParaWeight, 0.3) + result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) + result += dateRecord.OpenIIndex * getParaWeightValue("OpenIIndex", ParaWeight, 0.1) + + return result +} + +func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64) float64 { + var result float64 + // PR数 0.20 + // commit数 0.20 + // 提出任务数 0.20 + // 评论数 0.20 + // 关注项目数 0.10 + // 点赞项目数 0.10 + // 登录次数 0.10 + result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) + result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", ParaWeight, 0.2) + log.Info("2 result=" + fmt.Sprint(result)) + result += float64(dateRecord.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2) + result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) + result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) + result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) + result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) + result += float64(dateRecord.WatchedCount) * getParaWeightValue("WatchedCount", ParaWeight, 0.3) + result += float64(dateRecord.CommitCodeSize) * getParaWeightValue("CommitCodeSize", ParaWeight, 0.1) + result += float64(dateRecord.SolveIssueCount) * getParaWeightValue("SolveIssueCount", ParaWeight, 0.2) + result += float64(dateRecord.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) + result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) + result += float64(dateRecord.CloudBrainTaskNum) * getParaWeightValue("CloudBrainTaskNum", ParaWeight, 0.3) + result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) + result += dateRecord.OpenIIndex * getParaWeightValue("OpenIIndex", ParaWeight, 0.1) + + return result +} - return 0 +func getParaWeightValue(key string, valueMap map[string]float64, defaultValue float64) float64 { + if _, ok := valueMap[key]; !ok { + return defaultValue + } else { + return valueMap[key] + } } func getMapKeyStringValue(key string, valueMap map[string]int) int { diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 066e11314..3bfebf3e0 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -337,3 +337,8 @@ type UserBusinessAnalysisYesterday struct { UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` UserLocation string `xorm:"NULL"` } + +type UserAnalysisPara struct { + Key string `xorm:"NOT NULL"` + Value float64 `xorm:"NOT NULL DEFAULT 0"` +} From 53144be9b6ca9793d4d3649b6b50d029d7f3402a Mon Sep 17 00:00:00 2001 From: wangjr Date: Tue, 22 Mar 2022 16:46:19 +0800 Subject: [PATCH 008/129] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E9=A6=96=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 7 ++ options/locale/locale_zh-CN.ini | 8 +++ templates/explore/organizations.tmpl | 100 +++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 226fa2147..e10b2d1b4 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2104,6 +2104,13 @@ customize = Customize selected_project=Selected Projects fold = Fold unfold = Unfold +org_member = Member +org_members = Members +org_team = Team +org_teams = Teams +org_repository = Repository +org_repositories = Repositories + form.name_reserved = The organization name '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in an organization name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ce5367d98..a8d1a7399 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2111,6 +2111,14 @@ customize = 自定义 selected_project=精选项目 fold = 收起 unfold = 展开 +org_member = 成员 +org_members = 成员 +org_team = 团队 +org_teams = 团队 +org_repository = 项目 +org_repositories = 项目 + + form.name_reserved=组织名称 '%s' 是被保留的。 form.name_pattern_not_allowed=组织名称中不允许使用 "%s"。 diff --git a/templates/explore/organizations.tmpl b/templates/explore/organizations.tmpl index 1151c5a94..84a2d77a8 100644 --- a/templates/explore/organizations.tmpl +++ b/templates/explore/organizations.tmpl @@ -1,9 +1,76 @@ + + + + + + + {{template "base/head" .}}
{{template "explore/search" .}} + {{template "base/footer" .}} + + From de101e88008e9c549c5e07227c59cd99332be97f Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 22 Mar 2022 17:15:06 +0800 Subject: [PATCH 009/129] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_zh-CN.ini | 5 ++++ routers/repo/user_data_analysis.go | 15 ++++++++++-- web_src/js/components/UserAnalysis.vue | 32 +++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ce5367d98..79e43f437 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -470,6 +470,11 @@ static.encyclopediascount=百科页面贡献次数 static.createrepocount=创建项目数 static.openiindex=OpenI指数 static.registdate=用户注册时间 +static.CloudBrainTaskNum=云脑任务数 +static.CloudBrainRunTime=云脑运行时间(小时) +static.CommitDatasetNum=上传(提交)数据集文件数 +static.CommitModelCount=提交模型数 +static.UserIndex=用户指数 static.countdate=系统统计时间 static.all=所有 static.public.user_business_analysis_current_month=本月 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index b4adfc347..15bb55e84 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -54,7 +54,12 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac "N1": ctx.Tr("user.static.createrepocount"), "O1": ctx.Tr("user.static.openiindex"), "P1": ctx.Tr("user.static.registdate"), - "Q1": ctx.Tr("user.static.countdate"), + "Q1": ctx.Tr("user.static.CloudBrainTaskNum"), + "R1": ctx.Tr("user.static.CloudBrainRunTime"), + "S1": ctx.Tr("user.static.CommitDatasetNum"), + "T1": ctx.Tr("user.static.CommitModelCount"), + "U1": ctx.Tr("user.static.UserIndex"), + "V1": ctx.Tr("user.static.countdate"), } for k, v := range dataHeader { //设置单元格的值 @@ -89,8 +94,14 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") xlsx.SetCellValue(sheetName, "P"+rows, formatTime[0:len(formatTime)-3]) + xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) + xlsx.SetCellValue(sheetName, "R"+rows, userRecord.CloudBrainRunTime) + xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) + xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) + xlsx.SetCellValue(sheetName, "U"+rows, userRecord.UserIndex) + formatTime = userRecord.DataDate - xlsx.SetCellValue(sheetName, "Q"+rows, formatTime) + xlsx.SetCellValue(sheetName, "V"+rows, formatTime) } indexTotal += PAGE_SIZE diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 682dbc78c..71a2de096 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -133,7 +133,37 @@ + + + + + + + + + + Date: Tue, 22 Mar 2022 17:19:46 +0800 Subject: [PATCH 010/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 226fa2147..1280cb956 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -467,6 +467,11 @@ static.encyclopediascount=Encyclopedias Count static.createrepocount=Create Repo Count static.openiindex=OpenI Index static.registdate=Regist Date +static.CloudBrainTaskNum=CloudBrain Task Count +static.CloudBrainRunTime=CloudBrain Run Time +static.CommitDatasetNum=Commit Dataset Count +static.CommitModelCount=Commit Model Count +static.UserIndex=User Index static.countdate=Count Date static.all=All static.public.user_business_analysis_current_month=Current_Month From 70e22a3131c429b48ca8cb05c08ab8bc965aa479 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 22 Mar 2022 17:33:38 +0800 Subject: [PATCH 011/129] =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=A4=E4=BD=8D?= =?UTF-8?q?=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 2 +- web_src/js/components/UserAnalysis.vue | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 15bb55e84..8574e240b 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -98,7 +98,7 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac xlsx.SetCellValue(sheetName, "R"+rows, userRecord.CloudBrainRunTime) xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) - xlsx.SetCellValue(sheetName, "U"+rows, userRecord.UserIndex) + xlsx.SetCellValue(sheetName, "U"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) formatTime = userRecord.DataDate xlsx.SetCellValue(sheetName, "V"+rows, formatTime) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 71a2de096..a9381a383 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -163,6 +163,9 @@ label="用户指数" width="120px" align="center"> + Date: Wed, 23 Mar 2022 10:05:26 +0800 Subject: [PATCH 012/129] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/explore/organizations.tmpl | 143 ++++++++++++++++----------- 1 file changed, 85 insertions(+), 58 deletions(-) diff --git a/templates/explore/organizations.tmpl b/templates/explore/organizations.tmpl index 84a2d77a8..872490c8a 100644 --- a/templates/explore/organizations.tmpl +++ b/templates/explore/organizations.tmpl @@ -4,72 +4,99 @@ + {{template "base/head" .}}
{{template "explore/search" .}} +
+
+

+ 推荐组织 +

+

这些优秀的组织正在使用启智AI开发协作平台;你的组织也想展示到这里, 点此提交

+
-
-
-
-
- -
-
- +
+
+
-
+fdf
+
+fdfd + +
+
+dfgfg + +
+
+ +
+ +
+
+ {{template "explore/navbar" .}}
@@ -140,7 +167,7 @@ window.onload = function() { var swiperOrg = new Swiper(".homeorg-list", { slidesPerView: 1, - slidesPerColumn: 4, + slidesPerColumn: 3, slidesPerColumnFill:'row', spaceBetween: 15, pagination: { @@ -153,10 +180,10 @@ window.onload = function() { }, breakpoints: { 768: { - slidesPerView: 2, + slidesPerView: 3, }, 1024: { - slidesPerView: 3, + slidesPerView: 4, }, }, From 26d1df4a0d8b5e3bc75cc1bf806b1e85835896d0 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 24 Mar 2022 10:13:05 +0800 Subject: [PATCH 013/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/models.go | 2 + models/user_business_analysis.go | 65 ++++++++++++++++++++++++++------ models/user_business_struct.go | 9 +++++ 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/models/models.go b/models/models.go index 0f4679b4f..2ebdb4206 100755 --- a/models/models.go +++ b/models/models.go @@ -151,6 +151,8 @@ func init() { new(UserBusinessAnalysisCurrentWeek), new(UserBusinessAnalysisYesterday), new(UserLoginLog), + new(UserMetrics), + new(UserAnalysisPara), ) gonicNames := []string{"SSL", "UID"} diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 04c0eb5f0..644398d48 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -378,7 +378,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus return userBusinessAnalysisReturnList, count } -func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageStartTime time.Time, pageEndTime time.Time) { +func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageStartTime time.Time, pageEndTime time.Time, userMetrics map[string]int) { sess := x.NewSession() defer sess.Close() @@ -481,6 +481,11 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS } dateRecordBatch = make([]UserBusinessAnalysisAll, 0) } + if tableName == "user_business_analysis_all" { + if dateRecordAll.UserIndex > 0 || dateRecordAll.LoginCount > 0 { + userMetrics["TotalHasActivityUser"] = getMapKeyStringValue("TotalHasActivityUser", userMetrics) + 1 + } + } } indexTotal += PAGE_SIZE if indexTotal >= count { @@ -519,36 +524,36 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static statictisSess.Exec(insertBatchSql) } -func RefreshUserStaticAllTabel(wikiCountMap map[string]int) { +func RefreshUserStaticAllTabel(wikiCountMap map[string]int, userMetrics map[string]int) { currentTimeNow := time.Now() pageStartTime := time.Date(2021, 11, 5, 0, 0, 0, 0, currentTimeNow.Location()) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_all", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_all", pageStartTime, pageEndTime, userMetrics) log.Info("refresh all data finished.") pageStartTime = time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_year", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_year", pageStartTime, pageEndTime, userMetrics) thisMonth := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_month", thisMonth, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_month", thisMonth, pageEndTime, userMetrics) offset := int(time.Monday - currentTimeNow.Weekday()) if offset > 0 { offset = -6 } pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_week", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_week", pageStartTime, pageEndTime, userMetrics) pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -30) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_last30_day", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_last30_day", pageStartTime, pageEndTime, userMetrics) pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -1) pageEndTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_yesterday", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_yesterday", pageStartTime, pageEndTime, userMetrics) pageStartTime = thisMonth.AddDate(0, -1, 0) pageEndTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) - refreshUserStaticTable(wikiCountMap, "user_business_analysis_last_month", pageStartTime, pageEndTime) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_last_month", pageStartTime, pageEndTime, userMetrics) } @@ -604,7 +609,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } ParaWeight := getParaWeight() - + userMetrics := make(map[string]int) var indexTotal int64 indexTotal = 0 for { @@ -666,7 +671,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) - + setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) _, err = statictisSess.Insert(&dateRecord) if err != nil { log.Info("insert daterecord failed." + err.Error()) @@ -680,11 +685,47 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } } - RefreshUserStaticAllTabel(wikiCountMap) + RefreshUserStaticAllTabel(wikiCountMap, userMetrics) + + //insert userMetrics table + var useMetrics UserMetrics + useMetrics.CountDate = CountDate.Unix() + statictisSess.Delete(&useMetrics) + + useMetrics.ActivateRegistUser = getMapKeyStringValue("ActivateRegistUser", userMetrics) + useMetrics.HasActivityUser = getMapKeyStringValue("HasActivityUser", userMetrics) + useMetrics.NotActivateRegistUser = getMapKeyStringValue("NotActivateRegistUser", userMetrics) + useMetrics.TotalActivateRegistUser = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) + useMetrics.TotalHasActivityUser = getMapKeyStringValue("TotalHasActivityUser", userMetrics) + statictisSess.Insert(&useMetrics) return nil } +func setUserMetrics(userMetrics map[string]int, user *User, start_time int64, end_time int64, dateRecord UserBusinessAnalysis) { + //ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + //NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + //HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` + //TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + //TotalHasActivityUser + regist_time := user.CreatedUnix.AsTime().Unix() + if regist_time >= start_time && regist_time <= end_time { + if user.IsActive { + userMetrics["ActivateRegistUser"] = getMapKeyStringValue("ActivateRegistUser", userMetrics) + 1 + } else { + userMetrics["NotActivateRegistUser"] = getMapKeyStringValue("NotActivateRegistUser", userMetrics) + 1 + } + } + if user.IsActive { + userMetrics["TotalActivateRegistUser"] = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) + 1 + } + + if dateRecord.UserIndex > 0 || dateRecord.LoginCount > 0 { + userMetrics["HasActivityUser"] = getMapKeyStringValue("HasActivityUser", userMetrics) + 1 + } + +} + func getParaWeight() map[string]float64 { result := make(map[string]float64) statictisSess := xStatistic.NewSession() diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 3bfebf3e0..17d9f046f 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -342,3 +342,12 @@ type UserAnalysisPara struct { Key string `xorm:"NOT NULL"` Value float64 `xorm:"NOT NULL DEFAULT 0"` } + +type UserMetrics struct { + CountDate int64 `xorm:"pk"` + ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` + TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + TotalHasActivityUser int `xorm:"NOT NULL DEFAULT 0"` +} From 756222d96ef6e352c2152cbd8b1811fc6d5ebf80 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 24 Mar 2022 11:10:47 +0800 Subject: [PATCH 014/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 ++-- routers/repo/user_data_analysis.go | 17 +++++++++++++---- web_src/js/components/UserAnalysis.vue | 6 ++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 644398d48..edfe73939 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -668,7 +668,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.NpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuTrainJob", CloudBrainTaskItemMap) dateRecord.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) - + dateRecord.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) @@ -1375,7 +1375,7 @@ func queryCloudBrainTask(start_unix int64, end_unix int64) (map[int64]int, map[s } else { resultMap[cloudTaskRecord.UserID] += 1 } - setMapKey("time", cloudTaskRecord.UserID, int(cloudTaskRecord.Duration), resultItemMap) + setMapKey("CloudBrainRunTime", cloudTaskRecord.UserID, int(cloudTaskRecord.Duration), resultItemMap) if cloudTaskRecord.Type == 1 { //npu if cloudTaskRecord.JobType == "TRAIN" { setMapKey("NpuTrainJob", cloudTaskRecord.UserID, 1, resultItemMap) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 8574e240b..96503e5c9 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -95,7 +95,7 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac xlsx.SetCellValue(sheetName, "P"+rows, formatTime[0:len(formatTime)-3]) xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) - xlsx.SetCellValue(sheetName, "R"+rows, userRecord.CloudBrainRunTime) + xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) xlsx.SetCellValue(sheetName, "U"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) @@ -232,7 +232,12 @@ func QueryUserStaticDataPage(ctx *context.Context) { "N1": ctx.Tr("user.static.createrepocount"), "O1": ctx.Tr("user.static.openiindex"), "P1": ctx.Tr("user.static.registdate"), - "Q1": ctx.Tr("user.static.countdate"), + "Q1": ctx.Tr("user.static.CloudBrainTaskNum"), + "R1": ctx.Tr("user.static.CloudBrainRunTime"), + "S1": ctx.Tr("user.static.CommitDatasetNum"), + "T1": ctx.Tr("user.static.CommitModelCount"), + "U1": ctx.Tr("user.static.UserIndex"), + "V1": ctx.Tr("user.static.countdate"), } for k, v := range dataHeader { //设置单元格的值 @@ -260,9 +265,13 @@ func QueryUserStaticDataPage(ctx *context.Context) { formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") xlsx.SetCellValue(sheetName, "P"+rows, formatTime[0:len(formatTime)-3]) - + xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) + xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) + xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) + xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) + xlsx.SetCellValue(sheetName, "U"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) formatTime = userRecord.DataDate - xlsx.SetCellValue(sheetName, "Q"+rows, formatTime+" 00:01") + xlsx.SetCellValue(sheetName, "V"+rows, formatTime) } //设置默认打开的表单 diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index a9381a383..241768c15 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -145,6 +145,9 @@ label="云脑运行时间(小时)" width="120px" align="center"> + Date: Thu, 24 Mar 2022 17:06:21 +0800 Subject: [PATCH 015/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/home.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/home.go b/routers/home.go index aeb67b638..e7067524f 100755 --- a/routers/home.go +++ b/routers/home.go @@ -444,6 +444,7 @@ func ExploreOrganizations(ctx *context.Context) { ctx.ServerError("GetRecommendOrgInfos", err) return } + ctx.Data["RecommendURL"] = setting.RecommentRepoAddr ctx.Data["RecommendOrgs"] = recommendOrgs ctx.Data["StarOrgs"] = starInfo ctx.Data["MemberOrgs"] = memberInfo From 9ab71724f501a810cbf6d8d094be02d516b4ce2e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 24 Mar 2022 17:55:05 +0800 Subject: [PATCH 016/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/home.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routers/home.go b/routers/home.go index e7067524f..55c077f66 100755 --- a/routers/home.go +++ b/routers/home.go @@ -49,7 +49,7 @@ func Home(ctx *context.Context) { ctx.HTML(200, tplHome) } -func setRecommendURL(ctx *context.Context) { +func setRecommendURLOnly(ctx *context.Context) { addr := setting.RecommentRepoAddr[10:] start := strings.Index(addr, "/") end := strings.Index(addr, "raw") @@ -58,7 +58,10 @@ func setRecommendURL(ctx *context.Context) { } else { ctx.Data["RecommendURL"] = setting.RecommentRepoAddr } +} +func setRecommendURL(ctx *context.Context) { + setRecommendURLOnly(ctx) ctx.Data["page_title"] = ctx.Tr("home.page_title") ctx.Data["page_small_title"] = ctx.Tr("home.page_small_title") ctx.Data["page_description"] = ctx.Tr("home.page_description") @@ -444,7 +447,7 @@ func ExploreOrganizations(ctx *context.Context) { ctx.ServerError("GetRecommendOrgInfos", err) return } - ctx.Data["RecommendURL"] = setting.RecommentRepoAddr + setRecommendURLOnly(ctx) ctx.Data["RecommendOrgs"] = recommendOrgs ctx.Data["StarOrgs"] = starInfo ctx.Data["MemberOrgs"] = memberInfo From 212b63c5a97de094142ab75e622872b1d9f6ea08 Mon Sep 17 00:00:00 2001 From: wangjr Date: Fri, 25 Mar 2022 10:50:02 +0800 Subject: [PATCH 017/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=B9=BF=E5=9C=BA=E6=8E=92=E5=90=8D=E5=88=97=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 3 + options/locale/locale_zh-CN.ini | 4 +- templates/explore/organizations.tmpl | 207 +++++++++++++++------------ web_src/less/openi.less | 84 +++++++++++ 4 files changed, 208 insertions(+), 90 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 51e8a6c45..28250ab0c 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2141,6 +2141,9 @@ org_teams = Teams org_repository = Repository org_repositories = Repositories +star = Star Top10 +member = Members Top10 +active = Active Top10 form.name_reserved = The organization name '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in an organization name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 535f65ee1..18f6293f3 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2145,7 +2145,9 @@ org_teams = 团队 org_repository = 项目 org_repositories = 项目 - +star = 点赞榜 +member = 成员榜 +active = 活跃榜 form.name_reserved=组织名称 '%s' 是被保留的。 form.name_pattern_not_allowed=组织名称中不允许使用 "%s"。 diff --git a/templates/explore/organizations.tmpl b/templates/explore/organizations.tmpl index 872490c8a..d88272e71 100644 --- a/templates/explore/organizations.tmpl +++ b/templates/explore/organizations.tmpl @@ -4,27 +4,15 @@ - - {{template "base/head" .}}
{{template "explore/search" .}}

- 推荐组织 + {{$.i18n.Tr "home.page_recommend_org"}}

-

这些优秀的组织正在使用启智AI开发协作平台;你的组织也想展示到这里, 点此提交

+

{{$.i18n.Tr "home.page_recommend_org_desc"}} {{$.i18n.Tr "home.page_recommend_org_commit"}}

@@ -76,88 +64,130 @@
-
-
-
- -fdf -
-
-fdfd - -
-
-dfgfg - -
-
- -
- -
-
- - - {{template "explore/navbar" .}} -
-

- {{.i18n.Tr "explore.organizations"}} -

- {{template "base/footer" .}} @@ -191,5 +221,4 @@ window.onload = function() { } - diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 7871d8148..ad252dde7 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -779,4 +779,88 @@ display: block; border: none !important; color: #0366d6 !important; box-shadow: -15px 0px 10px #fff; +} + +.content_top10{ + padding:10px; + padding-top:0px; +} +.re_con{ + color: rgba(136, 136, 136, 100); + font-size: 14px; + text-align: center; + font-family: SourceHanSansSC-light; +} +.title_re{ + margin-top: 50px !important; +} +.card_list { + width: calc(33.33333333333333% - 2em); + margin-left: 1em; + margin-right: 1em +} +.list_title{ + height: 52px; + text-align: center +} +.star_title{ + background-color: #3291F8; +} +.memb_title{ + background-color: #706FE3; +} +.act_title{ + background-color: #13C28D; +} +.p_text{ + line-height: 50px; + text-align:left; + padding-left:15px; + font-size:18px; + color:#FFFFFF; +} +.orgs { + display: flex; + flex-flow: row wrap; + padding: 0; + margin-top:20px +} +.orgs li { + display: flex; + border-bottom: 0!important; + padding: 3px!important; +} +.p_score{ + line-height: 28px; + width: 100%; + + /* padding-right: 20px; */ + text-align: right; +} +.org_line_hight{ + line-height: 28px; +} +.org_icon{ + margin-top: 10px; + margin-right: 10px; + padding-left: 15px; +} +.org_icon_num{ + margin-left: 2px; + margin-right: 12px; +} +.org_icon_color{ + color: #FA8C16; +} +.li_name{ + list-style:none; + width: 55%; +} +.li_avatar{ + list-style: none; + width: 10%; +} +.li_score{ + list-style:none; + margin-left: 2px; } \ No newline at end of file From ed289fba93da1295d21a3eb03ddc37e33ecae705 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 25 Mar 2022 16:27:25 +0800 Subject: [PATCH 018/129] fix-1647 --- routers/repo/modelarts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 9c670e203..83dba1796 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1475,7 +1475,7 @@ func TrainJobShow(ctx *context.Context) { ctx.Data["displayJobName"] = VersionListTasks[0].DisplayJobName ctx.Data["version_list_task"] = VersionListTasks ctx.Data["version_list_count"] = VersionListCount - ctx.Data["canDownload"] = cloudbrain.CanDeleteJob(ctx, &VersionListTasks[0].Cloudbrain) + ctx.Data["canDownload"] = canNewJob ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) } From 38674e71da9dbcf0fce12f8c4612b6a99beef40e Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 28 Mar 2022 15:12:18 +0800 Subject: [PATCH 019/129] #1641 fix bug --- routers/repo/view.go | 24 ++++++++++++++---------- templates/repo/view_file.tmpl | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/routers/repo/view.go b/routers/repo/view.go index 320102ba4..b28e21aa1 100755 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -247,7 +247,11 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["ReadmeInList"] = true ctx.Data["ReadmeExist"] = true ctx.Data["FileIsSymlink"] = readmeFile.isSymlink - ctx.Data["ReadmeName"] = readmeFile.name + if ctx.Repo.TreePath == "" { + ctx.Data["ReadmeRelativePath"] = readmeFile.name + } else { + ctx.Data["ReadmeRelativePath"] = ctx.Repo.TreePath + "/" + readmeFile.name + } if ctx.Repo.CanEnableEditor() { ctx.Data["CanEditFile"] = true @@ -579,11 +583,11 @@ func safeURL(address string) string { } type ContributorInfo struct { - UserInfo *models.User // nil for contributor who is not a registered user - RelAvatarLink string `json:"rel_avatar_link"` - UserName string `json:"user_name"` - Email string `json:"email"` - CommitCnt int `json:"commit_cnt"` + UserInfo *models.User // nil for contributor who is not a registered user + RelAvatarLink string `json:"rel_avatar_link"` + UserName string `json:"user_name"` + Email string `json:"email"` + CommitCnt int `json:"commit_cnt"` } type GetContributorsInfo struct { @@ -642,7 +646,7 @@ func Home(ctx *context.Context) { existedContributorInfo.CommitCnt += c.CommitCnt } else { var newContributor = &ContributorInfo{ - user, "", "",c.Email, c.CommitCnt, + user, "", "", c.Email, c.CommitCnt, } count++ contributorInfos = append(contributorInfos, newContributor) @@ -839,7 +843,7 @@ func renderCode(ctx *context.Context) { compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch) ctx.Data["UpstreamSameBranchName"] = false } - if err==nil && compareInfo != nil { + if err == nil && compareInfo != nil { if compareInfo.Commits != nil { log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() @@ -950,7 +954,7 @@ func ContributorsAPI(ctx *context.Context) { } else { // new committer info var newContributor = &ContributorInfo{ - user, user.RelAvatarLink(),user.Name, user.Email,c.CommitCnt, + user, user.RelAvatarLink(), user.Name, user.Email, c.CommitCnt, } count++ contributorInfos = append(contributorInfos, newContributor) @@ -963,7 +967,7 @@ func ContributorsAPI(ctx *context.Context) { existedContributorInfo.CommitCnt += c.CommitCnt } else { var newContributor = &ContributorInfo{ - user, "", "",c.Email,c.CommitCnt, + user, "", "", c.Email, c.CommitCnt, } count++ contributorInfos = append(contributorInfos, newContributor) diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index a0cae31f3..a559dd611 100755 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -40,7 +40,7 @@
{{if .Repository.CanEnableEditor}} {{if .CanEditFile}} - {{svg "octicon-pencil" 16}} + {{svg "octicon-pencil" 16}} {{else}} {{svg "octicon-pencil" 16}} {{end}} @@ -48,7 +48,7 @@
{{end}} - + {{if not .ReadmeInList}}
From 9fcbd70f1e5bab1239bc1d986ef120f975210d74 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 28 Mar 2022 17:05:42 +0800 Subject: [PATCH 020/129] fix issue --- web_src/js/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web_src/js/index.js b/web_src/js/index.js index 902750c5b..f245045db 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2788,6 +2788,9 @@ $(document).ready(async () => { }); } }); + this.on('addedfile',(file)=>{ + console.log("addfile",file) + }) } }); } From ce3d50cd068e6789d0b5b3a3a001dad628bbb582 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 29 Mar 2022 10:23:57 +0800 Subject: [PATCH 021/129] fix issue --- templates/repo/editor/upload.tmpl | 2 +- web_src/js/index.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/templates/repo/editor/upload.tmpl b/templates/repo/editor/upload.tmpl index 7794c2a2d..08727600c 100644 --- a/templates/repo/editor/upload.tmpl +++ b/templates/repo/editor/upload.tmpl @@ -27,7 +27,7 @@
-
+
{{template "repo/editor/commit_form" .}} diff --git a/web_src/js/index.js b/web_src/js/index.js index f245045db..a832c0b4b 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2769,6 +2769,7 @@ $(document).ready(async () => { dictInvalidFileType: $dropzone.data('invalid-input-type'), dictFileTooBig: $dropzone.data('file-too-big'), dictRemoveFile: $dropzone.data('remove-file'), + dictMaxFilesExceeded:'上次超过限制', init() { this.on('success', (file, data) => { filenameDict[file.name] = data.uuid; @@ -2789,8 +2790,20 @@ $(document).ready(async () => { } }); this.on('addedfile',(file)=>{ - console.log("addfile",file) + console.log("addfile",file,filenameDict,this.files.length) + if(file.size/(1000*1000)>3){ + this.removeFile(file) + $('.maxfilesize.ui.red.message').text('单次最多上传XX个文件,每个文件不超过XXM。') + $('.maxfilesize.ui.red.message').css('display','block') + } + + }); + this.on('maxfilesexceeded',(file)=>{ + this.removeFile(file) + $('.maxfilesize.ui.red.message').text('一次最多只能上传 5 个文件, 上传已达到上限,请勿再添加文件。') + $('.maxfilesize.ui.red.message').css('display','block') }) + } }); } From 0025a23161b938c2ccb77e6c8e42578ca84972da Mon Sep 17 00:00:00 2001 From: wangjr Date: Fri, 1 Apr 2022 09:32:09 +0800 Subject: [PATCH 022/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=85=A8=E5=B1=80=E6=90=9C=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/explore/organizations.tmpl | 16 +++++++++++++++- web_src/less/openi.less | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/templates/explore/organizations.tmpl b/templates/explore/organizations.tmpl index d88272e71..757e80556 100644 --- a/templates/explore/organizations.tmpl +++ b/templates/explore/organizations.tmpl @@ -6,7 +6,21 @@ {{template "base/head" .}}
- {{template "explore/search" .}} + +
+
+
+
+
+ + + +
+
+
+
+
+

diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 6202c582b..0be3027ac 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -893,6 +893,7 @@ display: block; .li_score{ list-style:none; margin-left: 2px; +} /**seach**/ /**搜索导航条适配窄屏**/ .seachnav{ From 2b00415c2468eb18c46b7d1768843862476fa8cc Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 1 Apr 2022 10:06:37 +0800 Subject: [PATCH 023/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/search.js | 67 +++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/public/home/search.js b/public/home/search.js index 70b5d4ef9..af6589840 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -124,29 +124,7 @@ function search(){ $('#searchForm').addClass("hiddenSearch"); initPageInfo(); if(!isEmpty(currentSearchKeyword)){ - document.getElementById("find_id").innerHTML=getLabel(isZh,"search_finded"); - currentSearchSortBy = sortBy[10]; - currentSearchAscending = "false"; - OnlySearchLabel =false; - page(currentPage); - if(currentSearchTableName != "repository"){ - doSearch("repository",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "issue"){ - doSearch("issue",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "user"){ - doSearch("user",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "org"){ - doSearch("org",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "dataset"){ - doSearch("dataset",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "pr"){ - doSearch("pr",currentSearchKeyword,1,pageSize,true,"",false); - } + doSpcifySearch("repository",currentSearchKeyword,sortBy[10],"false") }else{ initDiv(false); document.getElementById("find_id").innerHTML=getLabel(isZh,"search_empty"); @@ -187,6 +165,38 @@ function initDiv(isSearchLabel=false){ } } +function doSpcifySearch(tableName,keyword,sortBy="",ascending="false"){ + initDiv(true); + document.getElementById("find_id").innerHTML=getLabel(isZh,"search_finded"); + currentSearchKeyword = keyword; + initPageInfo(); + currentSearchTableName = tableName; + currentSearchSortBy = sortBy; + currentSearchAscending = ascending; + OnlySearchLabel =false; + + page(currentPage); + + if(currentSearchTableName != "repository"){ + doSearch("repository",currentSearchKeyword,1,pageSize,true,"",false); + } + if(currentSearchTableName != "issue"){ + doSearch("issue",currentSearchKeyword,1,pageSize,true,"",false); + } + if(currentSearchTableName != "user"){ + doSearch("user",currentSearchKeyword,1,pageSize,true,"",false); + } + if(currentSearchTableName != "org"){ + doSearch("org",currentSearchKeyword,1,pageSize,true,"",false); + } + if(currentSearchTableName != "dataset"){ + doSearch("dataset",currentSearchKeyword,1,pageSize,true,"",false); + } + if(currentSearchTableName != "pr"){ + doSearch("pr",currentSearchKeyword,1,pageSize,true,"",false); + } +} + function doSearchLabel(tableName,keyword,sortBy="",ascending="false"){ initDiv(true); //document.getElementById("search_div").style.display="none"; @@ -1272,8 +1282,15 @@ var zhCN={ sessionStorage.removeItem("searchLabel"); doSearchLabel(sessionStorage.getItem("tableName"),sessionStorage.getItem("keyword"),sessionStorage.getItem("sortBy"),sessionStorage.getItem("ascending")); }else{ - console.log("normal search...."); - search(); + var specifySearch = sessionStorage.getItem("specifySearch"); + if(specifySearch){ + sessionStorage.removeItem("specifySearch"); + doSpcifySearch(sessionStorage.getItem("tableName"),sessionStorage.getItem("keyword"),sessionStorage.getItem("sortBy"),sessionStorage.getItem("ascending")); + }else{ + console.log("normal search...."); + search(); + } + } } } From 90231a34369d4ac6b7560c8aa4e0ce9b6cee3b04 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 1 Apr 2022 10:14:24 +0800 Subject: [PATCH 024/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/home/search.js b/public/home/search.js index af6589840..8468e42ac 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -166,7 +166,7 @@ function initDiv(isSearchLabel=false){ } function doSpcifySearch(tableName,keyword,sortBy="",ascending="false"){ - initDiv(true); + initDiv(false); document.getElementById("find_id").innerHTML=getLabel(isZh,"search_finded"); currentSearchKeyword = keyword; initPageInfo(); From b4deb062076e80b67a68f243f119a3c9d3217f18 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 1 Apr 2022 10:19:20 +0800 Subject: [PATCH 025/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/home/search.js b/public/home/search.js index 8468e42ac..71af07bc3 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -124,7 +124,7 @@ function search(){ $('#searchForm').addClass("hiddenSearch"); initPageInfo(); if(!isEmpty(currentSearchKeyword)){ - doSpcifySearch("repository",currentSearchKeyword,sortBy[10],"false") + doSpcifySearch(currentSearchTableName,currentSearchKeyword,sortBy[10],"false"); }else{ initDiv(false); document.getElementById("find_id").innerHTML=getLabel(isZh,"search_empty"); From 3f8470708e94f2dc80a6206da7afc41b71ca2db6 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 1 Apr 2022 14:37:05 +0800 Subject: [PATCH 026/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/search.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/public/home/search.js b/public/home/search.js index 71af07bc3..33c2279f4 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -108,8 +108,9 @@ function searchItem(type,sortType){ currentSearchSortBy = sortBy[sortType]; currentSearchAscending = sortAscending[sortType]; OnlySearchLabel =false; - page(currentPage); + }else{ + emptySearch(); } } @@ -126,22 +127,26 @@ function search(){ if(!isEmpty(currentSearchKeyword)){ doSpcifySearch(currentSearchTableName,currentSearchKeyword,sortBy[10],"false"); }else{ - initDiv(false); - document.getElementById("find_id").innerHTML=getLabel(isZh,"search_empty"); - $('#find_title').html(""); - document.getElementById("sort_type").innerHTML=""; - document.getElementById("child_search_item").innerHTML=""; - document.getElementById("page_menu").innerHTML=""; - $('#repo_total').text(""); - $('#pr_total').text(""); - $('#issue_total').text(""); - $('#dataset_total').text(""); - $('#user_total').text(""); - $('#org_total').text(""); - setActivate(null); + emptySearch(); } } +function emptySearch(){ + initDiv(false); + document.getElementById("find_id").innerHTML=getLabel(isZh,"search_empty"); + $('#find_title').html(""); + document.getElementById("sort_type").innerHTML=""; + document.getElementById("child_search_item").innerHTML=""; + document.getElementById("page_menu").innerHTML=""; + $('#repo_total').text(""); + $('#pr_total').text(""); + $('#issue_total').text(""); + $('#dataset_total').text(""); + $('#user_total').text(""); + $('#org_total').text(""); + setActivate(null); +} + function initDiv(isSearchLabel=false){ if(isSearchLabel){ document.getElementById("search_div").style.display="none"; @@ -1285,6 +1290,8 @@ var zhCN={ var specifySearch = sessionStorage.getItem("specifySearch"); if(specifySearch){ sessionStorage.removeItem("specifySearch"); + console.log("search sepcial keyword=...." + sessionStorage.getItem("keyword")); + document.getElementById("keyword_input").value = sessionStorage.getItem("keyword"); doSpcifySearch(sessionStorage.getItem("tableName"),sessionStorage.getItem("keyword"),sessionStorage.getItem("sortBy"),sessionStorage.getItem("ascending")); }else{ console.log("normal search...."); From aa05fbe13a02ca2b1568559d413e402adef96c51 Mon Sep 17 00:00:00 2001 From: wangjr Date: Fri, 1 Apr 2022 15:02:49 +0800 Subject: [PATCH 027/129] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/explore/organizations.tmpl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/templates/explore/organizations.tmpl b/templates/explore/organizations.tmpl index 757e80556..58615a8e5 100644 --- a/templates/explore/organizations.tmpl +++ b/templates/explore/organizations.tmpl @@ -10,13 +10,13 @@
-
-
- +
+
+ - +
- +
@@ -208,6 +208,19 @@ From 347e580fec44326423be087357c5022c69a71d7d Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Sat, 2 Apr 2022 11:49:09 +0800 Subject: [PATCH 038/129] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=94=B9=E4=B8=BA=E7=A7=81=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 2 +- models/repo.go | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index af47c53fe..c0d82d250 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -348,7 +348,7 @@ func GetDatasetByRepo(repo *Repository) (*Dataset, error) { if has { return dataset, nil } else { - return nil, errors.New("Not Found") + return nil, ErrNotExist{repo.ID} } } diff --git a/models/repo.go b/models/repo.go index b5d4921e4..25bfb4a74 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1607,14 +1607,16 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e } dataset, err := GetDatasetByRepo(repo) - if err != nil { + if err != nil && !IsErrNotExist(err) { return err } - _, err = e.Where("dataset_id = ?", dataset.ID).Cols("is_private").Update(&Attachment{ - IsPrivate: true, - }) - if err != nil { - return err + if dataset != nil { + _, err = e.Where("dataset_id = ?", dataset.ID).Cols("is_private").Update(&Attachment{ + IsPrivate: true, + }) + if err != nil { + return err + } } } else { From 876cb5ed4f9fa4418583558282604491a4c0c35a Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 14:32:27 +0800 Subject: [PATCH 039/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index b6c99df85..109fb195f 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -186,10 +186,10 @@ td, th {
{{.displayJobName}}

- -
+ {{range $k ,$v := .version_list_task}} +
-
+
@@ -216,13 +216,13 @@ td, th {
-
+
-
+
@@ -388,7 +388,7 @@ td, th {
-
+
- - {{template "base/paginate" .}} + {{end}} {{template "base/paginate" .}}
From 5935583a2e71ac545ff130505dee98fb744d569e Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Sat, 2 Apr 2022 14:43:16 +0800 Subject: [PATCH 040/129] show restart record --- routers/repo/cloudbrain.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 59d16a5d8..d1465745e 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -449,10 +449,15 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo task.ContainerID = taskRes.TaskStatuses[0].ContainerID task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) - err = models.UpdateJob(task) - if err != nil { - ctx.Data["error"] = err.Error() - return + + if task.DeletedAt.IsZero() { //normal record + err = models.UpdateJob(task) + if err != nil { + ctx.Data["error"] = err.Error() + return + } + } else { //restart record + } } else { task.Status = jobRes.JobStatus.State @@ -472,12 +477,6 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo return } - if task.DeletedAt.IsZero() { //normal record - - } else { //restart record - - } - user, err := models.GetUserByID(task.UserID) if err == nil { task.User = user From 85ce0687f9a9c19325878422ba359b1230967147 Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:11:26 +0800 Subject: [PATCH 041/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/benchmark/show.tmpl | 13 +++++----- templates/repo/cloudbrain/show.tmpl | 26 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index 109fb195f..16e5a98f5 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -281,7 +281,7 @@ td, th { - 镜像 + {{.i18n.Tr "cloudbrain.mirror"}} @@ -292,7 +292,8 @@ td, th { - 类型 + {{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_type"}} + @@ -313,7 +314,7 @@ td, th { - 训练程序 + {{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_train"}} @@ -324,7 +325,7 @@ td, th { - 测试程序 + {{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_test"}} @@ -360,7 +361,7 @@ td, th { - 创建者 + {{$.i18n.Tr "repo.cloudbrain_creator"}} @@ -371,7 +372,7 @@ td, th { - 子类型 + {{$.i18n.Tr "repo.cloudbrain.benchmark.evaluate_child_type"}} diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 109fb195f..948d43e97 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -179,8 +179,8 @@ td, th { {{.i18n.Tr "repo.cloudbrain"}}
/
- - {{$.i18n.Tr "repo.modelarts.evaluate_job"}} + + {{$.i18n.Tr "repo.modelarts.notebook"}}
/
{{.displayJobName}}
@@ -281,7 +281,7 @@ td, th { - 镜像 + {{.i18n.Tr "cloudbrain.mirror"}} @@ -292,12 +292,12 @@ td, th { - 类型 + {{$.i18n.Tr "repo.modelarts.train_job.dataset"}}
- {{$.BenchmarkTypeName}} + {{.DatasetName}}
@@ -313,30 +313,30 @@ td, th { - 训练程序 + 平台
- train.py + {{$.Platform}}
- 测试程序 + ExitCode
- test.py + {{$.JobStatus.AppExitCode}}
- {{$.i18n.Tr "repo.modelarts.train_job.description"}} + {{.i18n.Tr "cloudbrain.code_storage_path"}} @@ -360,7 +360,7 @@ td, th { - 创建者 + {{$.i18n.Tr "repo.cloudbrain_creator"}} @@ -371,12 +371,12 @@ td, th { - 子类型 + {{$.i18n.Tr "repo.cloudbrain.exitinfo"}}
- {{$.BenchmarkChildTypeName}} + {{$.JobStatus.AppExitDiagnostics | nl2br}}
From 4afba2eae4d98188b6a5a4d461d977060f9f5d24 Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:13:11 +0800 Subject: [PATCH 042/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 948d43e97..648fc0e3d 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -281,7 +281,7 @@ td, th { - {{.i18n.Tr "cloudbrain.mirror"}} + {{$.i18n.Tr "cloudbrain.mirror"}} @@ -336,7 +336,7 @@ td, th { - {{.i18n.Tr "cloudbrain.code_storage_path"}} + {{$.i18n.Tr "cloudbrain.code_storage_path"}} From c1d6231a139a89b312cfac708800b7b780aa2676 Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:18:56 +0800 Subject: [PATCH 043/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 648fc0e3d..082393ad0 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -329,7 +329,7 @@ td, th {
- {{$.JobStatus.AppExitCode}} + {{$.result.JobStatus.AppExitCode}}
@@ -376,7 +376,7 @@ td, th {
- {{$.JobStatus.AppExitDiagnostics | nl2br}} + {{$.result.JobStatus.AppExitDiagnostics}}
From 784c884d3922d91e3372ec30941f59668fcbdb40 Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:25:44 +0800 Subject: [PATCH 044/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/cloudbrain.go | 11 +++++++++-- templates/repo/cloudbrain/show.tmpl | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 898f3844f..33ce5debb 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -2,11 +2,9 @@ package repo import ( "bufio" - "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "fmt" - "github.com/unknwon/i18n" "io" "net/http" "os" @@ -16,6 +14,9 @@ import ( "strings" "time" + "code.gitea.io/gitea/modules/timeutil" + "github.com/unknwon/i18n" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" @@ -510,6 +511,12 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo } } + attachment, err := models.GetAttachmentByUUID(task.Uuid) + if err == nil { + ctx.Data["datasetname"] = attachment.Name + } else { + ctx.Data["datasetname"] = "" + } ctx.Data["task"] = task ctx.Data["jobName"] = task.JobName diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 082393ad0..54e721b08 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -297,7 +297,7 @@ td, th {
- {{.DatasetName}} + {{$.datasetname}}
From e5ce5bfb060bba1882c6fd0e044ec6b16f846b1f Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:33:15 +0800 Subject: [PATCH 045/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 54e721b08..98b4e56ba 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -375,9 +375,9 @@ td, th { -
- {{$.result.JobStatus.AppExitDiagnostics}} -
+ + {{$.result.JobStatus.AppExitDiagnostics}} + From 98a47aae216073e3fca60077f79f043acf605c5e Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:39:08 +0800 Subject: [PATCH 046/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 1 + templates/repo/cloudbrain/show.tmpl | 55 ++++++++--------------------- 3 files changed, 16 insertions(+), 42 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 09bb5015f..bed7c46e0 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -911,7 +911,7 @@ language_other = Other datasets = Datasets datasets.desc = Enable Dataset cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, etc. - +cloudbrain.exitinfo=Exit Information model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index d26065363..7bf28aa10 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -958,6 +958,7 @@ cloudbrain_jobname_err=只能以小写字母或数字开头且只包含小写字 cloudbrain_query_fail=查询云脑任务失败。 cloudbrain.mirror_tag = 镜像标签 cloudbrain.mirror_description = 镜像描述 +cloudbrain.exitinfo=退出信息 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 98b4e56ba..789f915d1 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -290,19 +290,7 @@ td, th {
- - - {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} - - - -
- {{$.datasetname}} -
- - - - +
@@ -336,12 +324,12 @@ td, th { - {{$.i18n.Tr "cloudbrain.code_storage_path"}} + {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} -
- {{.Description}} +
+ {{$.datasetname}}
@@ -369,39 +357,24 @@ td, th {
- - - {{$.i18n.Tr "repo.cloudbrain.exitinfo"}} - - - - - {{$.result.JobStatus.AppExitDiagnostics}} - - - +
+
+
+ {{$.i18n.Tr "repo.cloudbrain.exitinfo"}} +
+
+ {{$.result.JobStatus.AppExitDiagnostics}} +
+
-
-
- -
- - -

-                            
- -
- -
+
From 4390d617f8a6da4f3fd00a1f67a94db5c6b480c5 Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 15:54:56 +0800 Subject: [PATCH 047/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 789f915d1..b6294d280 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -220,7 +220,6 @@ td, th {
@@ -364,11 +363,12 @@ td, th {
- {{$.i18n.Tr "repo.cloudbrain.exitinfo"}} + {{$.i18n.Tr "repo.cloudbrain.exitinfo"}} +
-
- {{$.result.JobStatus.AppExitDiagnostics}} -
+
+
+ {{$.result.JobStatus.AppExitDiagnostics}}
From 05a9809f5f2e02e97deed819519510950303a0c0 Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 16:02:27 +0800 Subject: [PATCH 048/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index b6294d280..b5baa7df8 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -56,7 +56,7 @@ margin:10px 5px ; } .tab_2_content { - min-height: 360px; + min-height: 560px; margin-left: 10px; } .ac-grid { @@ -81,6 +81,13 @@ .ti-form>tbody, .ti-form>tbody>tr { vertical-align: inherit; } +.info_text { + padding-bottom: 20px; + padding-right: 20px; + color: #8a8e99; + font-size: 12px; +} + .ti-text-form-label { padding-bottom: 20px; @@ -368,7 +375,9 @@ td, th {
+ {{$.result.JobStatus.AppExitDiagnostics}} +
From b4182391139a7b2ccc3c6a4fdcba1cb06c41b00e Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 2 Apr 2022 16:10:43 +0800 Subject: [PATCH 049/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index b5baa7df8..b1dd6e661 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -84,7 +84,6 @@ .info_text { padding-bottom: 20px; padding-right: 20px; - color: #8a8e99; font-size: 12px; } @@ -312,7 +311,7 @@ td, th {
- {{$.Platform}} + {{$.result.Platform}}
From 5defcd0c8145ab58509e0466fbb6277d15b9729b Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Sat, 2 Apr 2022 16:11:22 +0800 Subject: [PATCH 050/129] format --- routers/repo/cloudbrain.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index d1465745e..0ddb1e1fe 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -456,7 +456,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo ctx.Data["error"] = err.Error() return } - } else { //restart record + } else { //deleted record } } else { @@ -982,7 +982,6 @@ func uploadCodeToMinio(codePath, jobName, parentDir string) error { destObject := setting.CBCodePathPrefix + jobName + parentDir + file.Name() sourceFile := codePath + file.Name() err = storage.Attachments.UploadObject(destObject, sourceFile) - if err != nil { log.Error("UploadObject(%s) failed: %s", file.Name(), err.Error()) return err From b01f528dbd9e7bfeed68de26290a7149e3e34a07 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 6 Apr 2022 10:47:49 +0800 Subject: [PATCH 051/129] fix 1820 --- templates/admin/cloudbrain/list.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 templates/admin/cloudbrain/list.tmpl diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl old mode 100644 new mode 100755 index 39b2c21de..02f100e46 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -81,7 +81,7 @@ {{.DisplayJobName}} {{else if eq .JobType "TRAIN"}} - + {{.DisplayJobName}} {{else if eq .JobType "BENCHMARK"}} @@ -155,13 +155,13 @@ {{else}} - + {{$.i18n.Tr "repo.stop"}} {{end}}
-
+ {{$.CsrfTokenHtml}} {{$.i18n.Tr "repo.delete"}} From 62f724b0183e8f60bcc47fdce88ae0664dd3b405 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 6 Apr 2022 10:48:31 +0800 Subject: [PATCH 052/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 23 +++++++++++++++++++++++ routers/api/v1/api.go | 2 ++ routers/repo/user_data_analysis.go | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index edfe73939..65ce642d5 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -207,6 +207,29 @@ func getLastCountDate() int64 { return pageStartTime.Unix() } +func QueryMetrics(start int64, end int64) ([]*UserMetrics, int64) { + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + userMetricsList := make([]*UserMetrics, 0) + if err := statictisSess.Table(new(UserMetrics)).Where("count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end)).OrderBy("count_date desc"). + Find(&userMetricsList); err != nil { + return nil, 0 + } + return userMetricsList, int64(len(userMetricsList)) +} + +func QueryRankList(key string, tableName string, limit int) ([]*UserBusinessAnalysisAll, int64) { + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + + userBusinessAnalysisAllList := make([]*UserBusinessAnalysisAll, 0) + if err := statictisSess.Table(tableName).OrderBy(key+" desc,id desc").Limit(limit, 0). + Find(&userBusinessAnalysisAllList); err != nil { + return nil, 0 + } + return userBusinessAnalysisAllList, int64(len(userBusinessAnalysisAllList)) +} + func QueryUserStaticDataByTableName(start int, pageSize int, tableName string, queryObj interface{}, userName string) ([]*UserBusinessAnalysisAll, int64) { statictisSess := xStatistic.NewSession() defer statictisSess.Close() diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 1868edcb5..9de65662f 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -547,6 +547,8 @@ func RegisterRoutes(m *macaron.Macaron) { }) }, operationReq) + m.Get("/query_user_metrics", operationReq, repo_ext.QueryMetrics) + m.Get("/query_user_rank_list", operationReq, repo_ext.QueryRankingList) m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) m.Get("/query_user_current_month", operationReq, repo_ext.QueryUserStaticCurrentMonth) m.Get("/query_user_current_week", operationReq, repo_ext.QueryUserStaticCurrentWeek) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 96503e5c9..9d906270f 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -126,6 +126,30 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac } } +func QueryMetrics(ctx *context.Context) { + startDate := ctx.Query("startDate") + endDate := ctx.Query("endDate") + startTime, _ := time.ParseInLocation("2006-01-02", startDate, time.Local) + endTime, _ := time.ParseInLocation("2006-01-02", endDate, time.Local) + result, count := models.QueryMetrics(startTime.Unix(), endTime.Unix()) + mapInterface := make(map[string]interface{}) + mapInterface["data"] = result + mapInterface["count"] = count + ctx.JSON(http.StatusOK, mapInterface) +} + +func QueryRankingList(ctx *context.Context) { + key := ctx.Query("key") + tableName := ctx.Query("tableName") + limit := ctx.QueryInt("limit") + + result, count := models.QueryRankList(key, tableName, limit) + mapInterface := make(map[string]interface{}) + mapInterface["data"] = result + mapInterface["count"] = count + ctx.JSON(http.StatusOK, mapInterface) +} + func QueryUserStaticCurrentMonth(ctx *context.Context) { queryUserDataPage(ctx, "public.user_business_analysis_current_month", new(models.UserBusinessAnalysisCurrentMonth)) } From c9b78df4dac3c12e980947402455a72176982045 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 6 Apr 2022 11:06:15 +0800 Subject: [PATCH 053/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + routers/repo/cloudbrain.go | 3 +++ templates/repo/cloudbrain/show.tmpl | 38 +++++++++++++++++++++++++++-- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index bed7c46e0..7c6e50892 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -912,6 +912,7 @@ datasets = Datasets datasets.desc = Enable Dataset cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, etc. cloudbrain.exitinfo=Exit Information +cloudbrain.platform=Platform model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 7bf28aa10..5a70a0e6f 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -959,6 +959,7 @@ cloudbrain_query_fail=查询云脑任务失败。 cloudbrain.mirror_tag = 镜像标签 cloudbrain.mirror_description = 镜像描述 cloudbrain.exitinfo=退出信息 +cloudbrain.platform=平台 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 33ce5debb..de6f97fc9 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -525,6 +525,9 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo version_list_task = append(version_list_task, task) ctx.Data["version_list_task"] = version_list_task ctx.Data["debugListType"] = debugListType + ctx.Data["code_path"] = cloudbrain.CodeMountPath + ctx.Data["dataset_path"] = cloudbrain.DataSetMountPath + ctx.Data["model_path"] = cloudbrain.ModelMountPath ctx.Data["canDownload"] = cloudbrain.CanDeleteJob(ctx, task) ctx.HTML(200, tpName) } diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index b1dd6e661..1eaede8fd 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -295,6 +295,30 @@ td, th {
+ + + + {{$.i18n.Tr "cloudbrain.dataset_storage_path"}} + + + +
+ {{$.dataset_path}} +
+ + + + + + {{$.i18n.Tr ""cloudbrain.code_storage_path"}} + + + +
+ {{$.code_path}} +
+ + @@ -306,7 +330,7 @@ td, th { - 平台 + {{$.i18n.Tr "repo.cloudbrain.platform"}} @@ -362,7 +386,17 @@ td, th {
- + + + {{$.i18n.Tr "cloudbrain.model_storage_path"}} + + + +
+ {{$.model_path}} +
+ +
From 19508fdf0ac84fc5e873e51c04251eb3d70cf79c Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 6 Apr 2022 11:08:16 +0800 Subject: [PATCH 054/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 1eaede8fd..fb885562e 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -310,7 +310,7 @@ td, th { - {{$.i18n.Tr ""cloudbrain.code_storage_path"}} + {{$.i18n.Tr "cloudbrain.code_storage_path"}} From 73a5392fb492bd94abab2bec2d32b4d4230274d7 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 6 Apr 2022 11:23:50 +0800 Subject: [PATCH 055/129] fix-1802 --- models/dataset.go | 48 +++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index c0d82d250..7cac6c468 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -139,20 +139,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { var cond = builder.NewCond() cond = cond.And(builder.Neq{"dataset.status": DatasetStatusDeleted}) - if len(opts.Keyword) > 0 { - cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) - } - - if len(opts.Category) > 0 { - cond = cond.And(builder.Eq{"dataset.category": opts.Category}) - } - - if len(opts.Task) > 0 { - cond = cond.And(builder.Eq{"dataset.task": opts.Task}) - } - if len(opts.License) > 0 { - cond = cond.And(builder.Eq{"dataset.license": opts.License}) - } + cond = generateFilterCond(opts, cond) if opts.RepoID > 0 { cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID}) @@ -162,14 +149,12 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) cond = cond.And(builder.Eq{"attachment.is_private": false}) if opts.OwnerID > 0 { - if len(opts.Keyword) == 0 { - cond = cond.Or(builder.Eq{"repository.owner_id": opts.OwnerID}) - } else { - subCon := builder.NewCond() - subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}, builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) - cond = cond.Or(subCon) - - } + + subCon := builder.NewCond() + subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}) + subCon = generateFilterCond(opts, subCon) + cond = cond.Or(subCon) + } } else if opts.OwnerID > 0 { cond = cond.And(builder.Eq{"repository.owner_id": opts.OwnerID}) @@ -182,6 +167,25 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { return cond } +func generateFilterCond(opts *SearchDatasetOptions, cond builder.Cond) builder.Cond { + if len(opts.Keyword) > 0 { + cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) + } + + if len(opts.Category) > 0 { + cond = cond.And(builder.Eq{"dataset.category": opts.Category}) + } + + if len(opts.Task) > 0 { + cond = cond.And(builder.Eq{"dataset.task": opts.Task}) + } + if len(opts.License) > 0 { + cond = cond.And(builder.Eq{"dataset.license": opts.License}) + } + + return cond +} + func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (DatasetList, int64, error) { if opts.Page <= 0 { opts.Page = 1 From 4c8de8891d3bdd89ec6fb55f2a19055230f0b2cb Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 6 Apr 2022 14:45:13 +0800 Subject: [PATCH 056/129] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 2 +- templates/repo/cloudbrain/show.tmpl | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7c6e50892..94214a25c 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -913,6 +913,7 @@ datasets.desc = Enable Dataset cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, etc. cloudbrain.exitinfo=Exit Information cloudbrain.platform=Platform +cloudbrain.endtime=End Time model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 5a70a0e6f..e93b05ffb 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -960,7 +960,7 @@ cloudbrain.mirror_tag = 镜像标签 cloudbrain.mirror_description = 镜像描述 cloudbrain.exitinfo=退出信息 cloudbrain.platform=平台 - +cloudbrain.endtime=结束时间 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 total_count_get_error=查询总页数失败。 diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index fb885562e..d7aeb36d7 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -363,6 +363,22 @@ td, th { + + + {{$.i18n.Tr "repo.cloudbrain.endtime"}} + + + +
+ {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .EndTime}} + {{else}} + -- + {{end}} +
+ + + {{$.i18n.Tr "repo.modelarts.train_job.standard"}} From 842f60734497349649ee8b9015af7b9e4ace5fb2 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 6 Apr 2022 14:52:37 +0800 Subject: [PATCH 057/129] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show--bak.tmpl | 108 ----------------------- templates/repo/cloudbrain/show.tmpl | 20 ++--- 2 files changed, 10 insertions(+), 118 deletions(-) delete mode 100644 templates/repo/cloudbrain/show--bak.tmpl diff --git a/templates/repo/cloudbrain/show--bak.tmpl b/templates/repo/cloudbrain/show--bak.tmpl deleted file mode 100644 index 1e234e094..000000000 --- a/templates/repo/cloudbrain/show--bak.tmpl +++ /dev/null @@ -1,108 +0,0 @@ -{{template "base/head" .}} -
-{{template "repo/header" .}} -
-
- {{template "base/alert" .}} - -

- -

-
-
- {{with .task}} -

任务名称: {{.DisplayJobName}}

- {{end}} -
-
-

任务结果:

- {{with .taskRes}} - {{range .TaskStatuses}} - - - - - - - -
状态 {{.State}}
- {{end}} - {{end}} -
-
- {{with .result}} - - - - - - - - - - - - - - - - - - -
硬件信息
CPU {{.Resource.CPU}}
Memory {{.Resource.Memory}}
NvidiaComGpu {{.Resource.NvidiaComGpu}}
- - - - - - - - - - - - - {{if not (eq $.task.StartTime 0)}} - - {{else}} - - - - {{if not (eq $.task.EndTime 0)}} - - {{else}} - - - - - - - - - - -
调试信息
平台 {{.Platform}}
开始时间 {{TimeSinceUnix1 $.task.StartTime}} - {{end}} -
结束时间 {{TimeSinceUnix1 $.task.EndTime}} - {{end}} -
ExitCode {{.JobStatus.AppExitCode}}
退出信息 {{.JobStatus.AppExitDiagnostics | nl2br}}
- {{end}} -
-
- -
-
-
-{{template "base/footer" .}} diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index d7aeb36d7..895a5c14f 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -350,35 +350,35 @@ td, th {
- - {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} + {{$.i18n.Tr "repo.cloudbrain.endtime"}}
- {{$.datasetname}} + {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .EndTime}} + {{else}} + -- + {{end}}
- - {{$.i18n.Tr "repo.cloudbrain.endtime"}} + {{$.i18n.Tr "repo.modelarts.train_job.dataset"}}
- {{if not (eq .StartTime 0)}} - {{TimeSinceUnix1 .EndTime}} - {{else}} - -- - {{end}} + {{$.datasetname}}
+ + {{$.i18n.Tr "repo.modelarts.train_job.standard"}} From fa0f91d24f537f4bb44a01435e7bfe6aee5417ee Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 6 Apr 2022 16:56:15 +0800 Subject: [PATCH 058/129] fix 1718 --- routers/repo/cloudbrain.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 73b1914e5..322b131c8 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -346,6 +346,24 @@ func CloudBrainRestart(ctx *context.Context) { break } + var hasSameResource bool + if gpuInfos == nil { + json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) + } + for _, resourceType := range gpuInfos.GpuInfo { + if resourceType.Queue == task.GpuQueue { + hasSameResource = true + continue + } + } + + if !hasSameResource { + log.Error("has no same resource, can not restart", ctx.Data["MsgID"]) + resultCode = "-1" + errorMsg = "the job's version is too old and can not be restarted" + break + } + count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, string(models.JobTypeDebug)) if err != nil { log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) From 6eb17718d0f33e13170993ed8a63c7c996035507 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 7 Apr 2022 09:40:35 +0800 Subject: [PATCH 059/129] fix-1827 --- models/dataset.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 7cac6c468..939aa8634 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -62,19 +62,20 @@ func (datasets DatasetList) loadAttributes(e Engine) error { } set := make(map[int64]struct{}) + userIdSet := make(map[int64]struct{}) datasetIDs := make([]int64, len(datasets)) for i := range datasets { - set[datasets[i].UserID] = struct{}{} + userIdSet[datasets[i].UserID] = struct{}{} set[datasets[i].RepoID] = struct{}{} datasetIDs[i] = datasets[i].ID } // Load owners. - users := make(map[int64]*User, len(set)) + users := make(map[int64]*User, len(userIdSet)) repos := make(map[int64]*Repository, len(set)) if err := e. Where("id > 0"). - In("id", keysInt64(set)). + In("id", keysInt64(userIdSet)). Find(&users); err != nil { return fmt.Errorf("find users: %v", err) } From d38f55927b3d0e82927c3ac4999f474ffb4aacbb Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 7 Apr 2022 10:31:39 +0800 Subject: [PATCH 060/129] #1639 add error msg for shell --- options/locale/locale_en-US.ini | 4 +++ options/locale/locale_zh-CN.ini | 3 ++ routers/repo/editor.go | 11 +++++-- routers/repo/http.go | 52 +++++++++++++++++++++++++++-- services/repository/repository.go | 55 ++++++++++++++++++++++++++++--- 5 files changed, 116 insertions(+), 9 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a990e9aee..f9bebbb86 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1236,6 +1236,10 @@ editor.cannot_commit_to_protected_branch = Cannot commit to protected branch '%s editor.no_commit_to_branch = Unable to commit directly to branch because: editor.user_no_push_to_branch = User cannot push to branch editor.require_signed_commit = Branch requires a signed commit +editor.repo_too_large = Repository can not exceed %d MB +editor.repo_file_invalid = Upload files are invalid +editor.upload_file_too_much = Can not upload more than %d files at a time + commits.desc = Browse source code change history. commits.commits = Commits diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 4e73fbad5..8679554c6 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1244,6 +1244,9 @@ editor.cannot_commit_to_protected_branch=不可以提交到受保护的分支 '% editor.no_commit_to_branch=无法直接提交分支,因为: editor.user_no_push_to_branch=用户不能推送到分支 editor.require_signed_commit=分支需要签名提交 +editor.repo_too_large = 代码仓总大小不能超过%dMB +editor.repo_file_invalid = 提交的文件非法 +editor.upload_file_too_much = 不能同时提交超过%d个文件 commits.desc=浏览代码修改历史 commits.commits=次代码提交 diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 94ced019c..b089a784c 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -616,8 +616,15 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) { } if err := repo_service.CheckRepoSizeLimit(ctx.Repo.Repository, form.Files); err != nil { - //ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", part), tplUploadFile, &form) - ctx.RenderWithErr(err.Error(), tplUploadFile, &form) + if repo_service.IsRepoTooLargeErr(err) { + ctx.RenderWithErr(ctx.Tr("repo.editor.repo_too_large", setting.Repository.RepoMaxSize), tplUploadFile, &form) + } else if repo_service.IsUploadFileInvalidErr(err) { + ctx.RenderWithErr(ctx.Tr("repo.editor.repo_file_invalid"), tplUploadFile, &form) + } else if repo_service.IsUploadFileTooMuchErr(err) { + ctx.RenderWithErr(ctx.Tr("repo.editor.upload_file_too_much", setting.Repository.Upload.MaxFiles), tplUploadFile, &form) + } else { + ctx.RenderWithErr(err.Error(), tplUploadFile, &form) + } return } diff --git a/routers/repo/http.go b/routers/repo/http.go index 87406a2c3..99d38d437 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -365,8 +365,7 @@ func HTTP(ctx *context.Context) { ctx.NotFound("Smart Git HTTP", err) return } - - route.handler(serviceHandler{cfg, w, r, dir, file, cfg.Env}) + route.handler(serviceHandler{cfg, w, r, dir, file, cfg.Env, repo}) return } } @@ -429,6 +428,7 @@ type serviceHandler struct { dir string file string environ []string + repo *models.Repository } func (h *serviceHandler) setHeaderNoCache() { @@ -546,6 +546,19 @@ func serviceRPC(h serviceHandler, service string) { return } } + content, _ := ioutil.ReadAll(reqBody) + //check size + if service == "receive-pack" { + if err := repo_service.CheckRepoTotalSizeLimit(h.repo, int64(len(content))); err != nil { + h.w.WriteHeader(http.StatusOK) + str := GenerateGitErrorBody(err.Error()) + h.w.Write([]byte(str)) + if h.w.Header().Get("Content-Type") == "" { + h.w.Header().Set("Content-Type", "application/x-git-receive-pack-result") + } + return + } + } // set this for allow pre-receive and post-receive execute h.environ = append(h.environ, "SSH_ORIGINAL_COMMAND="+service) @@ -560,7 +573,7 @@ func serviceRPC(h serviceHandler, service string) { } cmd.Stdout = h.w - cmd.Stdin = reqBody + cmd.Stdin = bytes.NewReader(content) cmd.Stderr = &stderr pid := process.GetManager().Add(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir), cancel) @@ -572,6 +585,39 @@ func serviceRPC(h serviceHandler, service string) { } } +func GenerateGitErrorBody(content string) string { + var builder strings.Builder + builder.WriteString(GenerateErrStartPKTLine()) + builder.WriteString(GeneratePKTLine(content)) + builder.WriteString(GenerateEndPKTLine()) + return builder.String() +} + +func GeneratePKTLine(content string) string { + content = "\u0002\033[31m " + content + " \033[0m" + l := len(content) + prefixLength := 4 + suffix := "\n" + f := strconv.FormatInt(int64(l+prefixLength+len(suffix)), 16) + lf := len(f) + if lf == 1 { + f = "000" + f + } else if lf == 2 { + f = "00" + f + } else if lf == 3 { + f = "0" + f + } + return f + content + suffix +} + +func GenerateEndPKTLine() string { + return "0000" +} + +func GenerateErrStartPKTLine() string { + return "0031\u0001000eunpack err\n0019ok refs/heads/master\n0000" +} + func serviceUploadPack(h serviceHandler) { serviceRPC(h, "upload-pack") } diff --git a/services/repository/repository.go b/services/repository/repository.go index c9080f930..fc4411056 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -5,7 +5,6 @@ package repository import ( - "errors" "fmt" "io/ioutil" "net/http" @@ -181,7 +180,7 @@ func CheckRepoSizeLimit(repo *models.Repository, fileIds []string) error { } totalSize, err := CountUploadFileSizeByIds(fileIds) if err != nil { - return errors.New("upload files are invalid") + return UploadFileInvalidErr{} } if err := CheckRepoTotalSizeLimit(repo, totalSize); err != nil { return err @@ -191,14 +190,14 @@ func CheckRepoSizeLimit(repo *models.Repository, fileIds []string) error { func CheckRepoTotalSizeLimit(repo *models.Repository, uploadFileSize int64) error { if repo.Size+uploadFileSize > setting.Repository.RepoMaxSize*1024*1024 { - return errors.New(fmt.Sprintf("repository can not exceed %d MB", setting.Repository.RepoMaxSize)) + return RepoTooLargeErr{} } return nil } func CheckRepoNumOnceLimit(uploadFileNum int) error { if uploadFileNum > setting.Repository.Upload.MaxFiles { - return errors.New(fmt.Sprintf("can not upload more than %d files at a time", setting.Repository.Upload.MaxFiles)) + return UploadFileTooMuchErr{} } return nil } @@ -231,3 +230,51 @@ func GetUploadFileSize(upload *models.Upload) (int64, error) { return info.Size(), nil } + +type RepoTooLargeErr struct { +} + +func (RepoTooLargeErr) Error() string { + return fmt.Sprintf("Repository can not exceed %d MB. Please remove some unnecessary files and try again", setting.Repository.RepoMaxSize) +} + +func IsRepoTooLargeErr(err error) bool { + _, ok := err.(RepoTooLargeErr) + return ok +} + +type RepoFileTooLargeErr struct { +} + +func (RepoFileTooLargeErr) Error() string { + return "repository file is too large" +} + +func IsRepoFileTooLargeErr(err error) bool { + _, ok := err.(RepoFileTooLargeErr) + return ok +} + +type UploadFileTooMuchErr struct { +} + +func (UploadFileTooMuchErr) Error() string { + return "upload files are too lmuch" +} + +func IsUploadFileTooMuchErr(err error) bool { + _, ok := err.(UploadFileTooMuchErr) + return ok +} + +type UploadFileInvalidErr struct { +} + +func (UploadFileInvalidErr) Error() string { + return "upload files are invalid" +} + +func IsUploadFileInvalidErr(err error) bool { + _, ok := err.(UploadFileInvalidErr) + return ok +} From 4197eaec1303d88b38e751d5269fa37c312e2f04 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 7 Apr 2022 10:42:05 +0800 Subject: [PATCH 061/129] no_record md5 --- models/attachment.go | 1 + models/dataset.go | 9 ++++++++- templates/repo/datasets/index.tmpl | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index a3fc6fa01..7c95a73dd 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -51,6 +51,7 @@ type Attachment struct { FileChunk *FileChunk `xorm:"-"` CanDel bool `xorm:"-"` Uploader *User `xorm:"-"` + Md5 string `xorm:"-"` } type AttachmentUsername struct { diff --git a/models/dataset.go b/models/dataset.go index 7cac6c468..c56a8fdc3 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,6 +1,7 @@ package models import ( + "code.gitea.io/gitea/modules/log" "errors" "fmt" "sort" @@ -296,7 +297,13 @@ func getDatasetAttachments(e Engine, typeCloudBrain int, isSigned bool, user *Us if err != nil { return err } - attachment.FileChunk = fileChunks[0] + if len(fileChunks) > 0 { + attachment.Md5 = fileChunks[0].Md5 + } else { + log.Error("has attachment record, but has no file_chunk record") + attachment.Md5 = "no_record" + } + attachment.CanDel = CanDelAttachment(isSigned, user, attachment) sortedRels.Rel[currentIndex].Attachments = append(sortedRels.Rel[currentIndex].Attachments, attachment) } diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 065ada386..e8d9b65e3 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -199,7 +199,7 @@
{{range $k, $v :=.Attachments}} -
+
@@ -266,8 +266,8 @@ {{$.i18n.Tr "preview"}} {{end}} {{if and (.CanDel) (not $.Repository.IsPrivate)}} - {{$.i18n.Tr "dataset.set_public"}} - {{$.i18n.Tr "dataset.set_private"}} + {{$.i18n.Tr "dataset.set_public"}} + {{$.i18n.Tr "dataset.set_private"}} {{end}} +
+
-
+ +
{{template "base/footer" .}} + + From 45ec621d6f76b249aae0b2548f8ff017e34db83d Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 7 Apr 2022 10:44:14 +0800 Subject: [PATCH 063/129] add stop status --- templates/admin/cloudbrain/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 02f100e46..6fea2eef7 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -155,7 +155,7 @@ {{else}} - + {{$.i18n.Tr "repo.stop"}} {{end}} From 6400513d3e0654b95c9ef79f099b8f17e4f525f9 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:46:19 +0800 Subject: [PATCH 064/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 8e69dac3e..d9c38eb44 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -397,7 +397,7 @@ td, th {
- {{end}} {{template "base/paginate" .}} + {{template "base/paginate" .}}
From 3af7725f62bac7350e81116241790b6b39554642 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:51:07 +0800 Subject: [PATCH 065/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 26 +++++++-------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index d9c38eb44..4b4446587 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -190,11 +190,11 @@ td, th {
/
{{with .task}} -
{{.DisplayJobName}}
- {{end}} +
{{.jobName}}
+ {{end}}
- + {{with .task}}
@@ -204,7 +204,7 @@ td, th {
- {{if not (eq .StartTime 0)}} + {{if not (eq .task.StartTime 0)}} {{TimeSinceUnix1 .StartTime}} {{else}} {{TimeSinceUnix1 .CreatedUnix}} @@ -241,7 +241,7 @@ td, th {
- {{.DisplayJobName}} + {{.jobName}}
@@ -327,7 +327,7 @@ td, th {
- {{if not (eq .StartTime 0)}} + {{if not (eq .task.StartTime 0)}} {{TimeSinceUnix1 .EndTime}} {{else}} -- @@ -397,6 +397,7 @@ td, th {
+ {{end}} {{template "base/paginate" .}}
@@ -445,17 +446,6 @@ td, th { jobName = urlArr.slice(-1)[0] }) - function loadLog(version_name){ - document.getElementById("mask").style.display = "block" - $.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobName}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { - $('input[name=end_line]').val(data.EndLine) - $('input[name=start_line]').val(data.StartLine) - $(`#log_file${version_name}`).text(data.Content) - document.getElementById("mask").style.display = "none" - }).fail(function(err) { - console.log(err); - document.getElementById("mask").style.display = "none" - }); - } + From 9426ce1a533d14559f894f23685df864de865fa1 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:51:59 +0800 Subject: [PATCH 066/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 4b4446587..b8fda3f7a 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -189,9 +189,9 @@ td, th { {{$.i18n.Tr "repo.modelarts.notebook"}}
/
- {{with .task}} -
{{.jobName}}
- {{end}} + +
{{.jobName}}
+
{{with .task}} From 877f3535da463138e8fbad3e92358934feda936b Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:52:30 +0800 Subject: [PATCH 067/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index b8fda3f7a..e53d94fcc 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -204,7 +204,7 @@ td, th {
- {{if not (eq .task.StartTime 0)}} + {{if not (eq .StartTime 0)}} {{TimeSinceUnix1 .StartTime}} {{else}} {{TimeSinceUnix1 .CreatedUnix}} From a08b745d040c82958827ef5a22426049502b7e31 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:53:10 +0800 Subject: [PATCH 068/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index e53d94fcc..4c946fa4a 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -241,7 +241,7 @@ td, th {
- {{.jobName}} + {{$.jobName}}
From deef8665fc3a7b0e31735b7f4669e3e95bb0ca5f Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:54:27 +0800 Subject: [PATCH 069/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 4c946fa4a..ecd17ec99 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -327,7 +327,7 @@ td, th {
- {{if not (eq .task.StartTime 0)}} + {{if not (eq .StartTime 0)}} {{TimeSinceUnix1 .EndTime}} {{else}} -- @@ -342,7 +342,7 @@ td, th {
- {{$.datasetname}} + {{.datasetname}}
@@ -356,7 +356,7 @@ td, th {
- {{$.resource_spec}} + {{.resource_spec}}
From f0423473ac3efffb79b13e13202f675274ca8deb Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:55:19 +0800 Subject: [PATCH 070/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index ecd17ec99..867f6f591 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -342,7 +342,7 @@ td, th {
- {{.datasetname}} + {{$.datasetDownloadLink}}
From 836f91aba01c1e16fe0f95459213867c5dcb273c Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 10:57:27 +0800 Subject: [PATCH 071/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 867f6f591..5cfb964b1 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -342,7 +342,7 @@ td, th {
- {{$.datasetDownloadLink}} + {{.DatasetName}}
From 0c4310afb1998261436e3c326bf9f7b4a6e380f4 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 7 Apr 2022 11:03:10 +0800 Subject: [PATCH 072/129] #1639 update --- routers/repo/http.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/repo/http.go b/routers/repo/http.go index 99d38d437..e3ab329ba 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -594,6 +594,8 @@ func GenerateGitErrorBody(content string) string { } func GeneratePKTLine(content string) string { + //\033[31m ... \033[0m + //mark the text red in shell content = "\u0002\033[31m " + content + " \033[0m" l := len(content) prefixLength := 4 From f7862ac693cc9e0aef8cfa6b1008b7f594b935c6 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 11:05:40 +0800 Subject: [PATCH 073/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/modelarts.go | 10 +++++++--- templates/repo/modelarts/notebook/show.tmpl | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 32d9db9ce..f003407c2 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -2,8 +2,6 @@ package repo import ( "archive/zip" - "code.gitea.io/gitea/modules/notification" - "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "io" @@ -16,6 +14,9 @@ import ( "time" "unicode/utf8" + "code.gitea.io/gitea/modules/notification" + "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" @@ -283,7 +284,10 @@ func NotebookShow(ctx *context.Context) { } } } - + if modelarts.FlavorInfos == nil { + json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) + } + ctx.Data["resource_spec"] = modelarts.FlavorInfos.FlavorInfo ctx.Data["datasetDownloadLink"] = datasetDownloadLink ctx.Data["task"] = task ctx.Data["ID"] = ID diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 5cfb964b1..68c94cdca 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -356,7 +356,7 @@ td, th {
- {{.resource_spec}} + {{$.resource_spec}}
From 7623fcdca9dbd38b4e938757a7121e583d62541c Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 11:08:14 +0800 Subject: [PATCH 074/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/modelarts.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index f003407c2..4b7582d4b 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -284,6 +284,10 @@ func NotebookShow(ctx *context.Context) { } } } + user, err := models.GetUserByID(task.UserID) + if err == nil { + task.User = user + } if modelarts.FlavorInfos == nil { json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) } From 5e7ada52c0f1bcc3a78872e87dac2f1f23140583 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 11:30:00 +0800 Subject: [PATCH 075/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/modelarts/modelarts.go | 1 + routers/repo/modelarts.go | 12 ++++++++++- templates/repo/modelarts/notebook/show.tmpl | 24 +++++---------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index 538fcfbd9..b1e7b269e 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -280,6 +280,7 @@ func GenerateNotebook2(ctx *context.Context, displayJobName, jobName, uuid, desc RepoID: ctx.Repo.Repository.ID, JobID: jobResult.ID, JobName: jobName, + FlavorCode: flavor, DisplayJobName: displayJobName, JobType: string(models.JobTypeDebug), Type: models.TypeCloudBrainTwo, diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 4b7582d4b..1f4a275d1 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -4,6 +4,7 @@ import ( "archive/zip" "encoding/json" "errors" + "fmt" "io" "io/ioutil" "net/http" @@ -291,7 +292,16 @@ func NotebookShow(ctx *context.Context) { if modelarts.FlavorInfos == nil { json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) } - ctx.Data["resource_spec"] = modelarts.FlavorInfos.FlavorInfo + if modelarts.FlavorInfos != nil { + ctx.Data["resource_spec"] = modelarts.FlavorInfos.FlavorInfo[0].Desc + for _, f := range modelarts.FlavorInfos.FlavorInfo { + if fmt.Sprint(f.Value) == task.FlavorCode { + ctx.Data["resource_spec"] = f.Desc + break + } + } + } + ctx.Data["datasetDownloadLink"] = datasetDownloadLink ctx.Data["task"] = task ctx.Data["ID"] = ID diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 68c94cdca..35180cedd 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -56,7 +56,7 @@ margin:10px 5px ; } .tab_2_content { - min-height: 560px; + min-height: 460px; margin-left: 10px; } .ac-grid { @@ -189,9 +189,9 @@ td, th { {{$.i18n.Tr "repo.modelarts.notebook"}}
/
- -
{{.jobName}}
- + {{with .task}} +
{{.DisplayJobName}}
+ {{end}}
{{with .task}} @@ -241,7 +241,7 @@ td, th {
- {{$.jobName}} + {{.DisplayJobName}}
@@ -297,20 +297,6 @@ td, th { - - - {{$.i18n.Tr "cloudbrain.dataset_storage_path"}} - - - -
- {{$.dataset_path}} -
- - - - -
From b6e31fcd9cd8b830a1c1d286582a758330412e51 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 14:22:47 +0800 Subject: [PATCH 076/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/modelarts.go | 15 ++++++++++++++- templates/repo/modelarts/notebook/show.tmpl | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 1f4a275d1..3f835ee5d 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -281,6 +281,7 @@ func NotebookShow(ctx *context.Context) { if task.Uuid != "" && task.UserID == ctx.User.ID { attachment, err := models.GetAttachmentByUUID(task.Uuid) if err == nil { + task.DatasetName = attachment.Name datasetDownloadLink = attachment.S3DownloadURL() } } @@ -301,7 +302,19 @@ func NotebookShow(ctx *context.Context) { } } } - + if task.TrainJobDuration == "" { + if task.Duration == 0 { + var duration int64 + if task.Status == string(models.JobRunning) { + duration = time.Now().Unix() - int64(task.CreatedUnix) + } else { + duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) + } + task.Duration = duration + } + task.TrainJobDuration = models.ConvertDurationToStr(task.Duration) + } + ctx.Data["duration"] = task.TrainJobDuration ctx.Data["datasetDownloadLink"] = datasetDownloadLink ctx.Data["task"] = task ctx.Data["ID"] = ID diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 35180cedd..f8122bead 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -328,7 +328,7 @@ td, th {
- {{.DatasetName}} + {{.DatasetName}}
@@ -360,12 +360,12 @@ td, th { - 描述 + {{$.i18n.Tr "cloudbrain.description"}}
- -- + {{.Description}}
From 3bd8962f72f9bd2736c8b1949e1dbb758f5ad1c6 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 14:30:02 +0800 Subject: [PATCH 077/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 48 +++++++++++---------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index f8122bead..93116944b 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -274,6 +274,21 @@ td, th {
+ + + + {{$.i18n.Tr "admin.auths.updated"}} + + + +
+ + {{TimeSinceUnix1 .UpdatedUnix}} + +
+ + + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} @@ -285,6 +300,15 @@ td, th {
+ + + + +
+
+ + + - -
{{$.i18n.Tr "cloudbrain.mirror"}} @@ -297,30 +321,8 @@ td, th {
-
-
- - - - - - - - - + diff --git a/templates/repo/modelarts/notebook/show--.tmpl-- b/templates/repo/modelarts/notebook/show--.tmpl-- deleted file mode 100644 index 59474ee49..000000000 --- a/templates/repo/modelarts/notebook/show--.tmpl-- +++ /dev/null @@ -1,68 +0,0 @@ -{{template "base/head" .}} -
-{{template "repo/header" .}} -
-
- {{template "base/alert" .}} - -

- -

-
-
- {{with .task}} -

任务名称: {{.DisplayJobName}}

- {{end}} -
-
-

任务详情:

- {{with .result}} -
- {{$.i18n.Tr "repo.cloudbrain.endtime"}} - -
- {{if not (eq .StartTime 0)}} - {{TimeSinceUnix1 .EndTime}} - {{else}} - -- - {{end}} -
-
{{$.i18n.Tr "repo.modelarts.train_job.dataset"}} From ec2e7a7a93a6240f681051e395483456b028a164 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 15:03:26 +0800 Subject: [PATCH 078/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/cloudbrain.go | 12 ++++ templates/repo/cloudbrain/show.tmpl | 4 +- .../repo/modelarts/notebook/show--.tmpl-- | 68 ------------------- 3 files changed, 14 insertions(+), 70 deletions(-) delete mode 100644 templates/repo/modelarts/notebook/show--.tmpl-- diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 73b1914e5..10497d720 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -417,6 +417,18 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo return } + if cloudbrain.ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) + } + for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { + if tmp.Id == task.ResourceSpecId { + ctx.Data["GpuNum"] = tmp.GpuNum + ctx.Data["CpuNum"] = tmp.CpuNum + ctx.Data["MemMiB"] = tmp.MemMiB + ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB + } + } + if result != nil { jobRes, _ := models.ConvertToJobResultPayload(result.Payload) jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 895a5c14f..fb8e04996 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -357,7 +357,7 @@ td, th {
- {{if not (eq .StartTime 0)}} + {{if not (eq .EndTime 0)}} {{TimeSinceUnix1 .EndTime}} {{else}} -- @@ -386,7 +386,7 @@ td, th {
- {{$.resource_spec}} + {{$.i18n.Tr "cloudbrain.gpu_num"}}:{{$.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{$.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.MemMiB}},{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{$.ShareMemMiB}}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
状态 {{.Status}}
描述 {{$.task.Description}}
镜像名称 {{$.task.Image}}
数据集下载地址 {{$.datasetDownloadLink}}
开始时间 {{.CreateTime}}
最后更新时间 {{.LatestUpdateTime}}
- {{end}} -
- -
- -
-
-
-{{template "base/footer" .}} From 90ea5dc8d29b470b798ce63c1eef2a72e5f90e1c Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 15:26:33 +0800 Subject: [PATCH 079/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/cloudbrain.go | 9 +++++++++ templates/repo/cloudbrain/show.tmpl | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 10497d720..cb16a6b0d 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -429,6 +429,15 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo } } + if gpuInfos == nil { + json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) + } + for _, tmp := range gpuInfos.GpuInfo { + if tmp.Queue == task.GpuQueue { + ctx.Data["gpu_type"] = tmp.Value + } + } + if result != nil { jobRes, _ := models.ConvertToJobResultPayload(result.Payload) jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index fb8e04996..76927c7f1 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -330,12 +330,12 @@ td, th { - {{$.i18n.Tr "repo.cloudbrain.platform"}} + {{$.i18n.Tr "cloudbrain.gpu_type"}}
- {{$.result.Platform}} + {{$.gpu_type}}
From 9dee6a695e80a7442e4c9848f938c381ee268122 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 15:28:02 +0800 Subject: [PATCH 080/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 93116944b..684ad99a1 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -330,7 +330,7 @@ td, th {
- {{.DatasetName}} + {{.DatasetName}}
From 58192375b3a154c44ef2a90b5f0d4b212fc203b4 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 15:52:29 +0800 Subject: [PATCH 081/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 1 - models/user_business_struct.go | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index db226b14b..65ce642d5 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -720,7 +720,6 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, useMetrics.NotActivateRegistUser = getMapKeyStringValue("NotActivateRegistUser", userMetrics) useMetrics.TotalActivateRegistUser = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) useMetrics.TotalHasActivityUser = getMapKeyStringValue("TotalHasActivityUser", userMetrics) - useMetrics.DataDate = currentTimeNow.Format("2006-01-02 15:04:05") statictisSess.Insert(&useMetrics) return nil diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 1a7625d82..17d9f046f 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -344,11 +344,10 @@ type UserAnalysisPara struct { } type UserMetrics struct { - CountDate int64 `xorm:"pk"` - ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` - TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - TotalHasActivityUser int `xorm:"NOT NULL DEFAULT 0"` - DataDate string `xorm:"NULL"` + CountDate int64 `xorm:"pk"` + ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` + TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + TotalHasActivityUser int `xorm:"NOT NULL DEFAULT 0"` } From 1a3b0ad9b67392f739c4e6460e9b9b546e3de98b Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 7 Apr 2022 15:59:49 +0800 Subject: [PATCH 082/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/cloudbrain.go | 9 --------- templates/repo/cloudbrain/show.tmpl | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 516b25576..2848b8e19 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -447,15 +447,6 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo } } - if gpuInfos == nil { - json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) - } - for _, tmp := range gpuInfos.GpuInfo { - if tmp.Queue == task.GpuQueue { - ctx.Data["gpu_type"] = tmp.Value - } - } - if result != nil { jobRes, _ := models.ConvertToJobResultPayload(result.Payload) jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 76927c7f1..781c66d67 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -335,7 +335,7 @@ td, th {
- {{$.gpu_type}} + {{$.resource_type}}
From 06f12db08d2bf59aac5c9b8937b5a77be43b7c8e Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 7 Apr 2022 17:18:57 +0800 Subject: [PATCH 083/129] fix-1647 --- routers/repo/cloudbrain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 2848b8e19..0d007a27d 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -579,7 +579,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo ctx.Data["code_path"] = cloudbrain.CodeMountPath ctx.Data["dataset_path"] = cloudbrain.DataSetMountPath ctx.Data["model_path"] = cloudbrain.ModelMountPath - ctx.Data["canDownload"] = cloudbrain.CanDeleteJob(ctx, task) + ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task) ctx.HTML(200, tpName) } From 42eb60bdbd41536138ad912dbb7ea7ca5ae18266 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 7 Apr 2022 17:53:59 +0800 Subject: [PATCH 084/129] fix-1647 --- routers/repo/modelarts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 3072ab70f..c29e55402 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1584,7 +1584,7 @@ func TrainJobShow(ctx *context.Context) { ctx.Data["displayJobName"] = VersionListTasks[0].DisplayJobName ctx.Data["version_list_task"] = VersionListTasks ctx.Data["version_list_count"] = VersionListCount - ctx.Data["canDownload"] = canNewJob + ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, &VersionListTasks[0].Cloudbrain) ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) } @@ -2215,7 +2215,7 @@ func InferenceJobShow(ctx *context.Context) { ctx.Data["jobName"] = task.JobName ctx.Data["displayJobName"] = task.DisplayJobName ctx.Data["task"] = task - ctx.Data["canDownload"] = cloudbrain.CanDeleteJob(ctx, task) + ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task) tempUids := []int64{} tempUids = append(tempUids, task.UserID) From a69443231f2a79328444156bfe1f5f28e45f3103 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 7 Apr 2022 18:01:11 +0800 Subject: [PATCH 085/129] get restart --- routers/repo/modelarts.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 3f835ee5d..f3c78d039 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -249,7 +249,7 @@ func NotebookShow(ctx *context.Context) { debugListType := ctx.Query("debugListType") var ID = ctx.Params(":id") - task, err := models.GetCloudbrainByID(ID) + task, err := models.GetCloudbrainByIDWithDeleted(ID) if err != nil { ctx.Data["error"] = err.Error() ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) @@ -264,16 +264,22 @@ func NotebookShow(ctx *context.Context) { } if result != nil { - task.Status = result.Status - err = models.UpdateJob(task) - if err != nil { - ctx.Data["error"] = err.Error() - ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) - return + if task.DeletedAt.IsZero() { //normal record + if task.Status != result.Status { + task.Status = result.Status + err = models.UpdateJob(task) + if err != nil { + ctx.Data["error"] = err.Error() + ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) + return + } + } + } else { //deleted record + } - result.CreateTime = time.Unix(int64(result.CreateAt/1000), 0).Format("2006-01-02 15:04:05") - result.LatestUpdateTime = time.Unix(int64(result.UpdateAt/1000), 0).Format("2006-01-02 15:04:05") + //result.CreateTime = time.Unix(int64(result.CreateAt/1000), 0).Format("2006-01-02 15:04:05") + //result.LatestUpdateTime = time.Unix(int64(result.UpdateAt/1000), 0).Format("2006-01-02 15:04:05") } datasetDownloadLink := "-" @@ -319,7 +325,7 @@ func NotebookShow(ctx *context.Context) { ctx.Data["task"] = task ctx.Data["ID"] = ID ctx.Data["jobName"] = task.JobName - ctx.Data["result"] = result + //ctx.Data["result"] = result ctx.Data["debugListType"] = debugListType ctx.HTML(200, tplModelArtsNotebookShow) } From 6d3e76bb9fc347697337e276b9c6b6b62eb74b34 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 09:08:58 +0800 Subject: [PATCH 086/129] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/less/openi.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 4f25e5ffd..e324f7e6c 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -935,7 +935,7 @@ display: block; color: red; } .ui.list .list>.item>img.image+.content, .ui.list>.item>img.image+.content { - width: calc(100% - 4.0em); + width: calc(100%-4em); margin-left: 0; } From 12b6d6efe09ef477e08533d302d85a023a7c31e8 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 09:35:04 +0800 Subject: [PATCH 087/129] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/user/settings/organization.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index 00b73f94d..6e5cb3872 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -23,7 +23,7 @@ - From f4df450f0435df5f8af60855b329fd6d4003f6ab Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 09:35:33 +0800 Subject: [PATCH 088/129] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/less/openi.less | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web_src/less/openi.less b/web_src/less/openi.less index e324f7e6c..af27172c2 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -934,8 +934,13 @@ display: block; .highlight{ color: red; } + + .ui.list .list>.item>img.image+.contentnew, .ui.list>.item>img.image+.contentnew { + margin-left: 0; + } + .ui.list .list>.item>img.image+.content, .ui.list>.item>img.image+.content { - width: calc(100%-4em); + width: calc(100%-4.0em); margin-left: 0; } From fe86b78aad6f0502e189afe1e45df111c16d1d14 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 09:46:25 +0800 Subject: [PATCH 089/129] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/less/openi.less | 1 + 1 file changed, 1 insertion(+) diff --git a/web_src/less/openi.less b/web_src/less/openi.less index af27172c2..bdadf559f 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -936,6 +936,7 @@ display: block; } .ui.list .list>.item>img.image+.contentnew, .ui.list>.item>img.image+.contentnew { + width: calc(100%-10em); margin-left: 0; } From 4b30c1bc56ff3f2d2dd96029eb3c982804696595 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 09:56:50 +0800 Subject: [PATCH 090/129] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/user/settings/organization.tmpl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index 6e5cb3872..ae92218b0 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -16,16 +16,17 @@
{{range .Orgs}}
+ + +
+ {{.Name}} +
{{$.CsrfTokenHtml}}
- -
- {{.Name}} -
{{end}}
From 91d1458a06ad60db347ac3c961373a5202f4dd63 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 10:15:01 +0800 Subject: [PATCH 091/129] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/user/settings/organization.tmpl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index ae92218b0..6e5cb3872 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -16,17 +16,16 @@
{{range .Orgs}}
- - -
- {{.Name}} -
{{$.CsrfTokenHtml}}
+ +
+ {{.Name}} +
{{end}}
From 914cef287d089552205ebc4b37b27cffd4aeed3b Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Fri, 8 Apr 2022 10:33:41 +0800 Subject: [PATCH 092/129] mod restart time --- templates/repo/modelarts/notebook/show.tmpl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 684ad99a1..70a68fed4 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -282,8 +282,11 @@ td, th {
- - {{TimeSinceUnix1 .UpdatedUnix}} + {{if not (eq .EndTime 0)}} + {{TimeSinceUnix1 .EndTime}} + {{else}} + {{TimeSinceUnix1 .UpdatedUnix}} + {{end}}
From 9731860d9ca1729e0b6189d11454048e0243b965 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 8 Apr 2022 10:58:46 +0800 Subject: [PATCH 093/129] #1639 add file total size limit --- modules/setting/repository.go | 3 +++ routers/repo/editor.go | 2 +- routers/repo/http.go | 2 +- services/repository/repository.go | 31 ++++++++++++++++++++++++++++++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/modules/setting/repository.go b/modules/setting/repository.go index a9786ca18..54ed13c2f 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -55,6 +55,7 @@ var ( AllowedTypes []string `delim:"|"` FileMaxSize int64 MaxFiles int + TotalMaxSize int64 } `ini:"-"` // Repository local settings @@ -122,12 +123,14 @@ var ( AllowedTypes []string `delim:"|"` FileMaxSize int64 MaxFiles int + TotalMaxSize int64 }{ Enabled: true, TempPath: "data/tmp/uploads", AllowedTypes: []string{}, FileMaxSize: 3, MaxFiles: 5, + TotalMaxSize: 100, }, // Repository local settings diff --git a/routers/repo/editor.go b/routers/repo/editor.go index b089a784c..8e13735df 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -615,7 +615,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) { message += "\n\n" + form.CommitMessage } - if err := repo_service.CheckRepoSizeLimit(ctx.Repo.Repository, form.Files); err != nil { + if err := repo_service.CheckPushSizeLimit4Web(ctx.Repo.Repository, form.Files); err != nil { if repo_service.IsRepoTooLargeErr(err) { ctx.RenderWithErr(ctx.Tr("repo.editor.repo_too_large", setting.Repository.RepoMaxSize), tplUploadFile, &form) } else if repo_service.IsUploadFileInvalidErr(err) { diff --git a/routers/repo/http.go b/routers/repo/http.go index e3ab329ba..26d58bd54 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -549,7 +549,7 @@ func serviceRPC(h serviceHandler, service string) { content, _ := ioutil.ReadAll(reqBody) //check size if service == "receive-pack" { - if err := repo_service.CheckRepoTotalSizeLimit(h.repo, int64(len(content))); err != nil { + if err := repo_service.CheckPushSizeLimit4Http(h.repo, int64(len(content))); err != nil { h.w.WriteHeader(http.StatusOK) str := GenerateGitErrorBody(err.Error()) h.w.Write([]byte(str)) diff --git a/services/repository/repository.go b/services/repository/repository.go index fc4411056..d0cd52653 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -174,7 +174,7 @@ func RecommendFromPromote(url string) ([]string, error) { return result, nil } -func CheckRepoSizeLimit(repo *models.Repository, fileIds []string) error { +func CheckPushSizeLimit4Web(repo *models.Repository, fileIds []string) error { if err := CheckRepoNumOnceLimit(len(fileIds)); err != nil { return err } @@ -188,6 +188,16 @@ func CheckRepoSizeLimit(repo *models.Repository, fileIds []string) error { return nil } +func CheckPushSizeLimit4Http(repo *models.Repository, uploadFileSize int64) error { + if err := CheckRepoOnceTotalSizeLimit(uploadFileSize); err != nil { + return err + } + if err := CheckRepoTotalSizeLimit(repo, uploadFileSize); err != nil { + return err + } + return nil +} + func CheckRepoTotalSizeLimit(repo *models.Repository, uploadFileSize int64) error { if repo.Size+uploadFileSize > setting.Repository.RepoMaxSize*1024*1024 { return RepoTooLargeErr{} @@ -195,6 +205,13 @@ func CheckRepoTotalSizeLimit(repo *models.Repository, uploadFileSize int64) erro return nil } +func CheckRepoOnceTotalSizeLimit(uploadFileSize int64) error { + if uploadFileSize > setting.Repository.Upload.TotalMaxSize*1024*1024 { + return UploadFileTooLargeErr{} + } + return nil +} + func CheckRepoNumOnceLimit(uploadFileNum int) error { if uploadFileNum > setting.Repository.Upload.MaxFiles { return UploadFileTooMuchErr{} @@ -243,6 +260,18 @@ func IsRepoTooLargeErr(err error) bool { return ok } +type UploadFileTooLargeErr struct { +} + +func (UploadFileTooLargeErr) Error() string { + return fmt.Sprintf("Upload files can not exceed %d MB at a time", setting.Repository.Upload.TotalMaxSize) +} + +func IsUploadFileTooLargeErr(err error) bool { + _, ok := err.(UploadFileTooLargeErr) + return ok +} + type RepoFileTooLargeErr struct { } From bb44f675c021443fbec70f3e5b4f7f388cf8d27c Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Fri, 8 Apr 2022 14:29:52 +0800 Subject: [PATCH 094/129] del unuse code --- routers/repo/modelarts.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 0b3405bcb..933571a0b 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -277,9 +277,6 @@ func NotebookShow(ctx *context.Context) { } else { //deleted record } - - //result.CreateTime = time.Unix(int64(result.CreateAt/1000), 0).Format("2006-01-02 15:04:05") - //result.LatestUpdateTime = time.Unix(int64(result.UpdateAt/1000), 0).Format("2006-01-02 15:04:05") } datasetDownloadLink := "-" @@ -325,7 +322,6 @@ func NotebookShow(ctx *context.Context) { ctx.Data["task"] = task ctx.Data["ID"] = ID ctx.Data["jobName"] = task.JobName - //ctx.Data["result"] = result ctx.Data["debugListType"] = debugListType ctx.HTML(200, tplModelArtsNotebookShow) } From b7b56ec19636a594d25f51febf238e901e4647db Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 15:25:53 +0800 Subject: [PATCH 095/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/repo/cloudbrain/show.tmpl | 18 ++++++++++++++++-- templates/user/settings/organization.tmpl | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 58168d1e2..a4858dbb7 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -919,6 +919,7 @@ cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, cloudbrain.exitinfo=Exit Information cloudbrain.platform=Platform cloudbrain.endtime=End Time +cloudbrain.runinfo=Task Runtime Information model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 28041428f..bec5000e1 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -966,6 +966,7 @@ cloudbrain.mirror_description = 镜像描述 cloudbrain.exitinfo=退出信息 cloudbrain.platform=平台 cloudbrain.endtime=结束时间 +cloudbrain.runinfo=任务运行简况 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 total_count_get_error=查询总页数失败。 diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 781c66d67..6fbff5956 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -198,7 +198,7 @@ td, th {
- +
@@ -226,6 +226,7 @@ td, th {
@@ -432,7 +433,20 @@ td, th {
- +
+
+ +
+ + {{$.result.JobStatus.AppExitDiagnostics}} + +
+ +
+ +
diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index 6e5cb3872..00b73f94d 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -23,7 +23,7 @@
- From 7c9764bd7c03019cfc797b112d2b697de62c29f9 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:32:21 +0800 Subject: [PATCH 096/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 58 ++++++++++++++++------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 6fbff5956..c22012d3b 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -226,7 +226,7 @@ td, th {
@@ -418,17 +418,6 @@ td, th {
-
-
- {{$.i18n.Tr "repo.cloudbrain.exitinfo"}} - -
-
-
- - {{$.result.JobStatus.AppExitDiagnostics}} - -
@@ -439,8 +428,9 @@ td, th {
- - {{$.result.JobStatus.AppExitDiagnostics}} + + +
@@ -499,17 +489,35 @@ td, th { jobName = urlArr.slice(-1)[0] }) - function loadLog(version_name){ - document.getElementById("mask").style.display = "block" - $.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobName}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { - $('input[name=end_line]').val(data.EndLine) - $('input[name=start_line]').val(data.StartLine) - $(`#log_file${version_name}`).text(data.Content) - document.getElementById("mask").style.display = "none" - }).fail(function(err) { - console.log(err); - document.getElementById("mask").style.display = "none" - }); + function parseLog(){ + let jsonValue = document.getElementById("json_value").value; + let jsonObj = JSON.parse(jsonValue); + let podRoleName = jsonObj["podRoleName"]; + let html = ""; + if (podRoleName != null){ + let task0 = podRoleName["task1-0"]; + let podEvents = jsonObj["podEvents"]; + let podEventArray = podEvents[task0]; + if(podEventArray != null){ + for(int i=0; i < podEventArray.length;i++){ + html +="

" +podEventArray[i]["reason"] + "

"; + html +="

" +podEventArray[i]["message"] + "

"; + html +="

" +podEventArray[i]["action"] + "

"; + } + } + let extras= jsonObj["extras"]; + if(extras != null){ + html +="

" +extras["reason"] + "

"; + html +="

" +extras["message"] + "

"; + html +="

" +extras["action"] + "

"; + } + + document.getElementById("info_display").innerHTML=html; + } + + + } + From d08854f28470c5c9c52c38e08a34d269c8099863 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:33:33 +0800 Subject: [PATCH 097/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index c22012d3b..3e2cc06be 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -226,7 +226,7 @@ td, th {
From 83652d406747c3ee8029c1c725e3ecf82acebe50 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:39:35 +0800 Subject: [PATCH 098/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 83 ++++++++++------------------- 1 file changed, 29 insertions(+), 54 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 3e2cc06be..3040fce8d 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -167,6 +167,34 @@ td, th { padding-top: 0.5rem ; } + +
@@ -226,7 +254,7 @@ td, th {
@@ -468,56 +496,3 @@ td, th {
{{template "base/footer" .}} - From 4c307c9d8b124c13daba0dda412967f68009eaf9 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:41:55 +0800 Subject: [PATCH 099/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/search.js | 26 ++++++++++++++++ templates/repo/cloudbrain/show.tmpl | 48 ++++++++++++++--------------- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/public/home/search.js b/public/home/search.js index e23d27549..8a8e940cb 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -129,6 +129,32 @@ function search(){ } } +function parseLog(){ + let jsonValue = document.getElementById("json_value").value; + let jsonObj = JSON.parse(jsonValue); + let podRoleName = jsonObj["podRoleName"]; + let html = ""; + if (podRoleName != null){ + let task0 = podRoleName["task1-0"]; + let podEvents = jsonObj["podEvents"]; + let podEventArray = podEvents[task0]; + if(podEventArray != null){ + for(int i=0; i < podEventArray.length;i++){ + html +="

" +podEventArray[i]["reason"] + "

"; + html +="

" +podEventArray[i]["message"] + "

"; + html +="

" +podEventArray[i]["action"] + "

"; + } + } + let extras= jsonObj["extras"]; + if(extras != null){ + html +="

" +extras["reason"] + "

"; + html +="

" +extras["message"] + "

"; + html +="

" +extras["action"] + "

"; + } + document.getElementById("info_display").innerHTML=html; + } + } + function emptySearch(){ initDiv(false); initPageInfo(); diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 3040fce8d..2a164e8de 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -168,31 +168,31 @@ td, th { }
From 6f06a8484204016406143c899c04eaa81ccc8ae6 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:48:36 +0800 Subject: [PATCH 100/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 63 ++++++++++++++++------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 2a164e8de..ed17e6ec2 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -167,33 +167,7 @@ td, th { padding-top: 0.5rem ; } - +
@@ -496,3 +470,38 @@ td, th {
{{template "base/footer" .}} + \ No newline at end of file From f29ed8688115a1c5d235c5b560fd7083abd6751e Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:52:10 +0800 Subject: [PATCH 101/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index ed17e6ec2..204362ddb 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -56,7 +56,7 @@ margin:10px 5px ; } .tab_2_content { - min-height: 560px; + min-height: 460px; margin-left: 10px; } .ac-grid { @@ -497,9 +497,11 @@ td, th { } let extras= jsonObj["extras"]; if(extras != null){ - html +="

" +extras["reason"] + "

"; - html +="

" +extras["message"] + "

"; - html +="

" +extras["action"] + "

"; + for(var i=0; i < extras.length;i++){ + html +="

" +extras[i]["reason"] + "

"; + html +="

" +extras[i]["message"] + "

"; + html +="

" +extras[i]["action"] + "

"; + } } } document.getElementById("info_display").innerHTML=html; From 8573b98eda977929fa2b00293cee61116a17333e Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 16:56:45 +0800 Subject: [PATCH 102/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 204362ddb..986e1c0cc 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -56,7 +56,7 @@ margin:10px 5px ; } .tab_2_content { - min-height: 460px; + min-height: 360px; margin-left: 10px; } .ac-grid { From 5836f132090c6add7acd8905950e91f1929cba16 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 17:20:06 +0800 Subject: [PATCH 103/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 161 +++++++++++++++------------- 1 file changed, 89 insertions(+), 72 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 986e1c0cc..94e3dd4a5 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -258,20 +258,58 @@ td, th {
+ + + {{$.i18n.Tr "repo.cloudbrain_creator"}} + + + +
+ {{.User.Name}} +
+ + + + + 计算资源 + + +
+ CPU/GPU +
+ + + + + 任务类型 + + +
+ DEBUG +
+ + + + + {{$.i18n.Tr "cloudbrain.gpu_type"}} + + + +
+ {{$.resource_type}} +
+ + - {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + 创建时间
- {{if not (eq .StartTime 0)}} - {{TimeSinceUnix1 .StartTime}} - {{else}} {{TimeSinceUnix1 .CreatedUnix}} - {{end}}
@@ -287,132 +325,111 @@ td, th {
- - - {{$.i18n.Tr "cloudbrain.mirror"}} - - - -
- {{.Image}} -
- - - - - - {{$.i18n.Tr "cloudbrain.dataset_storage_path"}} - - - -
- {{$.dataset_path}} -
- - - - - - {{$.i18n.Tr "cloudbrain.code_storage_path"}} - + - -
- {{$.code_path}} -
- - - +
+ + - + + + - - - - + - + + @@ -490,7 +507,7 @@ td, th { let podEventArray = podEvents[task0]; if(podEventArray != null){ for(var i=0; i < podEventArray.length;i++){ - html +="

" +podEventArray[i]["reason"] + "

"; + html +="

[" +podEventArray[i]["reason"] + "]

"; html +="

" +podEventArray[i]["message"] + "

"; html +="

" +podEventArray[i]["action"] + "

"; } @@ -498,7 +515,7 @@ td, th { let extras= jsonObj["extras"]; if(extras != null){ for(var i=0; i < extras.length;i++){ - html +="

" +extras[i]["reason"] + "

"; + html +="

[" +extras[i]["reason"] + "]

"; html +="

" +extras[i]["message"] + "

"; html +="

" +extras[i]["action"] + "

"; } From 1e1537cadf201fa457c77dc8329cb7f97694b128 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 8 Apr 2022 17:34:29 +0800 Subject: [PATCH 104/129] fix issue --- templates/explore/datasets.tmpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index ff18a3da3..b8b805865 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -216,3 +216,6 @@ {{template "base/footer" .}} + \ No newline at end of file From b045af3db98e666581f2fd09cb22a9bdb7568a56 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 8 Apr 2022 17:41:14 +0800 Subject: [PATCH 105/129] fix issue --- templates/explore/datasets.tmpl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index b8b805865..8211e8f20 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -184,9 +184,15 @@
+ {{if eq .UserID 0}} + {{else}} + + + + {{end}} 创建于:{{TimeSinceUnix1 .CreatedUnix}}
@@ -215,7 +221,4 @@ -{{template "base/footer" .}} - \ No newline at end of file +{{template "base/footer" .}} \ No newline at end of file From 1f46cbc181628daf718e867c31c3d50887298fc7 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 8 Apr 2022 17:47:35 +0800 Subject: [PATCH 106/129] fix issue --- templates/explore/datasets.tmpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index 8211e8f20..a1692cf35 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -121,10 +121,10 @@ From e052756d25cb792b2f2a36a7f262af21ec7d06db Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 17:50:13 +0800 Subject: [PATCH 107/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_zh-CN.ini | 2 + templates/repo/cloudbrain/show.tmpl | 86 +++++++++++++---------------- 2 files changed, 39 insertions(+), 49 deletions(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index bec5000e1..1d1d9ab0f 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -967,6 +967,8 @@ cloudbrain.exitinfo=退出信息 cloudbrain.platform=平台 cloudbrain.endtime=结束时间 cloudbrain.runinfo=任务运行简况 +cloudbrain.time.starttime=开始运行时间 +cloudbrain.time.endtime=结束运行时间 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 total_count_get_error=查询总页数失败。 diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 94e3dd4a5..34104f3c7 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -271,7 +271,7 @@ td, th {
+ + - - - - - - - + + + + + - - + + + @@ -401,38 +408,19 @@ td, th { - - - - - - - + +
+ {{$.i18n.Tr "cloudbrain.mirror"}} + +
+ {{.Image}} +
+
- {{$.i18n.Tr "cloudbrain.gpu_type"}} + {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} -
- {{$.resource_type}} +
+ {{$.datasetname}}
- ExitCode + {{$.i18n.Tr "repo.modelarts.train_job.standard"}}
- {{$.result.JobStatus.AppExitCode}} + {{$.i18n.Tr "cloudbrain.gpu_num"}}:{{$.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{$.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.MemMiB}},{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{$.ShareMemMiB}}
- {{$.i18n.Tr "repo.cloudbrain.endtime"}} + {{$.i18n.Tr "cloudbrain.dataset_storage_path"}} -
- {{if not (eq .EndTime 0)}} - {{TimeSinceUnix1 .EndTime}} - {{else}} - -- - {{end}} +
+ {{$.dataset_path}}
- {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} + {{$.i18n.Tr "cloudbrain.model_storage_path"}} -
- {{$.datasetname}} +
+ {{$.model_path}}
- {{$.i18n.Tr "repo.modelarts.train_job.standard"}} + {{$.i18n.Tr "cloudbrain.code_storage_path"}} -
- {{$.i18n.Tr "cloudbrain.gpu_num"}}:{{$.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{$.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.MemMiB}},{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{$.ShareMemMiB}} +
+ {{$.code_path}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + 开始运行时间 -
- {{.User.Name}} +
+ {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .StartTime}} + {{else}} + -- + {{end}}
- {{$.i18n.Tr "cloudbrain.model_storage_path"}} + 结束运行时间 -
- {{$.model_path}} +
+ {{if not (eq .EndTime 0)}} + {{TimeSinceUnix1 .EndTime}} + {{else}} + -- + {{end}}
- 计算资源 + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
@@ -281,7 +281,7 @@ td, th {
- 任务类型 + {{$.i18n.Tr "cloudbrain.task_type"}}
@@ -300,32 +300,39 @@ td, th {
+ {{$.i18n.Tr "repo.cloudbrain.time.starttime"}} +
- 创建时间 - -
- - {{TimeSinceUnix1 .CreatedUnix}} - -
-
- {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} - +
+ {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .StartTime}} + {{else}} + -- + {{end}} +
+
+ {{$.i18n.Tr "repo.cloudbrain.time.endtime"}} + -
- {{$.duration}} -
-
+
+ {{if not (eq .EndTime 0)}} + {{TimeSinceUnix1 .EndTime}} + {{else}} + -- + {{end}} +
+
- 开始运行时间 - -
- {{if not (eq .StartTime 0)}} - {{TimeSinceUnix1 .StartTime}} - {{else}} - -- - {{end}} -
-
- 结束运行时间 + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} -
- {{if not (eq .EndTime 0)}} - {{TimeSinceUnix1 .EndTime}} - {{else}} - -- - {{end}} +
+ {{$.duration}}
From 9e355ac65b8cecb657a280c27093ed481337c431 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 8 Apr 2022 17:51:41 +0800 Subject: [PATCH 108/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a4858dbb7..049454ddc 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -920,6 +920,8 @@ cloudbrain.exitinfo=Exit Information cloudbrain.platform=Platform cloudbrain.endtime=End Time cloudbrain.runinfo=Task Runtime Information +cloudbrain.time.starttime=Start run time +cloudbrain.time.endtime=End run time model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. From d8de9704fbd925012633a85ea79c8f8489bde8f6 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 11 Apr 2022 10:06:19 +0800 Subject: [PATCH 109/129] fix issue --- templates/custom/select_dataset.tmpl | 2 +- templates/custom/select_dataset_train.tmpl | 134 ++++++++++++++++++ templates/repo/cloudbrain/trainjob/new.tmpl | 16 +-- .../repo/modelarts/inferencejob/new.tmpl | 20 +-- templates/repo/modelarts/trainjob/new.tmpl | 21 +-- 5 files changed, 147 insertions(+), 46 deletions(-) create mode 100644 templates/custom/select_dataset_train.tmpl diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl index dc5ca6c9e..273477dd2 100644 --- a/templates/custom/select_dataset.tmpl +++ b/templates/custom/select_dataset.tmpl @@ -135,4 +135,4 @@ -
\ No newline at end of file +
diff --git a/templates/custom/select_dataset_train.tmpl b/templates/custom/select_dataset_train.tmpl new file mode 100644 index 000000000..2771200b6 --- /dev/null +++ b/templates/custom/select_dataset_train.tmpl @@ -0,0 +1,134 @@ + + +
+     + + + {{.i18n.Tr "dataset.select_dataset"}} + +
+ + +
+ + + +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ + +
+ +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ +
+ +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ +
+ +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ +
+
+
+ + +
+
+ + +
diff --git a/templates/repo/cloudbrain/trainjob/new.tmpl b/templates/repo/cloudbrain/trainjob/new.tmpl index e33920b20..e7254e410 100755 --- a/templates/repo/cloudbrain/trainjob/new.tmpl +++ b/templates/repo/cloudbrain/trainjob/new.tmpl @@ -169,9 +169,9 @@
{{if .bootFile}} - + {{else}} - + {{end}} @@ -179,17 +179,9 @@ 查看样例
-
- - - 训练脚本存储在/code中,数据集存储在/dataset中,训练输出请存储在/model中以供后续下载。 -
+ {{template "custom/select_dataset_train" .}} + 训练脚本存储在/code中,数据集存储在/dataset中,训练输出请存储在/model中以供后续下载。
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 5e7347abf..6c8681432 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -169,24 +169,10 @@
-
-      - - - - -
- + {{template "custom/select_dataset_train" .}} + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
-   + {{if .bootFile}} {{else}} diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 963250bcb..3629de442 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -158,29 +158,18 @@
{{if .bootFile}} - + {{else}} - + {{end}} {{.i18n.Tr "cloudbrain.view_sample"}}
-
- - - {{.i18n.Tr "cloudbrain.dataset_path_rule"}} -
- + + {{template "custom/select_dataset_train" .}} + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} From 2a65969622e2ec00b3b8b34e8079688016a45e7c Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Apr 2022 10:11:48 +0800 Subject: [PATCH 110/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 7 +-- templates/repo/modelarts/notebook/show.tmpl | 68 ++++++++++++--------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 34104f3c7..f0de9c791 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -275,7 +275,7 @@ td, th {
- CPU/GPU + {{.ComputeResource}}
@@ -285,7 +285,7 @@ td, th {
- DEBUG + {{.JobType}}
@@ -331,10 +331,7 @@ td, th {
- - -
diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 684ad99a1..3fdea7d07 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -256,38 +256,28 @@ td, th {
- - - {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} - + + {{$.i18n.Tr "repo.cloudbrain_creator"}} + - -
- - {{if not (eq .StartTime 0)}} - {{TimeSinceUnix1 .StartTime}} - {{else}} - {{TimeSinceUnix1 .CreatedUnix}} - {{end}} - -
- + +
+ {{.User.Name}} +
+ - - {{$.i18n.Tr "admin.auths.updated"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}} - -
- - {{TimeSinceUnix1 .UpdatedUnix}} - +
+ {{.ComputeResource}}
- + + @@ -348,25 +338,47 @@ td, th {
+ + + {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + - + +
+
+ {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .StartTime}} + {{else}} + -- + {{end}} +
+
+ + + + - {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain.time.endtime"}} -
- {{.User.Name}} +
+ {{if not (eq .EndTime 0)}} + {{TimeSinceUnix1 .EndTime}} + {{else}} + -- + {{end}}
+ {{$.i18n.Tr "cloudbrain.description"}} -
+
{{.Description}}
From 4a6dbb748be503f8709574bb904c642e3c84c4a4 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Apr 2022 10:19:43 +0800 Subject: [PATCH 111/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/cloudbrain/show.tmpl | 4 ++-- templates/repo/modelarts/notebook/show.tmpl | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index f0de9c791..440843bfc 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -306,7 +306,7 @@ td, th { -
+
{{if not (eq .StartTime 0)}} {{TimeSinceUnix1 .StartTime}} {{else}} @@ -322,7 +322,7 @@ td, th { -
+
{{if not (eq .EndTime 0)}} {{TimeSinceUnix1 .EndTime}} {{else}} diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 3fdea7d07..b9408a867 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -290,7 +290,17 @@ td, th {
- + + + 数据集下载地址 + + + +
+ {{$.datasetDownloadLink}} +
+ + From faa8253f04bdf1b15343af2f31801567ef7a04b2 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Apr 2022 10:39:07 +0800 Subject: [PATCH 112/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 36 +++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index b9408a867..9f99b3c64 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -101,6 +101,10 @@ line-height: 30px; padding-bottom: 20px; } +.ti-text-form-contentline60{ + line-height: 60px; + padding-bottom: 20px; +} .ti-form>tbody>tr>td { vertical-align: top; white-space: normal; @@ -114,6 +118,11 @@ td, th { text-overflow: ellipsis; white-space: nowrap; } +.text-span-new { + width: 450px; + overflow: hidden; + text-overflow: ellipsis; +} .redo-color{ color: #3291F8; } @@ -290,13 +299,24 @@ td, th {
- + - 数据集下载地址 + {{$.i18n.Tr "cloudbrain.description"}}
+ {{.Description}} +
+ + + + + 数据集下载地址 + + + +
{{$.datasetDownloadLink}}
@@ -382,17 +402,7 @@ td, th { - - - {{$.i18n.Tr "cloudbrain.description"}} - - - -
- {{.Description}} -
- - +
From 120c60b2728e6b6e5ef6d51ca7450c394b15ffaf Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Apr 2022 10:54:19 +0800 Subject: [PATCH 113/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 9f99b3c64..4c77a66da 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -119,9 +119,11 @@ td, th { white-space: nowrap; } .text-span-new { - width: 450px; + width: 800px; overflow: hidden; text-overflow: ellipsis; + height: 120px; + word-break: break-all; } .redo-color{ color: #3291F8; From 5b4a6d1b25a227d8e9ae8b5572cb15477ef3063f Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Apr 2022 11:02:09 +0800 Subject: [PATCH 114/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/repo/modelarts/notebook/show.tmpl | 11 ++++------- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 049454ddc..661911883 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -922,6 +922,7 @@ cloudbrain.endtime=End Time cloudbrain.runinfo=Task Runtime Information cloudbrain.time.starttime=Start run time cloudbrain.time.endtime=End run time +cloudbrain.datasetdownload=Dataset download url model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 1d1d9ab0f..c30fbdf8c 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -969,6 +969,7 @@ cloudbrain.endtime=结束时间 cloudbrain.runinfo=任务运行简况 cloudbrain.time.starttime=开始运行时间 cloudbrain.time.endtime=结束运行时间 +cloudbrain.datasetdownload=数据集下载地址 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 total_count_get_error=查询总页数失败。 diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 4c77a66da..fbf60caa3 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -101,10 +101,7 @@ line-height: 30px; padding-bottom: 20px; } -.ti-text-form-contentline60{ - line-height: 60px; - padding-bottom: 20px; -} + .ti-form>tbody>tr>td { vertical-align: top; white-space: normal; @@ -307,17 +304,17 @@ td, th { -
+
{{.Description}}
- 数据集下载地址 + {{$.i18n.Tr "repo.cloudbrain.datasetdownload"}} - +
{{$.datasetDownloadLink}}
From b2357f2d2e477474d11d0f7d00d033e5efc9bdfc Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 11 Apr 2022 11:04:04 +0800 Subject: [PATCH 115/129] fix issue --- options/locale/locale_en-US.ini | 2 ++ options/locale/locale_zh-CN.ini | 2 ++ templates/repo/editor/upload.tmpl | 4 ++-- web_src/js/index.js | 22 ++++++++++++++++++---- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f9bebbb86..781d5634f 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2836,6 +2836,8 @@ uploading = Uploading upload_complete = Uploading complete failed = Upload Failed enable_minio_support = Enable minio support to use the dataset service +max_file_tooltips= Upload a maximum of ? files at a time, each file does not exceed ? MB. +max_size-tooltips= You can only upload a maximum of ? files at a time. The upload limit has been reached, please do not add more files. [notification] notifications = Notifications diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 8679554c6..5a047ce9e 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2842,6 +2842,8 @@ uploading=正在上传 upload_complete=上传完成 failed=上传失败 enable_minio_support=启用minio支持以使用数据集服务 +max_file_tooltips=单次最多上传?个文件,每个文件不超过? MB。 +max_size-tooltips=一次最多只能上传?个文件, 上传已达到上限,请勿再添加文件。 [notification] notifications=通知 diff --git a/templates/repo/editor/upload.tmpl b/templates/repo/editor/upload.tmpl index 08727600c..7eae567c2 100644 --- a/templates/repo/editor/upload.tmpl +++ b/templates/repo/editor/upload.tmpl @@ -27,10 +27,10 @@
-
+
{{template "repo/editor/commit_form" .}}
-{{template "base/footer" .}} +{{template "base/footer" .}} \ No newline at end of file diff --git a/web_src/js/index.js b/web_src/js/index.js index a04b76936..3127e2110 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2751,9 +2751,23 @@ $(document).ready(async () => { $('td[data-href]').click(function () { window.location = $(this).data('href'); }); + // 在String原型对象上添加format方法 + String.prototype.format = function(){ + let str = this; + if(arguments.length == 0){ + return str; + }else{ + Object.keys(arguments).forEach((item,index)=>{ + str = str.replace(/\?/,arguments[item]) + }) + return str + } + } // Dropzone const $dropzone = $('#dropzone'); + let maxFileTooltips=$dropzone.data('max-file-tooltips').format($dropzone.data('max-file'),$dropzone.data('max-size')) + let maxSizeTooltips=$dropzone.data('max-size-tooltips').format($dropzone.data('max-file')) if ($dropzone.length > 0) { const filenameDict = {}; @@ -2769,7 +2783,6 @@ $(document).ready(async () => { dictInvalidFileType: $dropzone.data('invalid-input-type'), dictFileTooBig: $dropzone.data('file-too-big'), dictRemoveFile: $dropzone.data('remove-file'), - dictMaxFilesExceeded:'上次超过限制', init() { this.on('success', (file, data) => { filenameDict[file.name] = data.uuid; @@ -2790,17 +2803,18 @@ $(document).ready(async () => { } }); this.on('addedfile',(file)=>{ - console.log("addfile",file,filenameDict,this.files.length) if(file.size/(1000*1000)>3){ this.removeFile(file) - $('.maxfilesize.ui.red.message').text('单次最多上传XX个文件,每个文件不超过XXM。') + $('.maxfilesize.ui.red.message').text(maxFileTooltips) $('.maxfilesize.ui.red.message').css('display','block') + }else{ + $('.maxfilesize.ui.red.message').css('display','none') } }); this.on('maxfilesexceeded',(file)=>{ this.removeFile(file) - $('.maxfilesize.ui.red.message').text('一次最多只能上传 5 个文件, 上传已达到上限,请勿再添加文件。') + $('.maxfilesize.ui.red.message').text(maxSizeTooltips) $('.maxfilesize.ui.red.message').css('display','block') }) From 929ed1b28ec66aab677431ca0a5f6f8ecd36c248 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Apr 2022 11:09:27 +0800 Subject: [PATCH 116/129] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/modelarts/notebook/show.tmpl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index fbf60caa3..93c7068d3 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -298,29 +298,29 @@ td, th {
- + - {{$.i18n.Tr "cloudbrain.description"}} + {{$.i18n.Tr "repo.cloudbrain.datasetdownload"}}
- {{.Description}} + {{$.datasetDownloadLink}}
- + - {{$.i18n.Tr "repo.cloudbrain.datasetdownload"}} + {{$.i18n.Tr "cloudbrain.description"}}
- {{$.datasetDownloadLink}} + {{.Description}}
- - + +
From aff84ba79e0736e263f110ae726a906dd8ed052e Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 11 Apr 2022 12:10:59 +0800 Subject: [PATCH 117/129] #1639 rollback --- routers/repo/http.go | 54 +++----------------------------------------- 1 file changed, 3 insertions(+), 51 deletions(-) diff --git a/routers/repo/http.go b/routers/repo/http.go index 26d58bd54..87406a2c3 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -365,7 +365,8 @@ func HTTP(ctx *context.Context) { ctx.NotFound("Smart Git HTTP", err) return } - route.handler(serviceHandler{cfg, w, r, dir, file, cfg.Env, repo}) + + route.handler(serviceHandler{cfg, w, r, dir, file, cfg.Env}) return } } @@ -428,7 +429,6 @@ type serviceHandler struct { dir string file string environ []string - repo *models.Repository } func (h *serviceHandler) setHeaderNoCache() { @@ -546,19 +546,6 @@ func serviceRPC(h serviceHandler, service string) { return } } - content, _ := ioutil.ReadAll(reqBody) - //check size - if service == "receive-pack" { - if err := repo_service.CheckPushSizeLimit4Http(h.repo, int64(len(content))); err != nil { - h.w.WriteHeader(http.StatusOK) - str := GenerateGitErrorBody(err.Error()) - h.w.Write([]byte(str)) - if h.w.Header().Get("Content-Type") == "" { - h.w.Header().Set("Content-Type", "application/x-git-receive-pack-result") - } - return - } - } // set this for allow pre-receive and post-receive execute h.environ = append(h.environ, "SSH_ORIGINAL_COMMAND="+service) @@ -573,7 +560,7 @@ func serviceRPC(h serviceHandler, service string) { } cmd.Stdout = h.w - cmd.Stdin = bytes.NewReader(content) + cmd.Stdin = reqBody cmd.Stderr = &stderr pid := process.GetManager().Add(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir), cancel) @@ -585,41 +572,6 @@ func serviceRPC(h serviceHandler, service string) { } } -func GenerateGitErrorBody(content string) string { - var builder strings.Builder - builder.WriteString(GenerateErrStartPKTLine()) - builder.WriteString(GeneratePKTLine(content)) - builder.WriteString(GenerateEndPKTLine()) - return builder.String() -} - -func GeneratePKTLine(content string) string { - //\033[31m ... \033[0m - //mark the text red in shell - content = "\u0002\033[31m " + content + " \033[0m" - l := len(content) - prefixLength := 4 - suffix := "\n" - f := strconv.FormatInt(int64(l+prefixLength+len(suffix)), 16) - lf := len(f) - if lf == 1 { - f = "000" + f - } else if lf == 2 { - f = "00" + f - } else if lf == 3 { - f = "0" + f - } - return f + content + suffix -} - -func GenerateEndPKTLine() string { - return "0000" -} - -func GenerateErrStartPKTLine() string { - return "0031\u0001000eunpack err\n0019ok refs/heads/master\n0000" -} - func serviceUploadPack(h serviceHandler) { serviceRPC(h, "upload-pack") } From 8679849c3d582854214994f03b4a33d6597981ab Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 11 Apr 2022 14:36:00 +0800 Subject: [PATCH 118/129] fix issue --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 2 +- web_src/js/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 781d5634f..976387dd9 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2837,7 +2837,7 @@ upload_complete = Uploading complete failed = Upload Failed enable_minio_support = Enable minio support to use the dataset service max_file_tooltips= Upload a maximum of ? files at a time, each file does not exceed ? MB. -max_size-tooltips= You can only upload a maximum of ? files at a time. The upload limit has been reached, please do not add more files. +max_size_tooltips= You can only upload a maximum of ? files at a time. The upload limit has been reached, please do not add more files. [notification] notifications = Notifications diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 5a047ce9e..6e4b2dc59 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2843,7 +2843,7 @@ upload_complete=上传完成 failed=上传失败 enable_minio_support=启用minio支持以使用数据集服务 max_file_tooltips=单次最多上传?个文件,每个文件不超过? MB。 -max_size-tooltips=一次最多只能上传?个文件, 上传已达到上限,请勿再添加文件。 +max_size_tooltips=一次最多只能上传?个文件, 上传已达到上限,请勿再添加文件。 [notification] notifications=通知 diff --git a/web_src/js/index.js b/web_src/js/index.js index 3127e2110..8cbf86fb2 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2803,7 +2803,7 @@ $(document).ready(async () => { } }); this.on('addedfile',(file)=>{ - if(file.size/(1000*1000)>3){ + if(file.size/(1000*1000)>$dropzone.data('max-size')){ this.removeFile(file) $('.maxfilesize.ui.red.message').text(maxFileTooltips) $('.maxfilesize.ui.red.message').css('display','block') From cb128d6719494ea73a76388597df7a1a44816a36 Mon Sep 17 00:00:00 2001 From: OpenIhu Date: Mon, 11 Apr 2022 14:49:47 +0800 Subject: [PATCH 119/129] =?UTF-8?q?=E7=BB=84=E7=BB=87=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=80=82=E9=85=8D=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=8F=8A=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=8E=A8=E8=8D=90=E9=A1=B9=E7=9B=AE=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/org/navber.tmpl | 7 ++--- templates/org/select_pro.tmpl | 53 ++++++++++++++--------------------- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/templates/org/navber.tmpl b/templates/org/navber.tmpl index f7e88c1e9..772d9f67e 100755 --- a/templates/org/navber.tmpl +++ b/templates/org/navber.tmpl @@ -42,18 +42,15 @@ .active{ color:#0366D6 !important; } - .mleft{ - margin-left: 30% !important; - } .mbom{ margin-bottom: 10px !important; }
-