| @@ -11,30 +11,30 @@ import ( | |||
| ) | |||
| type AiModelManage struct { | |||
| ID string `xorm:"pk"` | |||
| Name string `xorm:"NOT NULL"` | |||
| Version string `xorm:"NOT NULL"` | |||
| VersionCount int `xorm:"NOT NULL DEFAULT 0"` | |||
| New int `xorm:"NOT NULL"` | |||
| Type int `xorm:"NOT NULL"` | |||
| Size int64 `xorm:"NOT NULL"` | |||
| Description string `xorm:"varchar(2000)"` | |||
| Label string `xorm:"varchar(1000)"` | |||
| Path string `xorm:"varchar(400) NOT NULL"` | |||
| DownloadCount int `xorm:"NOT NULL DEFAULT 0"` | |||
| Engine int64 `xorm:"NOT NULL DEFAULT 0"` | |||
| Status int `xorm:"NOT NULL DEFAULT 0"` | |||
| Accuracy string `xorm:"varchar(1000)"` | |||
| AttachmentId string `xorm:"NULL"` | |||
| RepoId int64 `xorm:"NULL"` | |||
| CodeBranch string `xorm:"varchar(400) NULL"` | |||
| CodeCommitID string `xorm:"NULL"` | |||
| UserId int64 `xorm:"NOT NULL"` | |||
| UserName string `xorm:"NULL"` | |||
| ID string `xorm:"pk"` | |||
| Name string `xorm:"INDEX NOT NULL"` | |||
| Version string `xorm:"NOT NULL"` | |||
| VersionCount int `xorm:"NOT NULL DEFAULT 0"` | |||
| New int `xorm:"NOT NULL"` | |||
| Type int `xorm:"NOT NULL"` | |||
| Size int64 `xorm:"NOT NULL"` | |||
| Description string `xorm:"varchar(2000)"` | |||
| Label string `xorm:"varchar(1000)"` | |||
| Path string `xorm:"varchar(400) NOT NULL"` | |||
| DownloadCount int `xorm:"NOT NULL DEFAULT 0"` | |||
| Engine int64 `xorm:"NOT NULL DEFAULT 0"` | |||
| Status int `xorm:"NOT NULL DEFAULT 0"` | |||
| Accuracy string `xorm:"varchar(1000)"` | |||
| AttachmentId string `xorm:"NULL"` | |||
| RepoId int64 `xorm:"INDEX NULL"` | |||
| CodeBranch string `xorm:"varchar(400) NULL"` | |||
| CodeCommitID string `xorm:"NULL"` | |||
| UserId int64 `xorm:"NOT NULL"` | |||
| UserName string | |||
| UserRelAvatarLink string `xorm:"NULL"` | |||
| TrainTaskInfo string `xorm:"text NULL"` | |||
| CreatedUnix timeutil.TimeStamp `xorm:"created"` | |||
| UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | |||
| UpdatedUnix timeutil.TimeStamp `xorm:"updated"` | |||
| IsCanOper bool | |||
| } | |||
| @@ -197,7 +197,6 @@ func QueryModel(opts *AiModelQueryOptions) ([]*AiModelManage, int64, error) { | |||
| Find(&aiModelManages); err != nil { | |||
| return nil, 0, fmt.Errorf("Find: %v", err) | |||
| } | |||
| sess.Close() | |||
| return aiModelManages, count, nil | |||
| } | |||
| @@ -433,9 +433,6 @@ var ( | |||
| AuthUser string | |||
| AuthPassword string | |||
| //home page | |||
| RecommentRepoAddr string | |||
| //labelsystem config | |||
| LabelTaskName string | |||
| LabelDatasetDeleteQueue string | |||
| @@ -1232,9 +1229,6 @@ func NewContext() { | |||
| LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue") | |||
| DecompressOBSTaskName = sec.Key("DecompressOBSTaskName").MustString("LabelDecompressOBSQueue") | |||
| sec = Cfg.Section("homepage") | |||
| RecommentRepoAddr = sec.Key("Address").MustString("https://git.openi.org.cn/OpenIOSSG/promote/raw/branch/master/") | |||
| sec = Cfg.Section("cloudbrain") | |||
| CBAuthUser = sec.Key("USER").MustString("") | |||
| CBAuthPassword = sec.Key("PWD").MustString("") | |||
| @@ -7,8 +7,6 @@ package routers | |||
| import ( | |||
| "bytes" | |||
| "fmt" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| @@ -513,43 +511,3 @@ func NotFound(ctx *context.Context) { | |||
| ctx.Data["Title"] = "Page Not Found" | |||
| ctx.NotFound("home.NotFound", nil) | |||
| } | |||
| func RecommendOrgFromPromote(ctx *context.Context) { | |||
| url := setting.RecommentRepoAddr + "organizations" | |||
| recommendFromPromote(ctx, url) | |||
| } | |||
| func recommendFromPromote(ctx *context.Context, url string) { | |||
| resp, err := http.Get(url) | |||
| if err != nil { | |||
| log.Info("Get organizations url error=" + err.Error()) | |||
| ctx.ServerError("QueryTrainJobList:", err) | |||
| return | |||
| } | |||
| bytes, err := ioutil.ReadAll(resp.Body) | |||
| resp.Body.Close() | |||
| if err != nil { | |||
| log.Info("Get organizations url error=" + err.Error()) | |||
| ctx.ServerError("QueryTrainJobList:", err) | |||
| return | |||
| } | |||
| allLineStr := string(bytes) | |||
| lines := strings.Split(allLineStr, "\n") | |||
| result := make([]string, len(lines)) | |||
| for i, line := range lines { | |||
| tmpIndex := strings.Index(line, ".") | |||
| log.Info("i=" + fmt.Sprint(i) + " line=" + line + " tmpIndex=" + fmt.Sprint(tmpIndex)) | |||
| if tmpIndex == -1 { | |||
| result[i] = strings.Trim(line, " ") | |||
| } else { | |||
| result[i] = strings.Trim(line[tmpIndex+1:], " ") | |||
| } | |||
| } | |||
| ctx.JSON(http.StatusOK, result) | |||
| } | |||
| func RecommendRepoFromPromote(ctx *context.Context) { | |||
| url := setting.RecommentRepoAddr + "projects" | |||
| recommendFromPromote(ctx, url) | |||
| } | |||
| @@ -28,7 +28,6 @@ const ( | |||
| func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, ctx *context.Context) error { | |||
| aiTask, err := models.GetCloudbrainByJobIDAndVersionName(jobId, versionName) | |||
| //aiTask, err := models.GetCloudbrainByJobID(jobId) | |||
| if err != nil { | |||
| log.Info("query task error." + err.Error()) | |||
| return err | |||
| @@ -71,7 +70,6 @@ func saveModelByParameters(jobId string, versionName string, name string, versio | |||
| log.Info("accuracyJson=" + string(accuracyJson)) | |||
| aiTaskJson, _ := json.Marshal(aiTask) | |||
| //taskConfigInfo,err := models.GetCloudbrainByJobIDAndVersionName(jobId,aiTask.VersionName) | |||
| model := &models.AiModelManage{ | |||
| ID: id, | |||
| Version: version, | |||
| @@ -86,7 +84,6 @@ func saveModelByParameters(jobId string, versionName string, name string, versio | |||
| AttachmentId: aiTask.Uuid, | |||
| RepoId: aiTask.RepoID, | |||
| UserId: ctx.User.ID, | |||
| UserName: ctx.User.Name, | |||
| UserRelAvatarLink: ctx.User.RelAvatarLink(), | |||
| CodeBranch: aiTask.BranchName, | |||
| CodeCommitID: aiTask.CommitID, | |||
| @@ -399,11 +396,22 @@ func ShowOneVersionOtherModel(ctx *context.Context) { | |||
| repoId := ctx.Repo.Repository.ID | |||
| name := ctx.Query("name") | |||
| aimodels := models.QueryModelByName(name, repoId) | |||
| for _, model := range aimodels { | |||
| userIds := make([]int64, len(aimodels)) | |||
| for i, model := range aimodels { | |||
| log.Info("model=" + model.Name) | |||
| log.Info("model.UserId=" + fmt.Sprint(model.UserId)) | |||
| model.IsCanOper = isOper(ctx, model.UserId) | |||
| userIds[i] = model.UserId | |||
| } | |||
| userNames, err := models.GetUserNamesByIDs(userIds) | |||
| if err == nil { | |||
| for i, model := range aimodels { | |||
| model.UserName = userNames[i] | |||
| } | |||
| } | |||
| if len(aimodels) > 0 { | |||
| ctx.JSON(200, aimodels[1:]) | |||
| } else { | |||
| @@ -431,7 +439,7 @@ func isOper(ctx *context.Context, modelUserId int64) bool { | |||
| if ctx.User == nil { | |||
| return false | |||
| } | |||
| if ctx.User.IsAdmin || ctx.Repo.IsAdmin() || ctx.Repo.IsOwner() || ctx.User.ID == modelUserId { | |||
| if ctx.User.IsAdmin || ctx.Repo.IsOwner() || ctx.User.ID == modelUserId { | |||
| return true | |||
| } | |||
| return false | |||
| @@ -463,10 +471,19 @@ func ShowModelPageInfo(ctx *context.Context) { | |||
| return | |||
| } | |||
| for _, model := range modelResult { | |||
| userIds := make([]int64, len(modelResult)) | |||
| for i, model := range modelResult { | |||
| log.Info("model=" + model.Name) | |||
| log.Info("model.UserId=" + fmt.Sprint(model.UserId)) | |||
| model.IsCanOper = isOper(ctx, model.UserId) | |||
| userIds[i] = model.UserId | |||
| } | |||
| userNames, err := models.GetUserNamesByIDs(userIds) | |||
| if err == nil { | |||
| for i, model := range modelResult { | |||
| model.UserName = userNames[i] | |||
| } | |||
| } | |||
| mapInterface := make(map[string]interface{}) | |||
| @@ -315,8 +315,6 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }) | |||
| m.Get("/", routers.Home) | |||
| m.Get("/dashboard", routers.Dashboard) | |||
| m.Get("/recommend/org", routers.RecommendOrgFromPromote) | |||
| m.Get("/recommend/repo", routers.RecommendRepoFromPromote) | |||
| m.Group("/explore", func() { | |||
| m.Get("", func(ctx *context.Context) { | |||
| ctx.Redirect(setting.AppSubURL + "/explore/repos") | |||