feat(application): add Environment field and inject into Slurm job submission
This commit is contained in:
@@ -49,6 +49,9 @@ func (s *JobService) SubmitJob(ctx context.Context, req *model.SubmitJobRequest)
|
||||
"PATH=/usr/local/bin:/usr/bin:/bin",
|
||||
"HOME=/root",
|
||||
}
|
||||
for k, v := range req.Environment {
|
||||
jobDesc.Environment = append(jobDesc.Environment, k+"="+v)
|
||||
}
|
||||
|
||||
if req.MemoryPerNode != nil {
|
||||
jobDesc.MemoryPerNode = &slurm.Uint64NoVal{Set: slurm.Ptr(true), Number: req.MemoryPerNode}
|
||||
|
||||
@@ -276,6 +276,14 @@ func (s *TaskService) ProcessTask(ctx context.Context, taskID int64) error {
|
||||
}
|
||||
}
|
||||
|
||||
// 15a. Parse app environment
|
||||
var appEnv map[string]string
|
||||
if len(app.Environment) > 0 {
|
||||
if err := json.Unmarshal(app.Environment, &appEnv); err != nil {
|
||||
return fail(model.TaskStepSubmitting, fmt.Sprintf("parse application environment: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
// 16. Parse task values
|
||||
values := make(map[string]string)
|
||||
if len(task.Values) > 0 {
|
||||
@@ -413,6 +421,7 @@ func (s *TaskService) ProcessTask(ctx context.Context, taskID int64) error {
|
||||
Dependency: task.Dependency,
|
||||
Requeue: task.Requeue,
|
||||
KillOnNodeFail: task.KillOnNodeFail,
|
||||
Environment: appEnv,
|
||||
})
|
||||
if err != nil {
|
||||
return fail(model.TaskStepSubmitting, fmt.Sprintf("submit job: %v", err))
|
||||
|
||||
Reference in New Issue
Block a user