From 7ad2be0b9a39e6e8ecf56242049e0dad9a4b82fa Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 22 May 2024 11:24:05 +0100 Subject: [PATCH 1/3] spalloc user and password from environment --- spinnman/spalloc/spalloc_client.py | 14 ++++++++++++-- spinnman_integration_tests/test_job.py | 5 +---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index d2a58ace4..c19bf3e51 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -14,6 +14,7 @@ """ Implementation of the client for the Spalloc web service. """ +import os import time from logging import getLogger @@ -108,12 +109,21 @@ def __init__( location; if so, the ``username`` and ``password`` arguments *must* be ``None``. If ``username`` and ``password`` are not given, not even within the URL, the ``bearer_token`` must be not ``None``. - :param str username: The user name to use - :param str password: The password to use + :param str username: + The user name to use. If not provided nor in service_url + environment variable SPALLOC_USER will be used. + :param str password: + The password to use. If not provided nor in service_url + environment variable SPALLOC_PASSWORD will be used. :param str bearer_token: The bearer token to use """ if username is None and password is None: service_url, username, password = parse_service_url(service_url) + if username is None: + username = os.environ["SPALLOC_USER"] + if password is None: + password = os.environ["SPALLOC_PASSWORD"] + self.__session: Optional[Session] = Session( service_url, username, password, bearer_token) obj = self.__session.renew() diff --git a/spinnman_integration_tests/test_job.py b/spinnman_integration_tests/test_job.py index 79641f615..1d52c4f28 100644 --- a/spinnman_integration_tests/test_job.py +++ b/spinnman_integration_tests/test_job.py @@ -29,12 +29,9 @@ def setUp(self): set_config("Machine", "version", FIVE) self.spalloc_url = "https://spinnaker.cs.man.ac.uk/spalloc" self.spalloc_machine = "SpiNNaker1M" - self.spalloc_user = os.environ["SPALLOC_USER"] - self.spalloc_password = os.environ["SPALLOC_PASSWORD"] def test_create_job(self): - client = SpallocClient( - self.spalloc_url, self.spalloc_user, self.spalloc_password) + client = SpallocClient(self.spalloc_url) # job = client.create_job_rect_at_board( # WIDTH, HEIGHT, triad=(x, y, b), machine_name=SPALLOC_MACHINE, # max_dead_boards=1) From 513c7942e69d4ce9c0e3c190a243833d03b1c224 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 24 May 2024 10:30:31 +0100 Subject: [PATCH 2/3] remove unused import --- spinnman_integration_tests/test_job.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spinnman_integration_tests/test_job.py b/spinnman_integration_tests/test_job.py index 1d52c4f28..f626e1ce8 100644 --- a/spinnman_integration_tests/test_job.py +++ b/spinnman_integration_tests/test_job.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import unittest from spinn_utilities.config_holder import set_config From d0502b4869f2490cf66a6ac5f536352bfbbb32f1 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 3 Jun 2024 15:38:55 +0100 Subject: [PATCH 3/3] coverage-package pylint-packages mypy-packages --- .github/workflows/python_actions.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 69e11ecbf..ef36ddf42 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -21,8 +21,11 @@ jobs: call: uses: SpiNNakerManchester/SupportScripts/.github/workflows/python_checks.yml@main with: - base-package: spinnman + dependencies: SpiNNUtils SpiNNMachine test_directories: unittests spinnman_integration_tests + coverage-package: spinnman flake8-packages: spinnman unittests spinnman_integration_tests + pylint-packages: spinnman + mypy-packages: spinnman secrets: inherit