diff --git a/README.md b/README.md
index b6e7892c9..061ece70c 100644
--- a/README.md
+++ b/README.md
@@ -46,3 +46,6 @@
- 点击[这里](https://git.openi.org.cn/OpenI/aiforge/issues)在线提交问题(点击页面右上角绿色按钮**创建任务**)
- 加入微信群实时交流,获得进一步的支持
+
+## 启智社区小白训练营:
+- 结合案例给大家详细讲解如何使用社区平台,帮助无技术背景的小白成长为启智社区达人 (https://git.openi.org.cn/zeizei/OpenI_Learning)
diff --git a/models/attachment.go b/models/attachment.go
index d217a61a4..fd1df9e43 100755
--- a/models/attachment.go
+++ b/models/attachment.go
@@ -439,6 +439,19 @@ func GetModelArtsUserAttachments(userID int64) ([]*AttachmentUsername, error) {
return getModelArtsUserAttachments(x, userID)
}
+func getModelArtsTrainAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) {
+ attachments := make([]*AttachmentUsername, 0, 10)
+ if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+
+ "= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?) and attachment.decompress_state = ?", TypeCloudBrainTwo, userID, false, DecompressStateDone).Find(&attachments); err != nil {
+ return nil, err
+ }
+ return attachments, nil
+}
+
+func GetModelArtsTrainAttachments(userID int64) ([]*AttachmentUsername, error) {
+ return getModelArtsTrainAttachments(x, userID)
+}
+
func CanDelAttachment(isSigned bool, user *User, attach *Attachment) bool {
if !isSigned {
return false
diff --git a/models/error.go b/models/error.go
index 9d1c68658..46917e15e 100755
--- a/models/error.go
+++ b/models/error.go
@@ -1999,3 +1999,16 @@ func IsErrJobNotExist(err error) bool {
func (err ErrJobNotExist) Error() string {
return fmt.Sprintf("the job does not exist")
}
+
+type ErrTagNotExist struct {
+ TagID int64
+}
+
+func (err ErrTagNotExist) Error() string {
+ return fmt.Sprintf("the tag does not exist")
+}
+
+func IsErrTagNotExist(err error) bool {
+ _, ok := err.(ErrTagNotExist)
+ return ok
+}
diff --git a/models/models.go b/models/models.go
index e8a71bbd8..a72ebe5db 100755
--- a/models/models.go
+++ b/models/models.go
@@ -134,6 +134,8 @@ func init() {
new(BlockChain),
new(RecommendOrg),
new(AiModelManage),
+ new(OfficialTag),
+ new(OfficialTagRepos),
)
tablesStatistic = append(tablesStatistic,
diff --git a/models/repo_tag.go b/models/repo_tag.go
new file mode 100644
index 000000000..76740bd76
--- /dev/null
+++ b/models/repo_tag.go
@@ -0,0 +1,163 @@
+package models
+
+import (
+ "code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/timeutil"
+ "fmt"
+)
+
+type OfficialTag struct {
+ ID int64 `xorm:"pk autoincr"`
+ Name string `xorm:"NOT NULL"`
+ Code string `xorm:"NOT NULL"`
+ Limit int `xorm:"NOT NULL default(-1)"`
+ Status int `xorm:"NOT NULL default(0)"`
+ CreatedUnix timeutil.TimeStamp `xorm:"created"`
+ UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
+}
+
+type OfficialTagRepos struct {
+ ID int64 `xorm:"pk autoincr"`
+ OrgID int64 `xorm:"NOT NULL INDEX"`
+ TagID int64 `xorm:"NOT NULL"`
+ RepoID int64 `xorm:"NOT NULL INDEX"`
+ CreatedUnix timeutil.TimeStamp `xorm:"created"`
+ UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
+}
+
+type TagReposBrief struct {
+ RepoID int64
+ RepoName string
+ TagID int64
+}
+
+type TagReposSelected struct {
+ RepoID int64
+ RepoName string
+ Selected bool
+}
+
+type TagsDetail struct {
+ TagId int64
+ TagName string
+ TagLimit int
+ RepoList []Repository
+}
+
+func GetTagByID(id int64) (*OfficialTag, error) {
+ r := &OfficialTag{
+ ID: id,
+ }
+ has, err := x.Get(r)
+ if err != nil {
+ return nil, err
+ } else if !has {
+ return nil, ErrTagNotExist{0}
+ }
+ return r, nil
+}
+
+func UpdateTagReposByID(tagID, orgID int64, repoIdList []int64) error {
+ sess := x.NewSession()
+ defer sess.Close()
+
+ if err := sess.Begin(); err != nil {
+ return fmt.Errorf("UpdateTagReposByID[tagId: %d, orgID: %d,error:%v", tagID, orgID, err)
+ }
+ //delete old tag repos
+ r := &OfficialTagRepos{
+ TagID: tagID,
+ OrgID: orgID,
+ }
+ _, err := sess.Delete(r)
+ if err != nil {
+ return err
+ }
+
+ if len(repoIdList) == 0 {
+ return sess.Commit()
+ }
+
+ //add new tag repos
+ data := make([]*OfficialTagRepos, 0)
+ for _, repoId := range repoIdList {
+ data = append(data, &OfficialTagRepos{
+ OrgID: orgID,
+ TagID: tagID,
+ RepoID: repoId,
+ })
+ }
+ _, err = sess.Insert(&data)
+ if err != nil {
+ sess.Rollback()
+ return err
+ }
+ return sess.Commit()
+}
+
+func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) {
+ t := make([]TagReposBrief, 0)
+ const SQLCmd = "select t1.id as repo_id,t1.name as repo_name,t2.id as tag_id from repository t1 left join official_tag_repos t2 on (t1.id = t2.repo_id and t2.tag_id = ?) where t1.owner_id = ? and t1.is_private = false order by t1.updated_unix desc"
+
+ if err := x.SQL(SQLCmd, tagID, orgID).Find(&t); err != nil {
+ return nil, err
+ }
+ r := make([]TagReposSelected, 0)
+ for _, v := range t {
+ selected := false
+ if v.TagID > 0 {
+ selected = true
+ }
+ r = append(r, TagReposSelected{
+ RepoID: v.RepoID,
+ RepoName: v.RepoName,
+ Selected: selected,
+ })
+ }
+ return r, nil
+}
+
+func GetAllOfficialTagRepos(orgID int64, isOwner bool) ([]TagsDetail, error) {
+ result := make([]TagsDetail, 0)
+ tags, err := GetAllOfficialTags()
+ if err != nil {
+ return nil, err
+ }
+ for _, tag := range tags {
+ repos, err := GetOfficialTagDetail(orgID, tag.ID)
+ if err != nil {
+ return nil, err
+ }
+ if len(repos) == 0 && !isOwner {
+ continue
+ }
+ result = append(result, TagsDetail{
+ TagId: tag.ID,
+ TagName: tag.Name,
+ TagLimit: tag.Limit,
+ RepoList: repos,
+ })
+ }
+ return result, nil
+}
+
+func GetOfficialTagDetail(orgID, tagId int64) ([]Repository, error) {
+ t := make([]Repository, 0)
+ const SQLCmd = "select t2.* from official_tag_repos t1 inner join repository t2 on t1.repo_id = t2.id where t1.org_id = ? and t1.tag_id=? order by t2.updated_unix desc"
+
+ if err := x.SQL(SQLCmd, orgID, tagId).Find(&t); err != nil {
+ return nil, err
+ }
+ return t, nil
+}
+
+func GetAllOfficialTags() ([]OfficialTag, error) {
+ //todo redis?
+ o := make([]OfficialTag, 0)
+ err := x.Where("status = ?", 0).OrderBy("updated_unix desc").Find(&o)
+ if err != nil {
+ log.Error("GetAllOfficialTags error,%v", err)
+ return nil, err
+ }
+ return o, nil
+}
diff --git a/modules/auth/org.go b/modules/auth/org.go
index 20e2b0999..9642e1ce6 100644
--- a/modules/auth/org.go
+++ b/modules/auth/org.go
@@ -70,3 +70,7 @@ type CreateTeamForm struct {
func (f *CreateTeamForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
return validate(errs, ctx.Data, f, ctx.Locale)
}
+
+type SubmitReposOfTagForm struct {
+ RepoList []int64
+}
diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go
index cf22d7269..5891182c0 100755
--- a/modules/modelarts/modelarts.go
+++ b/modules/modelarts/modelarts.go
@@ -240,14 +240,15 @@ func GenerateTask(ctx *context.Context, jobName, uuid, description, flavor strin
}
err = models.CreateCloudbrain(&models.Cloudbrain{
- Status: string(models.JobWaiting),
- UserID: ctx.User.ID,
- RepoID: ctx.Repo.Repository.ID,
- JobID: jobResult.ID,
- JobName: jobName,
- JobType: string(models.JobTypeDebug),
- Type: models.TypeCloudBrainTwo,
- Uuid: uuid,
+ Status: string(models.JobWaiting),
+ UserID: ctx.User.ID,
+ RepoID: ctx.Repo.Repository.ID,
+ JobID: jobResult.ID,
+ JobName: jobName,
+ JobType: string(models.JobTypeDebug),
+ Type: models.TypeCloudBrainTwo,
+ Uuid: uuid,
+ ComputeResource: models.NPUResource,
})
if err != nil {
diff --git a/modules/repository/elk_pagedata.go b/modules/repository/elk_pagedata.go
index 1454f0364..ecdbff078 100644
--- a/modules/repository/elk_pagedata.go
+++ b/modules/repository/elk_pagedata.go
@@ -21,7 +21,8 @@ type Fields struct {
Format string `json:"format"`
}
type MatchPhrase struct {
- Message string `json:"message"`
+ Message string `json:"message,omitempty"`
+ TagName string `json:"tagName.keyword,omitempty"`
}
type Should struct {
MatchPhrase MatchPhrase `json:"match_phrase"`
@@ -144,7 +145,7 @@ func ProjectViewInit(User string, Project string, Gte string, Lte string) (proje
inputStruct.Batch[0].Request.Params.Body.Fields = make([]Fields, 1)
inputStruct.Batch[0].Request.Params.Body.Fields[0].Field = setting.TimeField
inputStruct.Batch[0].Request.Params.Body.Fields[0].Format = setting.ElkTimeFormat
- inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter = make([]Filter, 3)
+ inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter = make([]Filter, 4)
//限定查询时间
var timeRange Range
timeRange.Timestamptest.Gte = Gte
@@ -159,6 +160,24 @@ func ProjectViewInit(User string, Project string, Gte string, Lte string) (proje
var projectName FilterMatchPhrase
projectName.ProjectName = Project
inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter[2].FilterMatchPhrase = &projectName
+ //限定页面
+ var bool Bool
+ bool.Should = make([]Should, 14)
+ bool.Should[0].MatchPhrase.TagName = "%{[request][3]}"
+ bool.Should[1].MatchPhrase.TagName = "datasets?type=0"
+ bool.Should[2].MatchPhrase.TagName = "datasets?type=1"
+ bool.Should[3].MatchPhrase.TagName = "issues"
+ bool.Should[4].MatchPhrase.TagName = "labels"
+ bool.Should[5].MatchPhrase.TagName = "pulls"
+ bool.Should[6].MatchPhrase.TagName = "wiki"
+ bool.Should[7].MatchPhrase.TagName = "activity"
+ bool.Should[8].MatchPhrase.TagName = "cloudbrain"
+ bool.Should[9].MatchPhrase.TagName = "modelarts"
+ bool.Should[10].MatchPhrase.TagName = "blockchain"
+ bool.Should[11].MatchPhrase.TagName = "watchers"
+ bool.Should[12].MatchPhrase.TagName = "stars"
+ bool.Should[13].MatchPhrase.TagName = "forks"
+ inputStruct.Batch[0].Request.Params.Body.Query.BoolIn.Filter[3].Bool = &bool
return inputStruct
}
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index e48f0d5ff..619255bc3 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -222,6 +222,7 @@ contributors = Contributors
[explore]
repos = Repositories
+select_repos = Select the project
users = Users
organizations = Organizations
images = CloudImages
@@ -234,6 +235,8 @@ org_no_results = No matching organizations found.
code_no_results = No source code matching your search term found.
code_search_results = Search results for '%s'
code_last_indexed_at = Last indexed %s
+save=save
+cancel=cancel
[auth]
create_new_account = Register Account
@@ -905,6 +908,8 @@ model.manage.F1 = F1
model.manage.Precision = Precision
model.manage.Recall = Recall
model.manage.sava_model = Sava Model
+model.manage.model_manage = ModelManage
+model.manage.model_accuracy = Model Accuracy
template.items = Template Items
template.git_content = Git Content (Default Branch)
diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini
index c56578e7a..b999a69d2 100755
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locale/locale_zh-CN.ini
@@ -224,6 +224,7 @@ contributors=贡献者
[explore]
repos=项目
+select_repos=精选项目
users=用户
organizations=组织
images = 云脑镜像
@@ -238,6 +239,8 @@ org_no_results=未找到匹配的组织。
code_no_results=未找到与搜索字词匹配的源代码。
code_search_results=“%s” 的搜索结果是
code_last_indexed_at=最后索引于 %s
+save=保存
+cancel=取消
[auth]
create_new_account=注册帐号
@@ -914,6 +917,8 @@ model.manage.F1 = F1值
model.manage.Precision = 精确率
model.manage.Recall = 召回率
model.manage.sava_model = 保存模型
+model.manage.model_manage = 模型管理
+model.manage.model_accuracy = 模型精度
template.items=模板选项
template.git_content=Git数据(默认分支)
diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go
index 2b6e45461..c9a214a3a 100755
--- a/routers/api/v1/repo/modelarts.go
+++ b/routers/api/v1/repo/modelarts.go
@@ -7,7 +7,6 @@ package repo
import (
"net/http"
- "os"
"strconv"
"strings"
@@ -15,8 +14,8 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/modelarts"
- "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
+ routerRepo "code.gitea.io/gitea/routers/repo"
)
func GetModelArtsNotebook(ctx *context.APIContext) {
@@ -258,7 +257,7 @@ func DelTrainJobVersion(ctx *context.APIContext) {
}
}
} else { //已删除该任务下的所有版本
- deleteJobStorage(task.JobName)
+ routerRepo.DeleteJobStorage(task.JobName)
}
ctx.JSON(http.StatusOK, map[string]interface{}{
diff --git a/routers/org/home.go b/routers/org/home.go
index b11c179c1..df600d96d 100755
--- a/routers/org/home.go
+++ b/routers/org/home.go
@@ -130,5 +130,13 @@ func Home(ctx *context.Context) {
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
+ //find org tag info
+ tags, err := models.GetAllOfficialTagRepos(org.ID, ctx.Org.IsOwner)
+ if err != nil {
+ ctx.ServerError("GetAllOfficialTagRepos", err)
+ return
+ }
+
+ ctx.Data["tags"] = tags
ctx.HTML(200, tplOrgHome)
}
diff --git a/routers/org/tag.go b/routers/org/tag.go
new file mode 100644
index 000000000..37d5b1c8f
--- /dev/null
+++ b/routers/org/tag.go
@@ -0,0 +1,90 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Copyright 2020 The Gitea Authors.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package org
+
+import (
+ "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/auth"
+ "code.gitea.io/gitea/modules/context"
+ "errors"
+ "strconv"
+)
+
+const DefaultOrgTagLimit = -1
+
+// SubmitTags submit repos of org tag
+func SubmitTags(ctx *context.Context, form auth.SubmitReposOfTagForm) {
+ if !ctx.Org.IsOwner {
+ ctx.ServerError("UpdateTagReposByID", errors.New("no access to submit tags"))
+ return
+ }
+ tag := getTagFromContext(ctx)
+ if ctx.Written() {
+ return
+ }
+ if tag.Limit != DefaultOrgTagLimit && len(form.RepoList) > tag.Limit {
+ ctx.ServerError("UpdateTagReposByID", errors.New("tags size over limit"))
+ return
+ }
+ err := models.UpdateTagReposByID(tag.ID, ctx.Org.Organization.ID, form.RepoList)
+ if err != nil {
+ ctx.ServerError("UpdateTagReposByID", err)
+ return
+ }
+
+ ctx.JSON(200, map[string]interface{}{
+ "code": "00",
+ "msg": "success",
+ })
+}
+
+// GetTagRepos get repos under org tag
+func GetTagRepos(ctx *context.Context) {
+ if !ctx.Org.IsOwner {
+ ctx.ServerError("GetTagRepos", errors.New("no access to get tags"))
+ return
+ }
+ tag := getTagFromContext(ctx)
+ if ctx.Written() {
+ return
+ }
+
+ r, err := models.GetTagRepos(tag.ID, ctx.Org.Organization.ID)
+ if err != nil {
+ ctx.ServerError("GetTagRepos", err)
+ return
+ }
+
+ ctx.JSON(200, map[string]interface{}{
+ "code": "00",
+ "msg": "success",
+ "data": r,
+ })
+}
+
+// getTagFromContext finds out tag info From context.
+func getTagFromContext(ctx *context.Context) *models.OfficialTag {
+ var tag *models.OfficialTag
+ var err error
+
+ tagIdStr := ctx.Query("tagId")
+ if len(tagIdStr) == 0 {
+ ctx.ServerError("GetTagInfo", errors.New("tag is not exist"))
+ return nil
+ }
+ tagId, _ := strconv.ParseInt(tagIdStr, 10, 32)
+ tag, err = models.GetTagByID(tagId)
+ if err != nil {
+ if models.IsErrTagNotExist(err) {
+ ctx.NotFound("GetTagInfo", err)
+ } else {
+ ctx.ServerError("GetTagInfo", err)
+ }
+ return nil
+ }
+
+ return tag
+}
diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go
index 3c60396b6..ab3303408 100755
--- a/routers/repo/cloudbrain.go
+++ b/routers/repo/cloudbrain.go
@@ -277,6 +277,13 @@ func CloudBrainRestart(ctx *context.Context) {
break
}
+ if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin()){
+ log.Error("the user has no right ro restart the job", task.JobName, ctx.Data["MsgID"])
+ resultCode = "-1"
+ errorMsg = "you have no right to restart the job"
+ break
+ }
+
count, err := models.GetCloudbrainCountByUserID(ctx.User.ID)
if err != nil {
log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"])
@@ -287,7 +294,7 @@ func CloudBrainRestart(ctx *context.Context) {
if count >= 1 {
log.Error("the user already has running or waiting task", ctx.Data["MsgID"])
resultCode = "-1"
- errorMsg = "the user already has running or waiting task"
+ errorMsg = "you have already a running or waiting task, can not create more"
break
}
}
diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go
index d370bd5d5..41a9b3ff6 100755
--- a/routers/repo/modelarts.go
+++ b/routers/repo/modelarts.go
@@ -12,11 +12,10 @@ import (
"strings"
"time"
- "code.gitea.io/gitea/modules/cloudbrain"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base"
+ "code.gitea.io/gitea/modules/cloudbrain"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
@@ -55,12 +54,9 @@ func DebugJobIndex(ctx *context.Context) {
page = 1
}
debugType := modelarts.DebugType
- jobType := string(models.JobTypeDebug)
if debugListType == models.GPUResource {
debugType = models.TypeCloudBrainOne
- jobType = ""
- }
- if debugListType == models.NPUResource {
+ } else if debugListType == models.NPUResource {
debugType = models.TypeCloudBrainTwo
}
@@ -69,9 +65,8 @@ func DebugJobIndex(ctx *context.Context) {
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
- RepoID: repo.ID,
- Type: debugType,
- JobType: jobType,
+ RepoID: repo.ID,
+ Type: debugType,
})
if err != nil {
ctx.ServerError("Get debugjob faild:", err)
@@ -79,7 +74,7 @@ func DebugJobIndex(ctx *context.Context) {
}
for i, task := range ciTasks {
- ciTasks[i].CanDebug = cloudbrain.CanCreateOrDebugJob(ctx)
+ ciTasks[i].CanDebug = cloudbrain.CanModifyJob(ctx, &task.Cloudbrain)
ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)
ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource
}
@@ -154,7 +149,7 @@ func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsNotebookForm)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookNew, &form)
return
}
- ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")
+ ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all")
}
func NotebookShow(ctx *context.Context) {
@@ -253,6 +248,13 @@ func NotebookManage(ctx *context.Context) {
errorMsg = "the job is not running"
break
}
+
+ if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin() && !ctx.IsUserRepoOwner()) {
+ log.Error("the user has no right ro stop the job", task.JobName, ctx.Data["MsgID"])
+ resultCode = "-1"
+ errorMsg = "you have no right to stop the job"
+ break
+ }
} else if action == models.ActionRestart {
if task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsCreateFailed) {
log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"])
@@ -261,6 +263,13 @@ func NotebookManage(ctx *context.Context) {
break
}
+ if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin()) {
+ log.Error("the user has no right ro restart the job", task.JobName, ctx.Data["MsgID"])
+ resultCode = "-1"
+ errorMsg = "you have no right to restart the job"
+ break
+ }
+
count, err := models.GetCloudbrainNotebookCountByUserID(ctx.User.ID)
if err != nil {
log.Error("GetCloudbrainNotebookCountByUserID failed:%v", err, ctx.Data["MsgID"])
@@ -416,7 +425,7 @@ func trainJobNewDataPrepare(ctx *context.Context) error {
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = jobName
- attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
+ attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err)
return err
@@ -485,7 +494,7 @@ func trainJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArts
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = jobName
- attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
+ attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err)
return err
@@ -573,7 +582,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error {
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = task.JobName
- attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
+ attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err)
return err
@@ -662,7 +671,7 @@ func versionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrai
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = task.JobName
- attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
+ attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err)
return err
@@ -1426,6 +1435,11 @@ func TrainJobDel(ctx *context.Context) {
}
}
+ //删除存储
+ if len(VersionListTasks) > 0 {
+ DeleteJobStorage(VersionListTasks[0].JobName)
+ }
+
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/train-job")
}
@@ -2001,3 +2015,20 @@ func ResultDownload(ctx *context.Context) {
}
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently)
}
+func DeleteJobStorage(jobName string) error {
+ //delete local
+ localJobPath := setting.JobPath + jobName
+ err := os.RemoveAll(localJobPath)
+ if err != nil {
+ log.Error("RemoveAll(%s) failed:%v", localJobPath, err)
+ }
+
+ //delete oss
+ dirPath := setting.CodePathPrefix + jobName + "/"
+ err = storage.ObsRemoveObject(setting.Bucket, dirPath)
+ if err != nil {
+ log.Error("ObsRemoveObject(%s) failed:%v", localJobPath, err)
+ }
+
+ return nil
+}
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index a89704234..cfaa81cea 100755
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -627,6 +627,10 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/org", func() {
m.Group("/:org", func() {
m.Get("/members", org.Members)
+ m.Group("/org_tag", func() {
+ m.Get("/repo_list", org.GetTagRepos)
+ m.Post("/repo_submit", bindIgnErr(auth.SubmitReposOfTagForm{}), org.SubmitTags)
+ })
}, context.OrgAssignment())
})
m.Group("/org", func() {
@@ -964,11 +968,11 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/cloudbrain", func() {
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow)
- m.Get("/debug", reqRepoCloudBrainWriter, repo.CloudBrainDebug)
+ m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDebug)
m.Post("/commit_image", cloudbrain.AdminOrOwnerOrJobCreaterRight, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage)
m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop)
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainDel)
- m.Post("/restart", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainRestart)
+ m.Post("/restart", reqRepoCloudBrainWriter, repo.CloudBrainRestart)
m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate)
m.Get("/models", reqRepoCloudBrainReader, repo.CloudBrainShowModels)
m.Get("/download_model", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainDownloadModel)
@@ -1005,8 +1009,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/notebook", func() {
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainReader, repo.NotebookShow)
- m.Get("/debug", reqRepoCloudBrainWriter, repo.NotebookDebug)
- m.Post("/:action", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.NotebookManage)
+ m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.NotebookDebug)
+ m.Post("/:action", reqRepoCloudBrainWriter, repo.NotebookManage)
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.NotebookDel)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.NotebookNew)
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index 7e9970d2b..e03c28a9e 100755
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -20,10 +20,11 @@
最多可选9个公开项目
+准确率 | +{{$.i18n.Tr "repo.model.manage.Accuracy"}} | |
精确率 | +{{$.i18n.Tr "repo.model.manage.Precision"}} | |
召回率 | +{{$.i18n.Tr "repo.model.manage.Recall"}} |