diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 69e11ecbf..de69522ee 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 - secrets: inherit + pylint-packages: spinnman + mypy-packages: spinnman unittests spinnman_integration_tests + secrets: inherit \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ad1abdeed..730bf08ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,4 +17,4 @@ requires = ["setuptools"] build-backend = "setuptools.build_meta" [tool.mypy] -exclude = ["doc", "setup.py", "unittests", "quick_tests"] +exclude = ["doc", "setup.py", "quick_tests"] diff --git a/spinnman/spalloc/session.py b/spinnman/spalloc/session.py index b58c7b01b..63c892969 100644 --- a/spinnman/spalloc/session.py +++ b/spinnman/spalloc/session.py @@ -238,7 +238,13 @@ def renew(self) -> JsonObject: self.__login_form_url, r.status_code) m = csrf_matcher.search(r.text) if not m: - raise SpallocException("could not establish temporary session") + msg = ("Could not establish temporary session to " + f"{self._service_url} for user {self.__username} ") + if self.__password is None: + msg += "with a no password" + else: + msg += f"with a {len(self.__password)} character password." + raise SpallocException(msg) csrf = m.group(1) session = r.cookies[_SESSION_COOKIE] diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index d2a58ace4..451bfffa8 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.getenv("SPALLOC_USER", None) + if password is None: + password = os.getenv("SPALLOC_PASSWORD", None) + self.__session: Optional[Session] = Session( service_url, username, password, bearer_token) obj = self.__session.renew() diff --git a/spinnman/spinnman.cfg b/spinnman/spinnman.cfg index e530f855f..d5df9e6ac 100644 --- a/spinnman/spinnman.cfg +++ b/spinnman/spinnman.cfg @@ -1,25 +1,15 @@ -# Adds or overwrites values in SpiNNMachine/spinn_machine/spinn_machine.cfg -# Which in turn adds or overwrites values in SpiNNUtils/spinn_utilities/spinn_utilities.cfg +# DO NOT EDIT! +# The are the default values +# Edit the cfg in your home directory to change your preferences +# Add / Edit a cfg in the run directory for script specific changes + +# Adds to values in SpiNNMachine/spinn_machine/spinn_machine.cfg +# Which in turn adds values in SpiNNUtils/spinn_utilities/spinn_utilities.cfg # This is a place holder for any future SpiNNMan level cfg settings [Machine] -# machine name is typically a URL and then version is required -machine_name = None - # When True if any non ethernet chip claims it has a IP address this is logged and ignored # When False the whole chip is removed ignore_bad_ethernets = True report_waiting_logs = False turn_off_machine = False - -# format is: -# bmp_names = [/(|board_id[,board_id]*) -# = - -# where: -# is the hostname or IP address of the BMP -# is a range of boards that the BMP can speak to -# is the ID of a single board in a frame -# Note this no longer supports multiple host nor cabinet or frame -bmp_names = None - -auto_detect_bmp = False diff --git a/spinnman_integration_tests/test_job.py b/spinnman_integration_tests/test_job.py index 79641f615..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 @@ -29,12 +28,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)