Skip to content

Commit

Permalink
Merge pull request #28 from opensafely-core/update-dependencies
Browse files Browse the repository at this point in the history
fix: Update to opensafely-jobrunner v2.10.1
  • Loading branch information
evansd authored Feb 8, 2021
2 parents fbbc8b2 + d49e7c1 commit aae8845
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions opensafely/_vendor/jobrunner/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ def get_action_specification(project, action_id):
f"Action '{action_id}' not found in project.yaml", project
)
run_command = action_spec["run"]
run_args = shlex.split(run_command)
# Specical case handling for the `cohortextractor generate_cohort` command
if is_generate_cohort_command(shlex.split(run_command)):
if is_generate_cohort_command(run_args):
# Set the size of the dummy data population, if that's what were
# generating. Possibly this should be moved to the study definition
# anyway, which would make this unnecessary.
Expand All @@ -212,12 +213,18 @@ def get_action_specification(project, action_id):
# ensure this doesn't break existing studies.)
output_dirs = get_output_dirs(action_spec["outputs"])
if len(output_dirs) != 1:
raise ProjectValidationError(
f"generate_cohort command should produce output in only one "
f"directory, found {len(output_dirs)}:\n"
+ "\n".join([f" - {d}/" for d in output_dirs])
)
run_command += f" --output-dir={output_dirs[0]}"
# If we detect multiple output directories but the command
# explicitly specifies an output directory then we assume the user
# knows what they're doing and don't attempt to modify the output
# directory or throw an error
if not args_include(run_args, "--output-dir"):
raise ProjectValidationError(
f"generate_cohort command should produce output in only one "
f"directory, found {len(output_dirs)}:\n"
+ "\n".join([f" - {d}/" for d in output_dirs])
)
else:
run_command += f" --output-dir={output_dirs[0]}"
return ActionSpecifiction(
run=run_command,
needs=action_spec.get("needs", []),
Expand All @@ -241,6 +248,10 @@ def is_generate_cohort_command(args):
return False


def args_include(args, target_arg):
return any(arg == target_arg or arg.startswith(f"{target_arg}=") for arg in args)


def get_all_actions(project):
# We ignore any manually defined run_all action (in later project versions
# this will be an error). We use a list comprehension rather than set
Expand Down
2 changes: 1 addition & 1 deletion vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
certifi==2020.12.5 # via requests
chardet==4.0.0 # via requests
idna==2.10 # via requests
opensafely-jobrunner==2.10.0 # via -r vendor.in
opensafely-jobrunner==2.10.1 # via -r vendor.in
requests==2.25.1 # via opensafely-jobrunner
# ruamel.yaml.clib==0.2.2 # via ruamel.yaml
ruamel.yaml==0.16.12 # via opensafely-jobrunner
Expand Down

0 comments on commit aae8845

Please sign in to comment.