Browse Source

数据集过滤只限制训练任务

tags/v1.21.12.2^2
liuzx 3 years ago
parent
commit
e95597f30b
2 changed files with 19 additions and 6 deletions
  1. +14
    -1
      models/attachment.go
  2. +5
    -5
      routers/repo/modelarts.go

+ 14
- 1
models/attachment.go View File

@@ -429,7 +429,7 @@ func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) {
func getModelArtsUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { func getModelArtsUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) {
attachments := make([]*AttachmentUsername, 0, 10) attachments := make([]*AttachmentUsername, 0, 10)
if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ 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 {
"= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?)", TypeCloudBrainTwo, userID, false).Find(&attachments); err != nil {
return nil, err return nil, err
} }
return attachments, nil return attachments, nil
@@ -439,6 +439,19 @@ func GetModelArtsUserAttachments(userID int64) ([]*AttachmentUsername, error) {
return getModelArtsUserAttachments(x, userID) 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 { func CanDelAttachment(isSigned bool, user *User, attach *Attachment) bool {
if !isSigned { if !isSigned {
return false return false


+ 5
- 5
routers/repo/modelarts.go View File

@@ -320,7 +320,7 @@ func NotebookDel(ctx *context.Context) {
return return
} }


if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped){
if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) {
log.Error("the job(%s) has not been stopped", task.JobName) log.Error("the job(%s) has not been stopped", task.JobName)
ctx.ServerError("the job has not been stopped", errors.New("the job has not been stopped")) ctx.ServerError("the job has not been stopped", errors.New("the job has not been stopped"))
return return
@@ -411,7 +411,7 @@ func trainJobNewDataPrepare(ctx *context.Context) error {
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = jobName ctx.Data["job_name"] = jobName


attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil { if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err) ctx.ServerError("GetAllUserAttachments failed:", err)
return err return err
@@ -480,7 +480,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:] var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = jobName ctx.Data["job_name"] = jobName


attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil { if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err) ctx.ServerError("GetAllUserAttachments failed:", err)
return err return err
@@ -568,7 +568,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error {
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = task.JobName ctx.Data["job_name"] = task.JobName


attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil { if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err) ctx.ServerError("GetAllUserAttachments failed:", err)
return err return err
@@ -657,7 +657,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:] var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
ctx.Data["job_name"] = task.JobName ctx.Data["job_name"] = task.JobName


attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID)
attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID)
if err != nil { if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err) ctx.ServerError("GetAllUserAttachments failed:", err)
return err return err


Loading…
Cancel
Save