Skip to content

Commit

Permalink
cmd/run,job: Flag to override files in working directory
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
  • Loading branch information
nderjung committed Dec 23, 2020
1 parent 989327b commit 835998c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type RunConfig struct {
DryRun bool
ScheduleGrace int
WorkDir string
AllowOverride bool
}

var (
Expand Down Expand Up @@ -91,6 +92,13 @@ func init() {
"",
"Specify working directory for outputting results, data, file systems, etc.",
)
runCmd.PersistentFlags().BoolVarP(
&runConfig.AllowOverride,
"allow-override",
"O",
false,
"Override contents in directories (otherwise tasks allowed to fail).",
)
}

// doRunCmd
Expand Down Expand Up @@ -118,6 +126,7 @@ func doRunCmd(cmd *cobra.Command, args []string) {
j, err := job.NewJob(args[0], &job.RuntimeConfig{
Cpus: cpus,
ScheduleGrace: runConfig.ScheduleGrace,
AllowOverride: runConfig.AllowOverride,
WorkDir: runConfig.WorkDir,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func NewJob(filePath string, cfg *RuntimeConfig) (*Job, error) {
}
}

task.Init(cfg.WorkDir, &job.Runs)
task.Init(cfg.WorkDir, cfg.AllowOverride, &job.Runs)
job.waitList.Add(task)
}

Expand Down
2 changes: 1 addition & 1 deletion job/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Task struct {
}

// Init prepare the task
func (t *Task) Init(workDir string, runs *[]Run) error {
func (t *Task) Init(workDir string, allowOverride bool, runs *[]Run) error {
// Create a queue of runs for this particular task
t.runs = NewQueue(len(*runs))

Expand Down

0 comments on commit 835998c

Please sign in to comment.