Skip to content

Commit 08e2dab

Browse files
author
Normalnoise
authored
Merge pull request #217 from swanchain/fix-rejected-status
Fix the issue of updating the rejected status of a task
2 parents 3314249 + c3bcb45 commit 08e2dab

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

internal/computing/cron_task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (task *CronTask) watchExpiredTask() {
250250
}
251251
}()
252252

253-
jobList, err := NewJobService().GetJobList(models.UN_DELETEED_FLAG, -1)
253+
jobList, err := NewJobService().GetJobListByNoRejectStatus()
254254
if err != nil {
255255
logs.GetLogger().Errorf("failed to get job data, error: %+v", err)
256256
return

internal/computing/ecp_image_service.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (imageJob *ImageJobService) DeployJob(c *gin.Context) {
233233
var envs []string
234234
var needResource container.Resources
235235
if len(job.Resource.Gpus) > 0 {
236-
envs = append(envs, fmt.Sprintf("CUDA_VISIBLE_DEVICES=%s", strings.Join(indexs, ",")))
236+
envs = append(envs, fmt.Sprintf("NVIDIA_VISIBLE_DEVICES=%s", strings.Join(indexs, ",")))
237237
needResource = container.Resources{
238238
CPUQuota: needCpu * 100000,
239239
Memory: job.Resource.Memory,
@@ -351,8 +351,13 @@ func (imageJob *ImageJobService) DeployJob(c *gin.Context) {
351351
}
352352
} else {
353353
var gNameStr string
354-
for _, g := range job.Resource.Gpus {
355-
gNameStr += g.GPUModel + "="
354+
if len(job.Resource.Gpus) > 0 {
355+
for _, g := range job.Resource.Gpus {
356+
if g.GPUModel == "" || g.GPU == 0 {
357+
continue
358+
}
359+
gNameStr += g.GPUModel + "="
360+
}
356361
}
357362

358363
if err = NewEcpJobService().SaveEcpJobEntity(&models.EcpJobEntity{

internal/computing/entity_service.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func (taskServ TaskService) GetTaskListNoRewardForFilC2() (list []*models.TaskEn
8484
}
8585

8686
func (taskServ TaskService) GetTaskListNoRewardForMining() (list []*models.TaskEntity, err error) {
87-
err = taskServ.Model(&models.TaskEntity{}).Where("uuid !='' and (status !=? or status !=? or status !=?) ", models.TASK_TIMEOUT_STATUS,
88-
models.TASK_VERIFYFAILED_STATUS, models.TASK_VERIFIED_STATUS).Find(&list).Error
87+
err = taskServ.Model(&models.TaskEntity{}).Where("uuid !='' and (status !=? or status !=? or status !=? or status !=?) ", models.TASK_TIMEOUT_STATUS,
88+
models.TASK_VERIFYFAILED_STATUS, models.TASK_VERIFIED_STATUS, models.TASK_REJECTED_STATUS).Find(&list).Error
8989
if err != nil {
9090
return nil, err
9191
}
@@ -172,6 +172,18 @@ func (jobServ JobService) GetJobList(status int, tailNum int) (list []*models.Jo
172172
return
173173
}
174174

175+
func (jobServ JobService) GetJobListByNoRejectStatus() (list []*models.JobEntity, err error) {
176+
err = jobServ.Model(&models.JobEntity{}).Where("delete_at=? and status >=0", models.UN_DELETEED_FLAG).Find(&list).Error
177+
if err != nil {
178+
return nil, err
179+
}
180+
181+
for i, j := 0, len(list)-1; i < j; i, j = i+1, j-1 {
182+
list[i], list[j] = list[j], list[i]
183+
}
184+
return
185+
}
186+
175187
func (jobServ JobService) UpdateJobReward(taskUuid string, amount string) (err error) {
176188
return jobServ.Model(&models.JobEntity{}).Where("task_uuid=?", taskUuid).Update("reward", amount).Error
177189
}

internal/computing/ubi_service.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,14 +1006,13 @@ func doFilC2Task(c *gin.Context, zkTask models.ZkTaskReq, taskEntity *models.Tas
10061006
Memory: needMemory * 1024 * 1024 * 1024,
10071007
}
10081008
} else {
1009-
//gpuEnv, ok := os.LookupEnv("RUST_GPU_TOOLS_CUSTOM_GPU")
1010-
//if ok {
1011-
// env = append(env, "RUST_GPU_TOOLS_CUSTOM_GPU="+gpuEnv)
1012-
//}
1013-
10141009
var useIndexs []string
10151010
if len(indexs) > 0 {
10161011
if gpuName != "" {
1012+
gpuEnv, ok := os.LookupEnv("RUST_GPU_TOOLS_CUSTOM_GPU")
1013+
if ok {
1014+
env = append(env, "RUST_GPU_TOOLS_CUSTOM_GPU="+gpuEnv)
1015+
}
10171016
useIndexs = append(useIndexs, defaultIndex)
10181017
} else {
10191018
for i := 0; i < needGpuNum; i++ {
@@ -1809,6 +1808,9 @@ func syncTaskStatusForSequencerService() error {
18091808
}
18101809

18111810
for _, item := range group.Items {
1811+
if item.Status == models.TASK_REJECTED_STATUS {
1812+
continue
1813+
}
18121814
var taskAddress = item.SequenceTaskAddr
18131815
if t, ok := taskMap[item.Id]; ok {
18141816
item.Reward = "0.00"

0 commit comments

Comments
 (0)