>>0}(a):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var o=function(e,t){var n=e.children[0];if(n&&1===n.type){var r=Pa(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map(function(e){return"function(){"+e+"}"}).join(",")+"]}"}}(e,t);o&&(n+=o+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Ga(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Ka(e){return 1===e.type&&("slot"===e.tag||e.children.some(Ka))}function Ja(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ua(e,t,Ja,"null");if(e.for&&!e.forProcessed)return za(e,t,Ja);var r=e.slotScope===ca?"":String(e.slotScope),i="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(qa(e,t)||"undefined")+":undefined":qa(e,t)||"undefined":Ra(e,t))+"}",o=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+i+o+"}"}function qa(e,t,n,r,i){var o=e.children;if(o.length){var a=o[0];if(1===o.length&&a.for&&"template"!==a.tag&&"slot"!==a.tag){var s=n?t.maybeComponent(a)?",1":",0":"";return""+(r||Ra)(a,t)+s}var c=n?function(e,t){for(var n=0,r=0;r':'',ts.innerHTML.indexOf("
")>0}var os=!!z&&is(!1),as=!!z&&is(!0),ss=g(function(e){var t=Yn(e);return t&&t.innerHTML}),cs=wn.prototype.$mount;return wn.prototype.$mount=function(e,t){if((e=e&&Yn(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ss(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){var i=rs(r,{outputSourceRange:!1,shouldDecodeNewlines:os,shouldDecodeNewlinesForHref:as,delimiters:n.delimiters,comments:n.comments},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return cs.call(this,e,t)},wn.compile=rs,wn});
\ No newline at end of file
diff --git a/models/cloudbrain.go b/models/cloudbrain.go
index 21d9768f7..1629acfeb 100755
--- a/models/cloudbrain.go
+++ b/models/cloudbrain.go
@@ -1291,7 +1291,8 @@ func QueryModelTrainJobVersionList(jobId string) ([]*CloudbrainInfo, int, error)
builder.Eq{"cloudbrain.job_id": jobId},
)
cond = cond.And(
- builder.Eq{"cloudbrain.Status": "COMPLETED"},
+ builder.In("cloudbrain.Status", "COMPLETED", "SUCCEEDED"),
+ //builder.Eq{"cloudbrain.Status": "COMPLETED"},
)
sess.OrderBy("cloudbrain.created_unix DESC")
@@ -1312,7 +1313,7 @@ func QueryModelTrainJobList(repoId int64) ([]*CloudbrainInfo, int, error) {
builder.Eq{"repo_id": repoId},
)
cond = cond.And(
- builder.Eq{"Status": "COMPLETED"},
+ builder.In("Status", "COMPLETED", "SUCCEEDED"),
)
cond = cond.And(
builder.Eq{"job_type": "TRAIN"},
diff --git a/models/cloudbrain_static.go b/models/cloudbrain_static.go
new file mode 100644
index 000000000..31f66d4fc
--- /dev/null
+++ b/models/cloudbrain_static.go
@@ -0,0 +1,22 @@
+package models
+
+import "code.gitea.io/gitea/modules/log"
+
+func GetAllStatusCloudBrain() map[string]int {
+ sess := x.NewSession()
+ defer sess.Close()
+ cloudbrains := make([]*CloudbrainInfo, 0)
+ if err := sess.Table(&Cloudbrain{}).Unscoped().
+ Find(&cloudbrains); err != nil {
+ log.Info("find error.")
+ }
+ cloudBrainStatusResult := make(map[string]int)
+ for _, cloudbrain := range cloudbrains {
+ if _, ok := cloudBrainStatusResult[cloudbrain.Status]; !ok {
+ cloudBrainStatusResult[cloudbrain.Status] = 1
+ } else {
+ cloudBrainStatusResult[cloudbrain.Status] += 1
+ }
+ }
+ return cloudBrainStatusResult
+}
diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go
index 333867fb2..4cd3539d7 100644
--- a/models/user_business_analysis.go
+++ b/models/user_business_analysis.go
@@ -719,12 +719,11 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS
userIndexMap := make(map[int64]float64, 0)
maxUserIndex := 0.0
minUserIndex := 100000000.0
- dateRecordBatch := make([]UserBusinessAnalysisAll, 0)
for {
sess.Select("`user`.*").Table("user").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal))
userList := make([]*User, 0)
sess.Find(&userList)
-
+ dateRecordBatch := make([]UserBusinessAnalysisAll, 0)
for _, userRecord := range userList {
var dateRecordAll UserBusinessAnalysisAll
dateRecordAll.ID = userRecord.ID
@@ -789,7 +788,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS
dateRecordBatch = append(dateRecordBatch, dateRecordAll)
if len(dateRecordBatch) >= BATCH_INSERT_SIZE {
- insertTable(dateRecordBatch, tableName, statictisSess)
+ err := insertTable(dateRecordBatch, tableName, statictisSess)
insertCount += BATCH_INSERT_SIZE
if err != nil {
log.Info("insert all data failed." + err.Error())
@@ -804,18 +803,19 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS
}
}
}
+ if len(dateRecordBatch) > 0 {
+ err := insertTable(dateRecordBatch, tableName, statictisSess)
+ insertCount += len(dateRecordBatch)
+ if err != nil {
+ log.Info("insert all data failed." + err.Error())
+ }
+ }
indexTotal += PAGE_SIZE
if indexTotal >= count {
break
}
}
- if len(dateRecordBatch) > 0 {
- insertTable(dateRecordBatch, tableName, statictisSess)
- insertCount += len(dateRecordBatch)
- if err != nil {
- log.Info("insert all data failed." + err.Error())
- }
- }
+
if tableName == "user_business_analysis_all" {
log.Info("TotalHasActivityUser=" + fmt.Sprint(userMetrics["TotalHasActivityUser"]))
}
@@ -835,7 +835,7 @@ func updateUserIndex(tableName string, statictisSess *xorm.Session, userId int64
statictisSess.Exec(updateSql)
}
-func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, statictisSess *xorm.Session) {
+func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, statictisSess *xorm.Session) error {
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, " +
@@ -854,7 +854,8 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static
}
}
- statictisSess.Exec(insertBatchSql)
+ _, err := statictisSess.Exec(insertBatchSql)
+ return err
}
func RefreshUserStaticAllTabel(wikiCountMap map[string]int, userMetrics map[string]int) {
@@ -2057,7 +2058,9 @@ func queryCloudBrainTask(start_unix int64, end_unix int64) (map[int64]int, map[s
} else {
resultMap[cloudTaskRecord.UserID] += 1
}
- setMapKey("CloudBrainRunTime", cloudTaskRecord.UserID, int(cloudTaskRecord.Duration), resultItemMap)
+ if cloudTaskRecord.Duration < 100000000 && cloudTaskRecord.Duration > 0 {
+ 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/modules/storage/local.go b/modules/storage/local.go
index df5807f87..4f431f11a 100755
--- a/modules/storage/local.go
+++ b/modules/storage/local.go
@@ -39,6 +39,14 @@ func (l *LocalStorage) Open(path string) (io.ReadCloser, error) {
return f, nil
}
+func (l *LocalStorage) DownloadAFile(bucket string, objectName string) (io.ReadCloser, error) {
+ f, err := os.Open(filepath.Join(l.dir, objectName))
+ if err != nil {
+ return nil, err
+ }
+ return f, nil
+}
+
// Save save a file
func (l *LocalStorage) Save(path string, r io.Reader) (int64, error) {
p := filepath.Join(l.dir, path)
diff --git a/modules/storage/minio.go b/modules/storage/minio.go
index 7b914817d..47f70e12d 100755
--- a/modules/storage/minio.go
+++ b/modules/storage/minio.go
@@ -59,6 +59,16 @@ func (m *MinioStorage) buildMinioPath(p string) string {
return strings.TrimPrefix(path.Join(m.basePath, p), "/")
}
+func (m *MinioStorage) DownloadAFile(bucket string, objectName string) (io.ReadCloser, error) {
+
+ var opts = minio.GetObjectOptions{}
+ object, err := m.client.GetObject(m.bucket, objectName, opts)
+ if err != nil {
+ return nil, err
+ }
+ return object, nil
+}
+
// Open open a file
func (m *MinioStorage) Open(path string) (io.ReadCloser, error) {
var opts = minio.GetObjectOptions{}
diff --git a/modules/storage/minio_ext.go b/modules/storage/minio_ext.go
index 167cd0488..514ac7204 100755
--- a/modules/storage/minio_ext.go
+++ b/modules/storage/minio_ext.go
@@ -113,7 +113,141 @@ func GenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, partSiz
objectName := strings.TrimPrefix(path.Join(minio.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
return minioClient.GenUploadPartSignedUrl(uploadId, bucketName, objectName, partNumber, partSize, PresignedUploadPartUrlExpireTime, setting.Attachment.Minio.Location)
+}
+
+func GetAllObjectByBucketAndPrefixMinio(bucket string, prefix string) ([]FileInfo, error) {
+ _, core, err := getClients()
+ if err != nil {
+ log.Error("getClients failed:", err.Error())
+ return nil, err
+ }
+ prefixLen := len(prefix)
+ delimiter := ""
+ marker := ""
+ index := 1
+ fileInfoList := FileInfoList{}
+ for {
+ output, err := core.ListObjects(bucket, prefix, marker, delimiter, 1000)
+ if err == nil {
+ log.Info("Page:%d\n", index)
+ index++
+ for _, val := range output.Contents {
+ var isDir bool
+ if prefixLen == len(val.Key) {
+ continue
+ }
+ if strings.HasSuffix(val.Key, "/") {
+ isDir = true
+ } else {
+ isDir = false
+ }
+ fileInfo := FileInfo{
+ ModTime: val.LastModified.Format("2006-01-02 15:04:05"),
+ FileName: val.Key[prefixLen:],
+ Size: val.Size,
+ IsDir: isDir,
+ ParenDir: "",
+ }
+ fileInfoList = append(fileInfoList, fileInfo)
+ }
+ if output.IsTruncated {
+ marker = output.NextMarker
+ } else {
+ break
+ }
+ } else {
+ log.Info("list error." + err.Error())
+ return nil, err
+ }
+ }
+ sort.Sort(fileInfoList)
+ return fileInfoList, nil
+}
+
+func GetOneLevelAllObjectUnderDirMinio(bucket string, prefixRootPath string, relativePath string) ([]FileInfo, error) {
+ _, core, err := getClients()
+ if err != nil {
+ log.Error("getClients failed:", err.Error())
+ return nil, err
+ }
+ Prefix := prefixRootPath + relativePath
+ if !strings.HasSuffix(Prefix, "/") {
+ Prefix += "/"
+ }
+ log.Info("bucket=" + bucket + " Prefix=" + Prefix)
+ output, err := core.ListObjects(bucket, Prefix, "", "", 1000)
+ fileInfos := make([]FileInfo, 0)
+ prefixLen := len(Prefix)
+ if err == nil {
+ for _, val := range output.Contents {
+ log.Info("val key=" + val.Key)
+ var isDir bool
+ var fileName string
+ if val.Key == Prefix {
+ continue
+ }
+ if strings.Contains(val.Key[prefixLen:len(val.Key)-1], "/") {
+ continue
+ }
+ if strings.HasSuffix(val.Key, "/") {
+ isDir = true
+ fileName = val.Key[prefixLen : len(val.Key)-1]
+ relativePath += val.Key[prefixLen:]
+ } else {
+ isDir = false
+ fileName = val.Key[prefixLen:]
+ }
+ fileInfo := FileInfo{
+ ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"),
+ FileName: fileName,
+ Size: val.Size,
+ IsDir: isDir,
+ ParenDir: relativePath,
+ }
+ fileInfos = append(fileInfos, fileInfo)
+ }
+ return fileInfos, err
+ } else {
+
+ log.Error("Message:%s", err.Error())
+
+ return nil, err
+ }
+
+}
+
+func MinioPathCopy(bucketName string, srcPath string, destPath string) (int64, error) {
+ _, core, err := getClients()
+ var fileTotalSize int64
+ fileTotalSize = 0
+ if err != nil {
+ log.Error("getClients failed:", err.Error())
+ return fileTotalSize, err
+ }
+ delimiter := ""
+ marker := ""
+ for {
+ output, err := core.ListObjects(bucketName, srcPath, marker, delimiter, 1000)
+ if err == nil {
+ for _, val := range output.Contents {
+ srcObjectName := val.Key
+ destObjectName := destPath + srcObjectName[len(srcPath):]
+ log.Info("srcObjectName=" + srcObjectName + " destObjectName=" + destObjectName)
+ core.CopyObject(bucketName, srcObjectName, bucketName, destObjectName, val.UserMetadata)
+ fileTotalSize += val.Size
+ }
+ if output.IsTruncated {
+ marker = output.NextMarker
+ } else {
+ break
+ }
+ } else {
+ log.Info("list error." + err.Error())
+ return 0, err
+ }
+ }
+ return fileTotalSize, nil
}
func NewMultiPartUpload(uuid string) (string, error) {
diff --git a/modules/storage/storage.go b/modules/storage/storage.go
index fc9d38020..bb9fff10a 100755
--- a/modules/storage/storage.go
+++ b/modules/storage/storage.go
@@ -22,6 +22,7 @@ const (
type ObjectStorage interface {
Save(path string, r io.Reader) (int64, error)
Open(path string) (io.ReadCloser, error)
+ DownloadAFile(bucket string, objectName string) (io.ReadCloser, error)
Delete(path string) error
DeleteDir(dir string) error
PresignedGetURL(path string, fileName string) (string, error)
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 016aa4951..75beda268 100755
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -1452,6 +1452,7 @@ issues.filter_sort.feweststars = Fewest stars
issues.filter_sort.mostforks = Most forks
issues.filter_sort.fewestforks = Fewest forks
issues.filter_sort.downloadtimes = Most downloaded
+issues.filter_sort.citations=Citations
issues.filter_sort.mostusecount = Most Quote
issues.filter_sort.fewestusecount=Fewest Quote
issues.action_open = Open
diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini
index 440f6746a..ac9de9fed 100755
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locale/locale_zh-CN.ini
@@ -226,7 +226,7 @@ contributors=贡献者
contributor=贡献者
page_title=探索更好的AI
-page_small_title=启智AI开发协作平台
+page_small_title=启智AI协作平台
page_description=面向AI领域的一站式协同开发环境,提供集代码开发、数据管理、模型调试、推理和评测为一体的AI开发流水线
page_use=立即使用
page_only_dynamic=仅展示开源项目动态
@@ -1462,9 +1462,11 @@ issues.filter_sort.feweststars=点赞由少到多
issues.filter_sort.mostforks=派生由多到少
issues.filter_sort.fewestforks=派生由少到多
issues.filter_sort.downloadtimes=下载次数
+issues.filter_sort.citations=引用次数
issues.filter_sort.moststars=收藏数量
issues.filter_sort.mostusecount=最多引用
issues.filter_sort.fewestusecount=最少引用
+
issues.action_open=开启
issues.action_close=关闭
issues.action_label=标签
diff --git a/public/home/home.js b/public/home/home.js
index 2affefddd..9754de0cb 100755
--- a/public/home/home.js
+++ b/public/home/home.js
@@ -9,7 +9,7 @@ if(isEmpty(token)){
var swiperNewMessage = new Swiper(".newslist", {
direction: "vertical",
- slidesPerView: 10,
+ slidesPerView: 9,
loop: true,
autoplay: {
delay: 2500,
@@ -17,7 +17,7 @@ var swiperNewMessage = new Swiper(".newslist", {
},
});
var swiperEvent = new Swiper(".event-list", {
- slidesPerView: 2,
+ slidesPerView: 3,
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
@@ -117,6 +117,7 @@ socket.onmessage = function (e) {
continue;
}
}
+ refresh3DInfo(record);
var recordPrefix = getMsg(record);
if(record.OpType == "6" || record.OpType == "10" || record.OpType == "12" || record.OpType == "13"){
html += recordPrefix + actionName;
@@ -200,6 +201,29 @@ function getTaskLink(record){
return re;
}
+function refresh3DInfo(record){
+ if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){
+ //cloudbrain one
+ var lines = $('.rotation3D__line');
+ var span = $('.rotation3D__line').find("span")[0];
+ //console.log(span);
+ span.innerText =record.RefName;
+ //$('.rotation3D__line').find("span").eq(0).text(record.RefName)
+ //console.log("cloudbrain one line length=" + lines.length);
+ //lines[0].find("span").text(record.RefName);
+ }else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){
+ //cloudbrain two
+ var lines = $('.rotation3D__line');
+ //console.log("cloudbrain two line length=" + lines.length);
+ var span = $('.rotation3D__line').find("span")[1];
+ //console.log(span);
+ span.innerText =record.RefName;
+ //$('.rotation3D__line').find("span").eq(1).text(record.RefName)
+ //lines[1].find("span").text(record.RefName);
+ }
+
+}
+
function getMsg(record){
var html ="";
html += "";
@@ -425,13 +449,50 @@ function queryRecommendData(){
dataType:"json",
async:false,
success:function(json){
- displayOrg(json.org);
- displayRepo(json.repo);
- displayActivity(json.image)
+ displayOrg(json.org);
+ displayRepo(json.repo);
+ displayActivity(json.image);
+ displayCloudBrain(json.cloudbrain)
},
error:function(response) {
}
});
+
+ // $.ajax({
+ // type:"GET",
+ // url:"/recommend/repo",
+ // headers: {
+ // authorization:token,
+ // },
+ // dataType:"json",
+ // async:false,
+ // success:function(json){
+ // displayRepo(json);
+ // },
+ // error:function(response) {
+ // }
+ // });
+
+ // $.ajax({
+ // type:"GET",
+ // url:"/recommend/imageinfo",
+ // headers: {
+ // authorization:token,
+ // },
+ // dataType:"json",
+ // async:false,
+ // success:function(json){
+ // displayActivity(json);
+ // },
+ // error:function(response) {
+ // }
+ // });
+}
+
+function displayCloudBrain(json){
+ $('#completed_task').text(json.completed_task);
+ $('#running_task').text(json.running_task);
+ $('#wait_task').text(json.wait_task);
}
function displayActivity(json){
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index d6d3b001a..35089f0e7 100755
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -573,6 +573,9 @@ func RegisterRoutes(m *macaron.Macaron) {
//cloudbrain board
m.Group("/cloudbrainboard", func() {
m.Get("/downloadAll", repo.DownloadCloudBrainBoard)
+ m.Group("/cloudbrain", func() {
+ m.Get("/status_analysis", repo.GetCloudbrainsStatusAnalysis)
+ })
}, operationReq)
// Users
m.Group("/users", func() {
diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go
index 2090a2cf2..0710a21e4 100644
--- a/routers/api/v1/repo/cloudbrain_dashboard.go
+++ b/routers/api/v1/repo/cloudbrain_dashboard.go
@@ -11,6 +11,16 @@ import (
"github.com/360EntSecGroup-Skylar/excelize/v2"
)
+type CloudbrainsStatusAnalysis struct {
+ JobWaitingCount int64 `json:"jobWaitingCount"`
+ JobRunningCount int64 `json:"jobRunningCount"`
+ JobStoppedCount int64 `json:"jobStoppedCount"`
+ JobCompletedCount int64 `json:"jobCompletedCount"`
+ JobFailedCount int64 `json:"jobFailedCount"`
+ JobKilledCount int64 `json:"jobKilledCount"`
+ JobInitCount int64 `json:"jobInitCount"`
+}
+
func DownloadCloudBrainBoard(ctx *context.Context) {
page := 1
@@ -133,3 +143,9 @@ func getBrainWaitTime(rs *models.CloudbrainInfo) string {
return models.ConvertDurationToStr(int64(waitTime))
}
}
+func GetCloudbrainsStatusAnalysis(ctx *context.Context) {
+ cloudBrainStatusResult := models.GetAllStatusCloudBrain()
+ ctx.JSON(http.StatusOK, map[string]interface{}{
+ "cloudBrainStatusResult": cloudBrainStatusResult,
+ })
+}
diff --git a/routers/home.go b/routers/home.go
index a34302876..e31bed4ff 100755
--- a/routers/home.go
+++ b/routers/home.go
@@ -7,6 +7,7 @@ package routers
import (
"bytes"
+ "fmt"
"net/http"
"strconv"
"strings"
@@ -750,6 +751,15 @@ func GetRankUser(index string) ([]map[string]interface{}, error) {
return resultOrg, nil
}
+// func GetImageInfoFromPromote(ctx *context.Context) {
+// imageInfo, err := GetImageInfo()
+// if err != nil {
+// ctx.ServerError("500", err)
+// return
+// }
+// ctx.JSON(200, imageInfo)
+// }
+
func GetUserRankFromPromote(ctx *context.Context) {
index := ctx.Params("index")
resultUserRank, err := GetRankUser(index)
@@ -773,13 +783,36 @@ func RecommendHomeInfo(ctx *context.Context) {
if err != nil {
log.Info("error." + err.Error())
}
+ resultCloudBrain, err := getCloudbrainNums()
+ if err != nil {
+ log.Info("error." + err.Error())
+ }
mapInterface := make(map[string]interface{})
mapInterface["org"] = resultOrg
mapInterface["repo"] = resultRepo
mapInterface["image"] = resultImage
+ mapInterface["cloudbrain"] = resultCloudBrain
ctx.JSON(http.StatusOK, mapInterface)
}
+func getCloudbrainNums() (map[string]string, error) {
+ result := make(map[string]string)
+ cloudStatusMap := models.GetAllStatusCloudBrain()
+ result["completed_task"] = fmt.Sprint(cloudStatusMap["COMPLETED"])
+ result["running_task"] = fmt.Sprint(cloudStatusMap["RUNNING"])
+ result["wait_task"] = fmt.Sprint(cloudStatusMap["WAITING"])
+ return result, nil
+}
+
+// func RecommendOrgFromPromote(ctx *context.Context) {
+// resultOrg, err := GetRecommendOrg()
+// if err != nil {
+// ctx.ServerError("500", err)
+// return
+// }
+// ctx.JSON(200, resultOrg)
+// }
+
func RecommendRepoFromPromote(ctx *context.Context) {
result, err := repository.GetRecommendRepoFromPromote("projects")
if err != nil {
diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go
index e2040e0d2..3ca6cf115 100644
--- a/routers/repo/ai_model_manage.go
+++ b/routers/repo/ai_model_manage.go
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
+ "net/url"
"path"
"strings"
@@ -27,19 +28,22 @@ const (
MODEL_NOT_LATEST = 0
)
-func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, ctx *context.Context) error {
+func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, engine int, ctx *context.Context) error {
aiTask, err := models.GetCloudbrainByJobIDAndVersionName(jobId, versionName)
if err != nil {
- log.Info("query task error." + err.Error())
- return err
+ aiTask, err = models.GetRepoCloudBrainByJobID(ctx.Repo.Repository.ID, jobId)
+ if err != nil {
+ log.Info("query task error." + err.Error())
+ return err
+ } else {
+ log.Info("query gpu train task.")
+ }
}
-
uuid := uuid.NewV4()
id := uuid.String()
modelPath := id
var lastNewModelId string
var modelSize int64
- cloudType := models.TypeCloudBrainTwo
log.Info("find task name:" + aiTask.JobName)
aimodels := models.QueryModelByName(name, aiTask.RepoID)
@@ -53,7 +57,7 @@ func saveModelByParameters(jobId string, versionName string, name string, versio
}
}
}
- cloudType = aiTask.Type
+ cloudType := aiTask.Type
//download model zip //train type
if cloudType == models.TypeCloudBrainTwo {
modelPath, modelSize, err = downloadModelFromCloudBrainTwo(id, aiTask.JobName, "", aiTask.TrainUrl)
@@ -61,6 +65,12 @@ func saveModelByParameters(jobId string, versionName string, name string, versio
log.Info("download model from CloudBrainTwo faild." + err.Error())
return err
}
+ } else if cloudType == models.TypeCloudBrainOne {
+ modelPath, modelSize, err = downloadModelFromCloudBrainOne(id, aiTask.JobName, "", aiTask.TrainUrl)
+ if err != nil {
+ log.Info("download model from CloudBrainOne faild." + err.Error())
+ return err
+ }
}
accuracy := make(map[string]string)
accuracy["F1"] = ""
@@ -131,7 +141,7 @@ func SaveNewNameModel(ctx *context.Context) {
return
}
SaveModel(ctx)
-
+ ctx.Status(200)
log.Info("save model end.")
}
@@ -143,8 +153,9 @@ func SaveModel(ctx *context.Context) {
version := ctx.Query("Version")
label := ctx.Query("Label")
description := ctx.Query("Description")
+ engine := ctx.QueryInt("Engine")
trainTaskCreate := ctx.QueryBool("trainTaskCreate")
-
+ log.Info("engine=" + fmt.Sprint(engine))
if !trainTaskCreate {
if !ctx.Repo.CanWrite(models.UnitTypeModelManage) {
//ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
@@ -163,14 +174,14 @@ func SaveModel(ctx *context.Context) {
return
}
- err := saveModelByParameters(JobId, VersionName, name, version, label, description, ctx)
+ err := saveModelByParameters(JobId, VersionName, name, version, label, description, engine, ctx)
if err != nil {
log.Info("save model error." + err.Error())
ctx.Error(500, fmt.Sprintf("save model error. %v", err))
return
}
-
+ ctx.Status(200)
log.Info("save model end.")
}
@@ -199,6 +210,22 @@ func downloadModelFromCloudBrainTwo(modelUUID string, jobName string, parentDir
return dataActualPath, size, nil
}
+func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir string, trainUrl string) (string, int64, error) {
+ modelActualPath := storage.GetMinioPath(jobName, "/model/")
+ log.Info("modelActualPath=" + modelActualPath)
+ modelSrcPrefix := setting.CBCodePathPrefix + jobName + "/model/"
+ destKeyNamePrefix := Model_prefix + models.AttachmentRelativePath(modelUUID) + "/"
+ bucketName := setting.Attachment.Minio.Bucket
+ log.Info("destKeyNamePrefix=" + destKeyNamePrefix + " modelSrcPrefix=" + modelSrcPrefix + " bucket=" + bucketName)
+ size, err := storage.MinioPathCopy(bucketName, modelSrcPrefix, destKeyNamePrefix)
+ if err == nil {
+ dataActualPath := bucketName + "/" + destKeyNamePrefix
+ return dataActualPath, size, nil
+ } else {
+ return "", 0, nil
+ }
+}
+
func DeleteModel(ctx *context.Context) {
log.Info("delete model start.")
id := ctx.Query("ID")
@@ -277,51 +304,117 @@ func DownloadMultiModelFile(ctx *context.Context) {
}
path := Model_prefix + models.AttachmentRelativePath(id) + "/"
+ if task.Type == models.TypeCloudBrainTwo {
+ downloadFromCloudBrainTwo(path, task, ctx, id)
+ } else if task.Type == models.TypeCloudBrainOne {
+ downloadFromCloudBrainOne(path, task, ctx, id)
+ }
+}
- allFile, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, path)
+func MinioDownloadManyFile(path string, ctx *context.Context, returnFileName string, allFile []storage.FileInfo) {
+ ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(returnFileName))
+ ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
+ w := zip.NewWriter(ctx.Resp)
+ defer w.Close()
+ for _, oneFile := range allFile {
+ if oneFile.IsDir {
+ log.Info("zip dir name:" + oneFile.FileName)
+ } else {
+ log.Info("zip file name:" + oneFile.FileName)
+ fDest, err := w.Create(oneFile.FileName)
+ if err != nil {
+ log.Info("create zip entry error, download file failed: %s\n", err.Error())
+ ctx.ServerError("download file failed:", err)
+ return
+ }
+ log.Info("minio file path=" + (path + oneFile.FileName))
+ body, err := storage.Attachments.DownloadAFile(setting.Attachment.Minio.Bucket, path+oneFile.FileName)
+ if err != nil {
+ log.Info("download file failed: %s\n", err.Error())
+ ctx.ServerError("download file failed:", err)
+ return
+ } else {
+ defer body.Close()
+ p := make([]byte, 1024)
+ var readErr error
+ var readCount int
+ // 读取对象内容
+ for {
+ readCount, readErr = body.Read(p)
+ if readCount > 0 {
+ fDest.Write(p[:readCount])
+ }
+ if readErr != nil {
+ break
+ }
+ }
+ }
+ }
+ }
+
+}
+
+func downloadFromCloudBrainOne(path string, task *models.AiModelManage, ctx *context.Context, id string) {
+ allFile, err := storage.GetAllObjectByBucketAndPrefixMinio(setting.Attachment.Minio.Bucket, path)
if err == nil {
//count++
models.ModifyModelDownloadCount(id)
-
returnFileName := task.Name + "_" + task.Version + ".zip"
- ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+returnFileName)
- ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
- w := zip.NewWriter(ctx.Resp)
- defer w.Close()
- for _, oneFile := range allFile {
- if oneFile.IsDir {
- log.Info("zip dir name:" + oneFile.FileName)
+ MinioDownloadManyFile(path, ctx, returnFileName, allFile)
+ } else {
+ log.Info("error,msg=" + err.Error())
+ ctx.ServerError("no file to download.", err)
+ }
+}
+
+func ObsDownloadManyFile(path string, ctx *context.Context, returnFileName string, allFile []storage.FileInfo) {
+ ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(returnFileName))
+ ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
+ w := zip.NewWriter(ctx.Resp)
+ defer w.Close()
+ for _, oneFile := range allFile {
+ if oneFile.IsDir {
+ log.Info("zip dir name:" + oneFile.FileName)
+ } else {
+ log.Info("zip file name:" + oneFile.FileName)
+ fDest, err := w.Create(oneFile.FileName)
+ if err != nil {
+ log.Info("create zip entry error, download file failed: %s\n", err.Error())
+ ctx.ServerError("download file failed:", err)
+ return
+ }
+ body, err := storage.ObsDownloadAFile(setting.Bucket, path+oneFile.FileName)
+ if err != nil {
+ log.Info("download file failed: %s\n", err.Error())
+ ctx.ServerError("download file failed:", err)
+ return
} else {
- log.Info("zip file name:" + oneFile.FileName)
- fDest, err := w.Create(oneFile.FileName)
- if err != nil {
- log.Info("create zip entry error, download file failed: %s\n", err.Error())
- ctx.ServerError("download file failed:", err)
- return
- }
- body, err := storage.ObsDownloadAFile(setting.Bucket, path+oneFile.FileName)
- if err != nil {
- log.Info("download file failed: %s\n", err.Error())
- ctx.ServerError("download file failed:", err)
- return
- } else {
- defer body.Close()
- p := make([]byte, 1024)
- var readErr error
- var readCount int
- // 读取对象内容
- for {
- readCount, readErr = body.Read(p)
- if readCount > 0 {
- fDest.Write(p[:readCount])
- }
- if readErr != nil {
- break
- }
+ defer body.Close()
+ p := make([]byte, 1024)
+ var readErr error
+ var readCount int
+ // 读取对象内容
+ for {
+ readCount, readErr = body.Read(p)
+ if readCount > 0 {
+ fDest.Write(p[:readCount])
+ }
+ if readErr != nil {
+ break
}
}
}
}
+ }
+}
+
+func downloadFromCloudBrainTwo(path string, task *models.AiModelManage, ctx *context.Context, id string) {
+ allFile, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, path)
+ if err == nil {
+ //count++
+ models.ModifyModelDownloadCount(id)
+ returnFileName := task.Name + "_" + task.Version + ".zip"
+ ObsDownloadManyFile(path, ctx, returnFileName, allFile)
} else {
log.Info("error,msg=" + err.Error())
ctx.ServerError("no file to download.", err)
@@ -374,42 +467,55 @@ func DownloadSingleModelFile(ctx *context.Context) {
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
return
}
- if setting.PROXYURL != "" {
- body, err := storage.ObsDownloadAFile(setting.Bucket, path)
- if err != nil {
- log.Info("download error.")
+ if task.Type == models.TypeCloudBrainTwo {
+ if setting.PROXYURL != "" {
+ body, err := storage.ObsDownloadAFile(setting.Bucket, path)
+ if err != nil {
+ log.Info("download error.")
+ } else {
+ //count++
+ models.ModifyModelDownloadCount(id)
+ defer body.Close()
+ ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName)
+ ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
+ p := make([]byte, 1024)
+ var readErr error
+ var readCount int
+ // 读取对象内容
+ for {
+ readCount, readErr = body.Read(p)
+ if readCount > 0 {
+ ctx.Resp.Write(p[:readCount])
+ //fmt.Printf("%s", p[:readCount])
+ }
+ if readErr != nil {
+ break
+ }
+ }
+ }
} else {
+ url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path)
+ if err != nil {
+ log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"])
+ ctx.ServerError("GetObsCreateSignedUrl", err)
+ return
+ }
//count++
models.ModifyModelDownloadCount(id)
- defer body.Close()
- ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName)
- ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
- p := make([]byte, 1024)
- var readErr error
- var readCount int
- // 读取对象内容
- for {
- readCount, readErr = body.Read(p)
- if readCount > 0 {
- ctx.Resp.Write(p[:readCount])
- //fmt.Printf("%s", p[:readCount])
- }
- if readErr != nil {
- break
- }
- }
+ http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently)
}
- } else {
- url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path)
+ } else if task.Type == models.TypeCloudBrainOne {
+ log.Info("start to down load minio file.")
+ url, err := storage.Attachments.PresignedGetURL(path, fileName)
if err != nil {
- log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"])
- ctx.ServerError("GetObsCreateSignedUrl", err)
+ log.Error("Get minio get SignedUrl failed: %v", err.Error(), ctx.Data["msgID"])
+ ctx.ServerError("Get minio get SignedUrl failed", err)
return
}
- //count++
models.ModifyModelDownloadCount(id)
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently)
}
+
}
func ShowModelInfo(ctx *context.Context) {
@@ -684,14 +790,22 @@ func QueryModelListForPredict(ctx *context.Context) {
func QueryModelFileForPredict(ctx *context.Context) {
id := ctx.Query("ID")
model, err := models.QueryModelById(id)
- if err != nil {
+ if err == nil {
+ if model.Type == models.TypeCloudBrainTwo {
+ prefix := model.Path[len(setting.Bucket)+1:]
+ fileinfos, _ := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix)
+ ctx.JSON(http.StatusOK, fileinfos)
+ } else if model.Type == models.TypeCloudBrainOne {
+ prefix := model.Path[len(setting.Attachment.Minio.Bucket)+1:]
+ fileinfos, _ := storage.GetAllObjectByBucketAndPrefixMinio(setting.Attachment.Minio.Bucket, prefix)
+ ctx.JSON(http.StatusOK, fileinfos)
+ }
+ } else {
log.Error("no such model!", err.Error())
ctx.ServerError("no such model:", err)
return
}
- prefix := model.Path[len(setting.Bucket)+1:]
- fileinfos, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix)
- ctx.JSON(http.StatusOK, fileinfos)
+
}
func QueryOneLevelModelFile(ctx *context.Context) {
@@ -703,7 +817,16 @@ func QueryOneLevelModelFile(ctx *context.Context) {
ctx.ServerError("no such model:", err)
return
}
- prefix := model.Path[len(setting.Bucket)+1:]
- fileinfos, err := storage.GetOneLevelAllObjectUnderDir(setting.Bucket, prefix, parentDir)
- ctx.JSON(http.StatusOK, fileinfos)
+ if model.Type == models.TypeCloudBrainTwo {
+ log.Info("TypeCloudBrainTwo list model file.")
+ prefix := model.Path[len(setting.Bucket)+1:]
+ fileinfos, _ := storage.GetOneLevelAllObjectUnderDir(setting.Bucket, prefix, parentDir)
+ ctx.JSON(http.StatusOK, fileinfos)
+ } else if model.Type == models.TypeCloudBrainOne {
+ log.Info("TypeCloudBrainOne list model file.")
+ prefix := model.Path[len(setting.Attachment.Minio.Bucket)+1:]
+ fileinfos, _ := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, parentDir)
+ ctx.JSON(http.StatusOK, fileinfos)
+ }
+
}
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index 278c40204..dd0605841 100755
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -324,7 +324,10 @@ func RegisterRoutes(m *macaron.Macaron) {
go routers.SocketManager.Run()
m.Get("/action/notification", routers.ActionNotification)
m.Get("/recommend/home", routers.RecommendHomeInfo)
+ //m.Get("/recommend/org", routers.RecommendOrgFromPromote)
+ //m.Get("/recommend/repo", routers.RecommendRepoFromPromote)
m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote)
+ //m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote)
m.Post("/all/search/", routers.Search)
m.Get("/all/search/", routers.EmptySearch)
m.Get("/all/dosearch/", routers.SearchApi)
@@ -1093,9 +1096,9 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/show_model_child_api", repo.ShowOneVersionOtherModel)
m.Get("/query_train_job", reqRepoCloudBrainReader, repo.QueryTrainJobList)
m.Get("/query_train_job_version", reqRepoCloudBrainReader, repo.QueryTrainJobVersionList)
- m.Get("/query_model_for_predict", reqRepoCloudBrainReader, repo.QueryModelListForPredict)
- m.Get("/query_modelfile_for_predict", reqRepoCloudBrainReader, repo.QueryModelFileForPredict)
- m.Get("/query_onelevel_modelfile", reqRepoCloudBrainReader, repo.QueryOneLevelModelFile)
+ m.Get("/query_model_for_predict", reqRepoModelManageReader, repo.QueryModelListForPredict)
+ m.Get("/query_modelfile_for_predict", reqRepoModelManageReader, repo.QueryModelFileForPredict)
+ m.Get("/query_onelevel_modelfile", reqRepoModelManageReader, repo.QueryOneLevelModelFile)
m.Group("/:ID", func() {
m.Get("", repo.ShowSingleModel)
m.Get("/downloadsingle", repo.DownloadSingleModelFile)
diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl
old mode 100644
new mode 100755
index 732f61ea5..802854716
--- a/templates/base/footer.tmpl
+++ b/templates/base/footer.tmpl
@@ -13,6 +13,9 @@
{{template "base/footer_content" .}}
+
+
+
{{if .RequireSimpleMDE}}
@@ -43,5 +46,46 @@
{{template "custom/footer" .}}
+{{if .PageIsHome}}
+
+
+
+
+{{end}}
+