|
|
@@ -1245,6 +1245,15 @@ func StopJobsByRepoID(repoID int64) { |
|
|
|
StopJobs(cloudBrains) |
|
|
|
} |
|
|
|
|
|
|
|
func DeleteJobsByRepoID(repoID int64) { |
|
|
|
cloudBrains, err := models.GetCloudbrainsNeededDeleteByRepoID(repoID) |
|
|
|
if err != nil { |
|
|
|
log.Warn("Failed to get cloudBrain info", err) |
|
|
|
return |
|
|
|
} |
|
|
|
DeleteJobs(cloudBrains) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
*/ |
|
|
@@ -1280,6 +1289,36 @@ func StopJobs(cloudBrains []*models.Cloudbrain) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func DeleteJobs(cloudBrains []*models.Cloudbrain) { |
|
|
|
for _, taskInfo := range cloudBrains { |
|
|
|
err := models.DeleteJob(taskInfo) |
|
|
|
if err != nil { |
|
|
|
log.Warn("Failed to DeleteJob:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
if taskInfo.Type == models.TypeCloudBrainOne { |
|
|
|
cloudbrain.DelCloudBrainJob(taskInfo.JobName) |
|
|
|
DeleteCloudbrainJobStorage(taskInfo.JobName, models.TypeCloudBrainOne) |
|
|
|
} |
|
|
|
if taskInfo.Type == models.TypeCloudBrainTwo { |
|
|
|
if taskInfo.JobType == string(models.JobTypeTrain) || taskInfo.JobType == string(models.JobTypeInference) { |
|
|
|
|
|
|
|
modelarts.DelTrainJob(taskInfo.JobID) |
|
|
|
DeleteJobStorage(taskInfo.JobName) |
|
|
|
} |
|
|
|
if taskInfo.JobType == string(models.JobTypeDebug) { |
|
|
|
modelarts.DelNotebook2(taskInfo.JobID) |
|
|
|
} |
|
|
|
} |
|
|
|
if taskInfo.Type == models.TypeC2Net { |
|
|
|
if taskInfo.JobType == string(models.JobTypeTrain) { |
|
|
|
cloudbrain.DelCloudBrainJob(taskInfo.JobName) |
|
|
|
DeleteCloudbrainJobStorage(taskInfo.JobName, models.TypeCloudBrainOne) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func retry(attempts int, sleep time.Duration, f func() error) (err error) { |
|
|
|
for i := 0; i < attempts; i++ { |
|
|
|
if i > 0 { |
|
|
@@ -1347,7 +1386,7 @@ func deleteCloudbrainJob(ctx *context.Context) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
deleteJobStorage(task.JobName, models.TypeCloudBrainOne) |
|
|
|
DeleteCloudbrainJobStorage(task.JobName, models.TypeCloudBrainOne) |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
@@ -1734,7 +1773,7 @@ func mkPathAndReadMeFile(path string, text string) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func deleteJobStorage(jobName string, cloudbrainType int) error { |
|
|
|
func DeleteCloudbrainJobStorage(jobName string, cloudbrainType int) error { |
|
|
|
//delete local |
|
|
|
localJobPath := setting.JobPath + jobName |
|
|
|
err := os.RemoveAll(localJobPath) |
|
|
|