Skip to content

Commit

Permalink
Merge pull request #553 from opensafely-core/cpus
Browse files Browse the repository at this point in the history
fix: use --cpus ali arg, aliased to --cpu for b/w compat
  • Loading branch information
bloodearnest authored Jan 18, 2023
2 parents ed419a6 + 24dac82 commit dacc6fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions jobrunner/cli/local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def add_arguments(parser):
default=config.DEFAULT_JOB_MEMORY_LIMIT,
)
parser.add_argument(
"--cpus",
"--cpu",
type=int,
help=f"The per-job cpu limit. How many cpus the job can use. Defaults to {config.DEFAULT_JOB_CPU_COUNT}",
Expand All @@ -169,7 +170,7 @@ def main(
format_output_for_github=False,
concurrency=config.MAX_WORKERS,
memory=config.DEFAULT_JOB_MEMORY_LIMIT,
cpu=config.DEFAULT_JOB_CPU_COUNT,
cpus=config.DEFAULT_JOB_CPU_COUNT,
):
if not docker_preflight_check():
return False
Expand Down Expand Up @@ -208,7 +209,7 @@ def main(
format_output_for_github=format_output_for_github,
concurrency=concurrency,
memory=memory,
cpu=cpu,
cpus=cpus,
)
except KeyboardInterrupt:
print("\nKilled by user")
Expand Down Expand Up @@ -244,7 +245,7 @@ def create_and_run_jobs(
format_output_for_github=False,
concurrency=config.MAX_WORKERS,
memory=config.DEFAULT_JOB_MEMORY_LIMIT,
cpu=config.DEFAULT_JOB_CPU_COUNT,
cpus=config.DEFAULT_JOB_CPU_COUNT,
):
# Fiddle with the configuration to suit what we need for running local jobs
docker.LABEL = docker_label
Expand All @@ -259,7 +260,7 @@ def create_and_run_jobs(
config.CLEAN_UP_DOCKER_OBJECTS = clean_up_docker_objects
config.MAX_WORKERS = concurrency
config.DEFAULT_JOB_MEMORY_LIMIT = memory
config.DEFAULT_JOB_CPU_COUNT = cpu
config.DEFAULT_JOB_CPU_COUNT = cpus

# We want to fetch any reusable actions code directly from Github so as to
# avoid pushing unnecessary traffic through the proxy
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/test_local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_local_run_limits_applied(db, tmp_path, docker_cleanup):
actions=["generate_dataset"],
debug=True, # preserves containers for inspection
memory="1.5G",
cpu=1.5,
cpus=1.5,
)

for job in database.find_all(Job):
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_add_arguments():
"--debug",
"--concurrency=3",
"--memory=2G",
"--cpu=1",
"--cpus=1",
]
)

Expand All @@ -219,7 +219,7 @@ def test_add_arguments():
assert args.debug
assert args.concurrency == 3
assert args.memory == "2G"
assert args.cpu == 1
assert args.cpus == 1


def test_filter_log_messages():
Expand Down

0 comments on commit dacc6fe

Please sign in to comment.