Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 27, 2024
1 parent 2a6f06c commit 3085609
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions spalloc_client/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import subprocess
import time
from types import TracebackType
from typing import (
Any, cast, Dict, List, Optional, Tuple, Type, TypeVar, Union)
from typing import (Any, cast, Dict, List, Optional, Tuple, Type, TypeVar)
import sys

from typing_extensions import Literal, Self
Expand All @@ -47,6 +46,7 @@
NO_INT = -9834
F = TypeVar('F', bound='float')


def pick_str(param: Optional[str], config: Optional[str]) -> Optional[str]:
""" Use the param unless it is the default value, otherwise use config"""
if param == NO_STR:
Expand Down Expand Up @@ -162,7 +162,7 @@ class Job(object):
"""

def __init__(self, *args: int, hostname: Optional[str] = NO_STR,
port:Optional[int] = NO_INT,
port: Optional[int] = NO_INT,
reconnect_delay: Optional[float] = NO_INT,
timeout: Optional[float] = NO_INT,
config_filenames: Optional[List[str]] = [NO_STR],
Expand Down Expand Up @@ -355,14 +355,14 @@ def __init__(self, *args: int, hostname: Optional[str] = NO_STR,

# Create the job (failing fast if can't communicate)
self.id = self._client.create_job(
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(
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=pick_num(
max_dead_links, config.max_dead_links),
require_torus = pick_bool(
require_torus=pick_bool(
require_torus, config.require_torus))

logger.info("Created spalloc job %d", self.id)
Expand Down
2 changes: 1 addition & 1 deletion spalloc_client/protocol_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def create_job(self, timeout: Optional[float], *args: int,
"create_job", timeout, *args, owner=owner,
keepalive=keepalive, machine=machine, tags=tags,
min_ratio=min_ratio, max_dead_boards=max_dead_boards,
max_dead_links =max_dead_links, require_torus=require_torus))
max_dead_links=max_dead_links, require_torus=require_torus))

def job_keepalive(self, job_id: int,
timeout: Optional[float] = None) -> JsonObject:
Expand Down
4 changes: 2 additions & 2 deletions spalloc_client/scripts/alloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def parse_argv(argv: Optional[List[str]]) -> Tuple[

def run_job(ip_file_filename: str,
job_args: List[int],
job_kwargs: Dict[str, Union[float, str, None]])-> int:
job_kwargs: Dict[str, Union[float, str, None]]) -> int:
"""
Run a job
"""
Expand All @@ -441,7 +441,7 @@ def run_job(ip_file_filename: str,

# Create the job
try:
job = Job(*job_args, **job_kwargs) # type: ignore[arg-type]
job = Job(*job_args, **job_kwargs) # type: ignore[arg-type]
except (OSError, IOError, ProtocolError, ProtocolTimeoutError) as e:
info(t.red(f"Could not connect to server: {e}"))
return 6
Expand Down
3 changes: 1 addition & 2 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import pytest
from mock import Mock # type: ignore[import]
from spalloc_client import (
Job, JobState, JobDestroyedError, ProtocolTimeoutError,
SpallocServerException)
Job, JobState, JobDestroyedError, ProtocolTimeoutError)
from spalloc_client._keepalive_process import keep_job_alive
from spalloc_client.job import (
_JobStateTuple, _JobMachineInfoTuple, StateChangeTimeoutError,
Expand Down

0 comments on commit 3085609

Please sign in to comment.