Skip to content

Commit

Permalink
remove another kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 27, 2024
1 parent 6b5107c commit bc8fd00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
33 changes: 14 additions & 19 deletions spalloc_client/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,34 +341,29 @@ def __init__(self, *args: int, hostname: Optional[str] = NO_STR,
logger.info("Spalloc resumed job %d", self.id)
else:
# Get job creation arguments
job_args = args
job_kwargs = {
"owner": owner,
"keepalive": pick_num(keepalive, config.keepalive),
"machine": pick_str(machine, config.machine),
"tags": pick_list(tags, config.tags),
"min_ratio": pick_num(min_ratio, config.min_ratio),
"max_dead_boards":
pick_num(max_dead_boards, config.max_dead_boards),
"max_dead_links":
pick_num(max_dead_links, config.max_dead_links),
"require_torus":
pick_bool(require_torus, config.require_torus),
}
machine = pick_str(machine, config.machine)
tags = pick_list(tags, config.tags)

# Sanity check arguments
if job_kwargs["owner"] is None:
if owner is None:
raise ValueError("An owner must be specified.")
if (job_kwargs["tags"] is not None and
job_kwargs["machine"] is not None):
if tags is not None and machine is not None:
raise ValueError(
"Only one of tags and machine may be specified.")

self._keepalive = job_kwargs["keepalive"]
self._keepalive = pick_num(keepalive, config.keepalive)

# Create the job (failing fast if can't communicate)
self.id = self._client.create_job(
self._timeout, *job_args, **job_kwargs)
self._timeout, *args, owner = owner,
keepalive = self._keepalive, machine = machine, tags = tags,
min_ratio = pick_num(min_ratio, config.min_ratio),
max_dead_boards = pick_num(
max_dead_boards, config.max_dead_boards),
max_dead_links = pick_num(
max_dead_links, config.max_dead_links),
require_torus = pick_bool(
require_torus, config.require_torus))

logger.info("Created spalloc job %d", self.id)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ def test_args_from_config(self, basic_config_file, client,
basic_job_kwargs.pop("hostname")
basic_job_kwargs.pop("port")
basic_job_kwargs.pop("reconnect_delay")
timeout = basic_job_kwargs.pop("timeout")
assert len(client.create_job.mock_calls) == 1
args = client.create_job.mock_calls[0][1]
kwargs = client.create_job.mock_calls[0][2]
assert args == tuple()
assert args == (timeout,)
assert kwargs == basic_job_kwargs
finally:
j.close()
Expand Down Expand Up @@ -107,9 +108,8 @@ def test_override_config(self, basic_config_file, basic_job_kwargs,
assert len(client.create_job.mock_calls) == 1
args = client.create_job.mock_calls[0][1]
kwargs = client.create_job.mock_calls[0][2]
assert args == tuple()
assert kwargs == dict(timeout=0.2,
owner="mossblaser",
assert args == (0.2,)
assert kwargs == dict(owner="mossblaser",
keepalive=0.3,
machine=None,
tags=["baz", "quz"],
Expand Down

0 comments on commit bc8fd00

Please sign in to comment.