From 7ff6676c21da3981411da4a3a48e0581737036ae Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Mon, 22 Jul 2024 08:15:11 +0100 Subject: [PATCH 1/2] Allow getting of an existing job --- spinnman/spalloc/spalloc_client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 451bfffa8..1bc37d9fa 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -138,6 +138,16 @@ def __init__( self.__nmpi_user = nmpi_user logger.info("established session to {} for {}", service_url, username) + def get_job(self, job_id: str) -> SpallocJob: + """ + Get a job by its job id. + + :param str job_id: The job id. + :rtype: SpallocJob + """ + return _SpallocJob( + self.__session, fix_url(f"{self.__jobs_url}/{job_id}")) + @staticmethod def open_job_from_database( service_url, job_url, cookies, headers) -> SpallocJob: From 856dfc4ae067846d00c09e7af321fa1c31455936 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Tue, 23 Jul 2024 08:09:37 +0100 Subject: [PATCH 2/2] mypy fixes --- spinnman/spalloc/spalloc_client.py | 1 + spinnman/utilities/locate_connected_machine_ip_address.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 1bc37d9fa..53c036710 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -145,6 +145,7 @@ def get_job(self, job_id: str) -> SpallocJob: :param str job_id: The job id. :rtype: SpallocJob """ + assert self.__session return _SpallocJob( self.__session, fix_url(f"{self.__jobs_url}/{job_id}")) diff --git a/spinnman/utilities/locate_connected_machine_ip_address.py b/spinnman/utilities/locate_connected_machine_ip_address.py index eaa734033..6ed26c419 100644 --- a/spinnman/utilities/locate_connected_machine_ip_address.py +++ b/spinnman/utilities/locate_connected_machine_ip_address.py @@ -20,7 +20,7 @@ from spinnman.connections.udp_packet_connections import IPAddressesConnection -def locate_connected_machine(handler: Callable[[str, float], None]): +def locate_connected_machine(handler: Callable[[str, float], bool]): """ Locates any SpiNNaker machines IP addresses from the auto-transmitted packets from non-booted SpiNNaker machines. @@ -51,7 +51,7 @@ def _ctrlc_handler(sig, frame): print("Exiting") sys.exit() - def _print_connected(ip_address: str, timestamp: float): + def _print_connected(ip_address: str, timestamp: float) -> bool: try: hostname = f" ({socket.gethostbyaddr(ip_address)[0]})" except Exception: # pylint: disable=broad-except