| @@ -1329,6 +1329,9 @@ func QueryModelTrainJobList(repoId int64) ([]*CloudbrainInfo, int, error) { | |||
| cond = cond.And( | |||
| builder.Eq{"job_type": "TRAIN"}, | |||
| ) | |||
| cond = cond.And( | |||
| builder.In("type", 0, 1), | |||
| ) | |||
| cloudbrains := make([]*CloudbrainInfo, 0) | |||
| if err := sess.Select("job_id,display_job_name").Table(&Cloudbrain{}).Where(cond).OrderBy("created_unix DESC"). | |||
| @@ -6,7 +6,6 @@ | |||
| package models | |||
| import ( | |||
| "code.gitea.io/gitea/modules/blockchain" | |||
| "container/list" | |||
| "context" | |||
| "crypto/md5" | |||
| @@ -25,6 +24,8 @@ import ( | |||
| "time" | |||
| "unicode/utf8" | |||
| "code.gitea.io/gitea/modules/blockchain" | |||
| "code.gitea.io/gitea/modules/avatar" | |||
| "code.gitea.io/gitea/modules/base" | |||
| "code.gitea.io/gitea/modules/generate" | |||
| @@ -1498,6 +1499,17 @@ func GetUsersByIDs(ids []int64) (UserList, error) { | |||
| return ous, err | |||
| } | |||
| func GetUsersByNames(names []string) (UserList, error) { | |||
| ous := make([]*User, 0, len(names)) | |||
| if len(names) == 0 { | |||
| return ous, nil | |||
| } | |||
| err := x.In("name", names). | |||
| Asc("name"). | |||
| Find(&ous) | |||
| return ous, err | |||
| } | |||
| // GetUserIDsByNames returns a slice of ids corresponds to names. | |||
| func GetUserIDsByNames(names []string, ignoreNonExistent bool) ([]int64, error) { | |||
| ids := make([]int64, 0, len(names)) | |||
| @@ -217,9 +217,9 @@ function refresh3DInfo(record){ | |||
| //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); | |||
| if(span != null){ | |||
| span.innerText =record.RefName; | |||
| } | |||
| } | |||
| } | |||
| @@ -452,48 +452,12 @@ function queryRecommendData(){ | |||
| 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){ | |||
| var activityDiv = document.getElementById("recommendactivity"); | |||
| @@ -7,7 +7,6 @@ package routers | |||
| import ( | |||
| "bytes" | |||
| "fmt" | |||
| "net/http" | |||
| "strconv" | |||
| "strings" | |||
| @@ -673,10 +672,19 @@ func getRecommendOrg() ([]map[string]interface{}, error) { | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| names := make([]string, 0) | |||
| for _, userName := range result { | |||
| names = append(names, userName) | |||
| } | |||
| users, _ := models.GetUsersByNames(names) | |||
| userMap := make(map[string]*models.User, 0) | |||
| for _, user := range users { | |||
| userMap[user.Name] = user | |||
| } | |||
| resultOrg := make([]map[string]interface{}, 0) | |||
| for _, userName := range result { | |||
| user, err := models.GetUserByName(userName) | |||
| if err == nil { | |||
| user := userMap[userName] | |||
| if user != nil { | |||
| userMap := make(map[string]interface{}) | |||
| userMap["Name"] = user.Name | |||
| userMap["Description"] = user.Description | |||
| @@ -689,7 +697,7 @@ func getRecommendOrg() ([]map[string]interface{}, error) { | |||
| userMap["NumMembers"] = user.NumMembers | |||
| resultOrg = append(resultOrg, userMap) | |||
| } else { | |||
| log.Info("query user error," + err.Error()) | |||
| log.Info("the user not exist," + userName) | |||
| } | |||
| } | |||
| return resultOrg, nil | |||
| @@ -758,15 +766,6 @@ 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) | |||
| @@ -790,45 +789,15 @@ 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 | |||
| //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 { | |||
| ctx.ServerError("500", err) | |||
| } else { | |||
| ctx.JSON(200, result) | |||
| } | |||
| } | |||
| func HomeTerm(ctx *context.Context) { | |||
| ctx.HTML(200, tplHomeTerm) | |||
| } | |||
| @@ -131,11 +131,6 @@ func GetRecommendRepoFromPromote(filename string) ([]map[string]interface{}, err | |||
| repoMap["ID"] = fmt.Sprint(repo.ID) | |||
| repoMap["Name"] = repo.Name | |||
| repoMap["Alias"] = repo.Alias | |||
| if repo.RepoType == models.RepoCourse { | |||
| //Load creator | |||
| repo.GetCreator() | |||
| repoMap["Creator"] = repo.Creator | |||
| } | |||
| repoMap["OwnerName"] = repo.OwnerName | |||
| repoMap["NumStars"] = repo.NumStars | |||
| @@ -602,7 +602,7 @@ | |||
| <div class="unite min_title inline field required"> | |||
| <label>模型框架</label> | |||
| <input type="hidden" id="Engine" name="Engine" required> | |||
| <input style="width: 45%;" id="Engine_name" name="Engine_name" value="" readonly required maxlength="255"> | |||
| <input style="width: 45%;" id="Engine_name" name="Engine_name" readonly required maxlength="255"> | |||
| </div> | |||
| <div class="inline field"> | |||
| <label>模型标签</label> | |||
| @@ -675,7 +675,7 @@ | |||
| $('#JobName').val(obj.DisplayJobName).addClass('model_disabled') | |||
| $('input[name="JobId"]').val(obj.JobID) | |||
| $('input[name="VersionName"]').val(obj.VersionName).addClass('model_disabled') | |||
| if(obj.EngineID ==122){ | |||
| if(obj.EngineID ==122 || obj.EngineID ==35){ | |||
| $('input[name="Engine_name"]').val("MindSpore").addClass('model_disabled'); | |||
| $('input[name="Engine"]').val(2); | |||
| } | |||
| @@ -704,6 +704,8 @@ | |||
| type: 'POST', | |||
| data: data, | |||
| success: function (res) { | |||
| $('input[name="Engine_name"]').val(""); | |||
| $('input[name="Engine"]').val(""); | |||
| location.href = `/${userName}/${repoPath}/modelmanage/show_model` | |||
| $('.ui.modal.second').modal('hide') | |||
| }, | |||
| @@ -346,17 +346,20 @@ | |||
| $.get(`${repolink}/modelmanage/query_train_job?repoId=${repoId}`, (data) => { | |||
| const n_length = data.length | |||
| let train_html = '' | |||
| for (let i = 0; i < n_length; i++) { | |||
| train_html += `<div class="item" data-value="${data[i].JobID}">${data[i].DisplayJobName}</div>` | |||
| train_html += '</div>' | |||
| if(n_length > 0){ | |||
| let train_html = '' | |||
| for (let i = 0; i < n_length; i++) { | |||
| train_html += `<div class="item" data-value="${data[i].JobID}">${data[i].DisplayJobName}</div>` | |||
| train_html += '</div>' | |||
| } | |||
| $("#job-name").append(train_html) | |||
| $(".ui.dropdown.selection.search.width83").removeClass("loading") | |||
| $('#choice_model .default.text').text(data[0].DisplayJobName) | |||
| $('#choice_model input[name="JobId"]').val(data[0].JobID) | |||
| loadTrainVersion() | |||
| }else{ | |||
| $(".ui.dropdown.selection.search.width83").removeClass("loading") | |||
| } | |||
| $("#job-name").append(train_html) | |||
| $(".ui.dropdown.selection.search.width83").removeClass("loading") | |||
| $('#choice_model .default.text').text(data[0].DisplayJobName) | |||
| $('#choice_model input[name="JobId"]').val(data[0].JobID) | |||
| loadTrainVersion() | |||
| }) | |||
| } | |||
| function loadTrainVersion(value) { | |||
| @@ -378,7 +381,6 @@ | |||
| } | |||
| $('#choice_version .default.text').text(versionName) | |||
| $('#choice_version input[name="VersionName"]').val(versionName) | |||
| console.log("1111111111"); | |||
| setEngine(data[0]) | |||
| loadModelFile(data[0]) | |||
| } | |||
| @@ -361,7 +361,7 @@ export default { | |||
| return "Pytorch"; | |||
| }else if(model.Engine == 1 || model.Engine == 121){ | |||
| return "TensorFlow"; | |||
| }else if(model.Engine == 2 || model.Engine == 122){ | |||
| }else if(model.Engine == 2 || model.Engine == 122 || model.Engine == 35){ | |||
| return "MindSpore"; | |||
| }else if(model.Engine == 4){ | |||
| return "PaddlePaddle"; | |||