From 6d6f0e31995b091199821190dc6426008fce66dc Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 07:54:14 +0100 Subject: [PATCH 01/12] swap to pyproject.toml --- .github/workflows/python_actions.yml | 12 +++--- MANIFEST.in | 2 +- requirements.txt => pyproject.toml | 6 ++- requirements-test.txt | 22 ---------- setup.cfg | 62 +++++++++++++++++++++++++++ setup.py | 64 ++-------------------------- 6 files changed, 77 insertions(+), 91 deletions(-) rename requirements.txt => pyproject.toml (80%) delete mode 100644 requirements-test.txt create mode 100644 setup.cfg diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index d99038264..5c91cf48e 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -40,12 +40,14 @@ jobs: - name: Install pip, etc uses: ./support/actions/python-tools - name: Install Spinnaker Dependencies - uses: ./support/actions/checkout-spinn-deps + uses: ./support/actions/install-spinn-deps with: repositories: SpiNNUtils install: true - - name: Setup - uses: ./support/actions/run-setup + + - name: Install + uses: ./support/actions/run-install + - name: Extra setup run: pip install -r requirements-docs.txt @@ -62,7 +64,7 @@ jobs: run: flake8 spalloc tests - name: Lint with pylint uses: ./support/actions/pylint - with: + with: package: spalloc exitcheck: 39 @@ -79,4 +81,4 @@ jobs: - name: Validate CITATION.cff if: matrix.python-version == 3.8 - uses: dieghernan/cff-validator@main + uses: dieghernan/cff-validator@main \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 860619287..3487a3d39 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include CITATION.cff LICENSE.md requirements.txt pypi_to_import \ No newline at end of file +include LICENSE LICENSE_POLICY.md README.rst diff --git a/requirements.txt b/pyproject.toml similarity index 80% rename from requirements.txt rename to pyproject.toml index c9f6d085b..ddb15f360 100644 --- a/requirements.txt +++ b/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright (c) 2016 The University of Manchester +# Copyright (c) 2023 The University of Manchester # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,4 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -SpiNNUtilities == 1!6.0.1 +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index f4068ffef..000000000 --- a/requirements-test.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2016 The University of Manchester -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Test suite requirements --r requirements.txt -coverage >= 4.4, < 5.0 -pytest-cov -# pytest will be brought in by pytest-cov -pytest-timeout -flake8 -mock diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..658af425e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,62 @@ +# Copyright (c) 2023 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[metadata] +name = spalloc +version = attr: spalloc._version.__version__ +description = A client for the spalloc_server SpiNNaker machine partitioning and allocation system. +#long_description = file: README.rst +#long_description_content_type = text/x-rst +url = https://github.com/SpiNNakerManchester/spalloc +license = Apache-2.0 +classifiers = + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + Intended Audience :: Science/Research + License :: OSI Approved :: Apache License 2.0 + Natural Language :: English + Operating System :: POSIX :: Linux + Operating System :: Microsoft :: Windows + Operating System :: MacOS + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 +maintainer = SpiNNakerTeam +maintainer_email = spinnakerusers@googlegroups.com +keywords = + spinnaker + allocation + packing management + supercomputer + +[options] +python_requires = >=3.7, <4 +packages = find: +zip_safe = True +include_package_data = True +install_requires = + jsonschema + SpiNNUtilities == 1!6.0.1 + +[options.extras_require] +test = + flake8 >= 5.0 + coverage >= 4.4, < 5.0 + # pytest will be brought in by pytest-cov + pytest-cov + pytest-timeout + mock \ No newline at end of file diff --git a/setup.py b/setup.py index 21d871e96..ecc61bec8 100644 --- a/setup.py +++ b/setup.py @@ -12,64 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from setuptools import setup, find_packages - -__version__ = None -exec(open("spalloc/_version.py").read()) -assert __version__ - -setup( - name="spalloc", - version=__version__, - packages=find_packages(), - - # Metadata for PyPi - url="https://github.com/SpiNNakerManchester/spalloc", - description="A client for the spalloc_server SpiNNaker machine " - "partitioning and allocation system.", - license="GPLv2", - classifiers=[ - "Development Status :: 5 - Production/Stable", - - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - - "License :: OSI Approved :: Apache License 2.0", - - "Natural Language :: English", - - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows", - "Operating System :: MacOS", - - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - keywords="spinnaker allocation packing management supercomputer", - - # Requirements - install_requires=['SpiNNUtilities == 1!6.0.1'], - # Scripts - entry_points={ - "console_scripts": [ - "spalloc = spalloc.scripts.alloc:main", - "spalloc-ps = spalloc.scripts.ps:main", - "spalloc-job = spalloc.scripts.job:main", - "spalloc-machine = spalloc.scripts.machine:main", - "spalloc-where-is = spalloc.scripts.where_is:main", - ], - }, - # Booting directly needs rig; not recommended! Use SpiNNMan instead, as - # that has an up-to-date boot image pre-built - # Note rig does not work with python 3.11 and there are NO plans to fix it - extras_require={ - 'boot': [ - 'rig', - ]}, - maintainer="SpiNNakerTeam", - maintainer_email="spinnakerusers@googlegroups.com" -) +from setuptools import setup +if __name__ == '__main__': + setup() \ No newline at end of file From 1b280462f595a3562d646afdd4d52d5a59512c99 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 10:19:43 +0100 Subject: [PATCH 02/12] rename spalloc spalloc_client --- README.rst | 2 +- docs/source/conf.py | 8 ++++---- docs/source/index.rst | 2 +- setup.cfg | 2 +- {spalloc => spalloc_client}/__init__.py | 12 ++++++------ {spalloc => spalloc_client}/_keepalive_process.py | 2 +- {spalloc => spalloc_client}/_utils.py | 0 {spalloc => spalloc_client}/_version.py | 0 {spalloc => spalloc_client}/config.py | 0 {spalloc => spalloc_client}/job.py | 9 +++++---- {spalloc => spalloc_client}/protocol_client.py | 2 +- {spalloc => spalloc_client}/scripts/__init__.py | 0 {spalloc => spalloc_client}/scripts/alloc.py | 4 ++-- {spalloc => spalloc_client}/scripts/job.py | 6 +++--- {spalloc => spalloc_client}/scripts/machine.py | 4 ++-- {spalloc => spalloc_client}/scripts/ps.py | 6 +++--- {spalloc => spalloc_client}/scripts/support.py | 2 +- {spalloc => spalloc_client}/scripts/where_is.py | 4 ++-- {spalloc => spalloc_client}/states.py | 0 {spalloc => spalloc_client}/term.py | 0 tests/conftest.py | 4 ++-- tests/scripts/test_alloc.py | 4 ++-- tests/scripts/test_job_script.py | 8 ++++---- tests/scripts/test_machine.py | 8 ++++---- tests/scripts/test_ps.py | 9 +++++---- tests/scripts/test_where_is.py | 7 ++++--- tests/test_config.py | 2 +- tests/test_job.py | 6 +++--- tests/test_protocol_client.py | 2 +- tests/test_term.py | 2 +- 30 files changed, 60 insertions(+), 57 deletions(-) rename {spalloc => spalloc_client}/__init__.py (67%) rename {spalloc => spalloc_client}/_keepalive_process.py (97%) rename {spalloc => spalloc_client}/_utils.py (100%) rename {spalloc => spalloc_client}/_version.py (100%) rename {spalloc => spalloc_client}/config.py (100%) rename {spalloc => spalloc_client}/job.py (99%) rename {spalloc => spalloc_client}/protocol_client.py (99%) rename {spalloc => spalloc_client}/scripts/__init__.py (100%) rename {spalloc => spalloc_client}/scripts/alloc.py (99%) rename {spalloc => spalloc_client}/scripts/job.py (98%) rename {spalloc => spalloc_client}/scripts/machine.py (99%) rename {spalloc => spalloc_client}/scripts/ps.py (97%) rename {spalloc => spalloc_client}/scripts/support.py (99%) rename {spalloc => spalloc_client}/scripts/where_is.py (98%) rename {spalloc => spalloc_client}/states.py (100%) rename {spalloc => spalloc_client}/term.py (100%) diff --git a/README.rst b/README.rst index 77bccf5ce..917043bbc 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,7 @@ three-board machine:: :: - >>> from spalloc import Job + >>> from spalloc_client import Job >>> with Job(3) as j: ... my_boot(j.hostname, j.width, j.height) ... my_application(j.hostname) diff --git a/docs/source/conf.py b/docs/source/conf.py index 10d7360c0..7fef43dfe 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -61,8 +61,8 @@ def __getattr__(cls, name): # Note that this has to go AFTER we have updated sys.path! # This is because RTD doesn't actually install our checkout. -import spalloc # noqa: E402 -from spalloc import __version__ as release # noqa: E402 +import spalloc_client # noqa: E402 +from spalloc_client import __version__ as release # noqa: E402 # -- General configuration ------------------------------------------------ @@ -158,8 +158,8 @@ def __getattr__(cls, name): # -- linkcode GitHub link generator --------------------------------------- -local_module_path = spalloc.__file__ -github_module_path = "spalloc/" +local_module_path = spalloc_client.__file__ +github_module_path = "spalloc_client/" github_repo = "SpiNNakerManchester/spalloc" diff --git a/docs/source/index.rst b/docs/source/index.rst index 150d8d141..816fd4a93 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -35,7 +35,7 @@ three-board machine:: :: - >>> from spalloc import Job + >>> from spalloc_client import Job >>> with Job(3) as j: ... my_boot(j.hostname, j.width, j.height) ... my_application(j.hostname) diff --git a/setup.cfg b/setup.cfg index 658af425e..6fb575931 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,7 @@ [metadata] name = spalloc -version = attr: spalloc._version.__version__ +version = attr: spalloc_client._version.__version__ description = A client for the spalloc_server SpiNNaker machine partitioning and allocation system. #long_description = file: README.rst #long_description_content_type = text/x-rst diff --git a/spalloc/__init__.py b/spalloc_client/__init__.py similarity index 67% rename from spalloc/__init__.py rename to spalloc_client/__init__.py index 8ae35f170..2d08687a8 100644 --- a/spalloc/__init__.py +++ b/spalloc_client/__init__.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from spalloc._version import __version__ # noqa: F401 +from spalloc_client._version import __version__ # noqa: F401 # Alias useful objects -from spalloc.protocol_client import ProtocolClient, ProtocolError -from spalloc.protocol_client import ProtocolTimeoutError -from spalloc.protocol_client import SpallocServerException -from spalloc.job import Job, JobDestroyedError, StateChangeTimeoutError -from spalloc.states import JobState +from spalloc_client.protocol_client import ProtocolClient, ProtocolError +from spalloc_client.protocol_client import ProtocolTimeoutError +from spalloc_client.protocol_client import SpallocServerException +from spalloc_client.job import Job, JobDestroyedError, StateChangeTimeoutError +from spalloc_client.states import JobState __all__ = [ "Job", "JobDestroyedError", "JobState", "ProtocolClient", diff --git a/spalloc/_keepalive_process.py b/spalloc_client/_keepalive_process.py similarity index 97% rename from spalloc/_keepalive_process.py rename to spalloc_client/_keepalive_process.py index e1a0ff408..3ca225bc6 100644 --- a/spalloc/_keepalive_process.py +++ b/spalloc_client/_keepalive_process.py @@ -17,7 +17,7 @@ """ import sys import threading -from spalloc.protocol_client import ProtocolClient, ProtocolTimeoutError +from spalloc_client.protocol_client import ProtocolClient, ProtocolTimeoutError def wait_for_exit(stop_event): diff --git a/spalloc/_utils.py b/spalloc_client/_utils.py similarity index 100% rename from spalloc/_utils.py rename to spalloc_client/_utils.py diff --git a/spalloc/_version.py b/spalloc_client/_version.py similarity index 100% rename from spalloc/_version.py rename to spalloc_client/_version.py diff --git a/spalloc/config.py b/spalloc_client/config.py similarity index 100% rename from spalloc/config.py rename to spalloc_client/config.py diff --git a/spalloc/job.py b/spalloc_client/job.py similarity index 99% rename from spalloc/job.py rename to spalloc_client/job.py index 23737bb07..bceaab75f 100644 --- a/spalloc/job.py +++ b/spalloc_client/job.py @@ -11,7 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from spalloc.scripts.support import VERSION_RANGE_START, VERSION_RANGE_STOP +from spalloc_client.scripts.support import ( + VERSION_RANGE_START, VERSION_RANGE_STOP) # A high-level Python interface for allocating SpiNNaker boards. @@ -47,7 +48,7 @@ class Job(object): In its simplest form, a :py:class:`.Job` can be used as a context manager like so:: - >>> from spalloc import Job + >>> from spalloc_client import Job >>> with Job(6) as j: ... my_boot(j.hostname, j.width, j.height) ... my_application(j.hostname) @@ -60,7 +61,7 @@ class Job(object): For more fine-grained control, the same functionality is available via various methods:: - >>> from spalloc import Job + >>> from spalloc_client import Job >>> j = Job(6) >>> j.wait_until_ready() >>> my_boot(j.hostname, j.width, j.height) @@ -335,7 +336,7 @@ def __enter__(self): Example:: - >>> from spalloc import Job + >>> from spalloc_client import Job >>> with Job(6) as j: ... my_boot(j.hostname, j.width, j.height) ... my_application(j.hostname) diff --git a/spalloc/protocol_client.py b/spalloc_client/protocol_client.py similarity index 99% rename from spalloc/protocol_client.py rename to spalloc_client/protocol_client.py index feb51e63d..5706ecb3d 100644 --- a/spalloc/protocol_client.py +++ b/spalloc_client/protocol_client.py @@ -21,7 +21,7 @@ from threading import current_thread, RLock, local from spinn_utilities.abstract_context_manager import AbstractContextManager from spinn_utilities.overrides import overrides -from spalloc._utils import time_left, timed_out, make_timeout +from spalloc_client._utils import time_left, timed_out, make_timeout class ProtocolError(Exception): diff --git a/spalloc/scripts/__init__.py b/spalloc_client/scripts/__init__.py similarity index 100% rename from spalloc/scripts/__init__.py rename to spalloc_client/scripts/__init__.py diff --git a/spalloc/scripts/alloc.py b/spalloc_client/scripts/alloc.py similarity index 99% rename from spalloc/scripts/alloc.py rename to spalloc_client/scripts/alloc.py index 8c64d3d9c..1ec664ed2 100644 --- a/spalloc/scripts/alloc.py +++ b/spalloc_client/scripts/alloc.py @@ -116,10 +116,10 @@ import sys import tempfile from shlex import quote -from spalloc import ( +from spalloc_client import ( config, Job, JobState, __version__, ProtocolError, ProtocolTimeoutError, SpallocServerException) -from spalloc.term import Terminal, render_definitions +from spalloc_client.term import Terminal, render_definitions # Rig is used to implement the optional '--boot' facility. try: from rig.machine_control import MachineController diff --git a/spalloc/scripts/job.py b/spalloc_client/scripts/job.py similarity index 98% rename from spalloc/scripts/job.py rename to spalloc_client/scripts/job.py index 74413bf82..1447bfbfc 100644 --- a/spalloc/scripts/job.py +++ b/spalloc_client/scripts/job.py @@ -75,10 +75,10 @@ """ import argparse import sys -from spalloc import __version__, JobState -from spalloc.term import ( +from spalloc_client import __version__, JobState +from spalloc_client.term import ( Terminal, render_definitions, render_boards, DEFAULT_BOARD_EDGES) -from spalloc._utils import render_timestamp +from spalloc_client._utils import render_timestamp from .support import Terminate, Script diff --git a/spalloc/scripts/machine.py b/spalloc_client/scripts/machine.py similarity index 99% rename from spalloc/scripts/machine.py rename to spalloc_client/scripts/machine.py index 559ac54d1..cbf64d8ce 100644 --- a/spalloc/scripts/machine.py +++ b/spalloc_client/scripts/machine.py @@ -32,8 +32,8 @@ from collections import defaultdict import argparse import sys -from spalloc import __version__ -from spalloc.term import ( +from spalloc_client import __version__ +from spalloc_client.term import ( Terminal, render_table, render_definitions, render_boards, render_cells, DEFAULT_BOARD_EDGES) from .support import Terminate, Script diff --git a/spalloc/scripts/ps.py b/spalloc_client/scripts/ps.py similarity index 97% rename from spalloc/scripts/ps.py rename to spalloc_client/scripts/ps.py index d48476381..d5e9a2d18 100644 --- a/spalloc/scripts/ps.py +++ b/spalloc_client/scripts/ps.py @@ -26,9 +26,9 @@ """ import argparse import sys -from spalloc import __version__, JobState -from spalloc.term import Terminal, render_table -from spalloc._utils import render_timestamp +from spalloc_client import __version__, JobState +from spalloc_client.term import Terminal, render_table +from spalloc_client._utils import render_timestamp from .support import Script diff --git a/spalloc/scripts/support.py b/spalloc_client/scripts/support.py similarity index 99% rename from spalloc/scripts/support.py rename to spalloc_client/scripts/support.py index d804ffc90..af6a3f488 100644 --- a/spalloc/scripts/support.py +++ b/spalloc_client/scripts/support.py @@ -13,7 +13,7 @@ # limitations under the License. import sys -from spalloc import ( +from spalloc_client import ( config, ProtocolClient, ProtocolError, ProtocolTimeoutError, SpallocServerException) diff --git a/spalloc/scripts/where_is.py b/spalloc_client/scripts/where_is.py similarity index 98% rename from spalloc/scripts/where_is.py rename to spalloc_client/scripts/where_is.py index d767afedb..c738e5445 100644 --- a/spalloc/scripts/where_is.py +++ b/spalloc_client/scripts/where_is.py @@ -66,8 +66,8 @@ """ import sys import argparse -from spalloc import __version__ -from spalloc.term import render_definitions +from spalloc_client import __version__ +from spalloc_client.term import render_definitions from .support import Terminate, Script diff --git a/spalloc/states.py b/spalloc_client/states.py similarity index 100% rename from spalloc/states.py rename to spalloc_client/states.py diff --git a/spalloc/term.py b/spalloc_client/term.py similarity index 100% rename from spalloc/term.py rename to spalloc_client/term.py diff --git a/tests/conftest.py b/tests/conftest.py index 6264e5799..c93a1557d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,8 +18,8 @@ import tempfile import pytest from mock import Mock -from spalloc import ProtocolClient -from spalloc.config import SEARCH_PATH +from spalloc_client import ProtocolClient +from spalloc_client.config import SEARCH_PATH from .common import MockServer diff --git a/tests/scripts/test_alloc.py b/tests/scripts/test_alloc.py index 02f3fb4bf..660a0bcbe 100644 --- a/tests/scripts/test_alloc.py +++ b/tests/scripts/test_alloc.py @@ -16,8 +16,8 @@ import tempfile import pytest from mock import Mock, PropertyMock -from spalloc import JobState, JobDestroyedError -from spalloc.scripts.alloc import ( +from spalloc_client import JobState, JobDestroyedError +from spalloc_client.scripts.alloc import ( write_ips_to_csv, print_info, run_command, main) # pylint: disable=redefined-outer-name, unused-argument diff --git a/tests/scripts/test_job_script.py b/tests/scripts/test_job_script.py index 0ffd1160d..f0b9808f3 100644 --- a/tests/scripts/test_job_script.py +++ b/tests/scripts/test_job_script.py @@ -15,11 +15,11 @@ import datetime import pytest from mock import Mock, MagicMock -from spalloc import JobState, ProtocolError -from spalloc.term import Terminal -from spalloc.scripts.job import ( +from spalloc_client import JobState, ProtocolError +from spalloc_client.term import Terminal +from spalloc_client.scripts.job import ( show_job_info, watch_job, power_job, list_ips, destroy_job, main) -from spalloc.scripts.support import ( +from spalloc_client.scripts.support import ( VERSION_RANGE_START, VERSION_RANGE_STOP, Terminate) diff --git a/tests/scripts/test_machine.py b/tests/scripts/test_machine.py index 90915ff36..00dedf49f 100644 --- a/tests/scripts/test_machine.py +++ b/tests/scripts/test_machine.py @@ -14,12 +14,12 @@ import pytest from mock import Mock, MagicMock -from spalloc.term import Terminal -from spalloc.scripts.machine import ( +from spalloc_client.term import Terminal +from spalloc_client.scripts.machine import ( main, generate_keys, list_machines, show_machine) -from spalloc.scripts.support import ( +from spalloc_client.scripts.support import ( VERSION_RANGE_START, VERSION_RANGE_STOP, Terminate) -from spalloc.protocol_client import ProtocolError +from spalloc_client.protocol_client import ProtocolError @pytest.fixture diff --git a/tests/scripts/test_ps.py b/tests/scripts/test_ps.py index a75e4a22b..3d941afec 100644 --- a/tests/scripts/test_ps.py +++ b/tests/scripts/test_ps.py @@ -16,10 +16,11 @@ import datetime from mock import Mock, MagicMock import pytest -from spalloc.scripts.ps import main, render_job_list -from spalloc.scripts.support import VERSION_RANGE_START, VERSION_RANGE_STOP -from spalloc.term import Terminal -from spalloc import JobState +from spalloc_client.scripts.ps import main, render_job_list +from spalloc_client.scripts.support import ( + VERSION_RANGE_START, VERSION_RANGE_STOP) +from spalloc_client.term import Terminal +from spalloc_client import JobState @pytest.fixture diff --git a/tests/scripts/test_where_is.py b/tests/scripts/test_where_is.py index fe140f0e0..097598b42 100644 --- a/tests/scripts/test_where_is.py +++ b/tests/scripts/test_where_is.py @@ -14,9 +14,10 @@ import pytest from mock import Mock, MagicMock -from spalloc.scripts.where_is import main -from spalloc.scripts.support import VERSION_RANGE_START, VERSION_RANGE_STOP -from spalloc.protocol_client import ProtocolError +from spalloc_client.scripts.where_is import main +from spalloc_client.scripts.support import ( + VERSION_RANGE_START, VERSION_RANGE_STOP) +from spalloc_client.protocol_client import ProtocolError @pytest.fixture diff --git a/tests/test_config.py b/tests/test_config.py index 85dd64075..7a76bfb84 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -16,7 +16,7 @@ import shutil import os.path import pytest -from spalloc.config import read_config +from spalloc_client.config import read_config @pytest.yield_fixture diff --git a/tests/test_job.py b/tests/test_job.py index 911a2f0a2..fb831389d 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -16,9 +16,9 @@ from threading import Thread, Event import pytest from mock import Mock -from spalloc import Job, JobState, JobDestroyedError, ProtocolTimeoutError -from spalloc._keepalive_process import keep_job_alive -from spalloc.job import ( +from spalloc_client import Job, JobState, JobDestroyedError, ProtocolTimeoutError +from spalloc_client._keepalive_process import keep_job_alive +from spalloc_client.job import ( _JobStateTuple, _JobMachineInfoTuple, StateChangeTimeoutError, VERSION_RANGE_START, VERSION_RANGE_STOP) diff --git a/tests/test_protocol_client.py b/tests/test_protocol_client.py index 23e3fa721..0eef573fc 100644 --- a/tests/test_protocol_client.py +++ b/tests/test_protocol_client.py @@ -18,7 +18,7 @@ import logging import pytest from mock import Mock -from spalloc import ( +from spalloc_client import ( ProtocolClient, SpallocServerException, ProtocolTimeoutError, ProtocolError) from .common import MockServer diff --git a/tests/test_term.py b/tests/test_term.py index 22360b14a..88b56b93e 100644 --- a/tests/test_term.py +++ b/tests/test_term.py @@ -13,7 +13,7 @@ # limitations under the License. import pytest -from spalloc.term import ( +from spalloc_client.term import ( Terminal, render_table, render_definitions, render_boards, render_cells, DEFAULT_BOARD_EDGES) From 2d5a42ec7f1feb97f8e2a1e6db8f38b8b28af87b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 12:01:19 +0100 Subject: [PATCH 03/12] more spalloc_client --- spalloc_client/job.py | 13 +++++++------ tests/scripts/test_alloc.py | 25 +++++++++++++------------ tests/scripts/test_ps.py | 4 ++-- tests/test_job.py | 8 ++++---- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/spalloc_client/job.py b/spalloc_client/job.py index bceaab75f..3e1a819f1 100644 --- a/spalloc_client/job.py +++ b/spalloc_client/job.py @@ -161,8 +161,9 @@ def __init__(self, *args, **kwargs): The following keyword-only parameters below are used both to specify the server details as well as the job requirements. Most parameters - default to the values supplied in the local :py:mod:`~spalloc.config` - file allowing usage as in the examples above. + default to the values supplied in the local + :py:mod:`~spalloc_client.config` + file allowing usage as in the examples above. Parameters ---------- @@ -311,8 +312,8 @@ def __init__(self, *args, **kwargs): # Set-up and start background keepalive thread self._keepalive_process = subprocess.Popen(map(str, [ - sys.executable, "-m", "spalloc._keepalive_process", hostname, - port, self.id, self._keepalive, self._timeout, + sys.executable, "-m", "spalloc_client._keepalive_process", + hostname, port, self.id, self._keepalive, self._timeout, self._reconnect_delay]), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # Wait for it to announce that it is working @@ -579,7 +580,7 @@ def wait_for_state_change(self, old_state, timeout=None): Parameters ---------- - old_state : :py:class:`~spalloc.JobState` + old_state : :py:class:`~spalloc_client.JobState` The current state. timeout : float or None The number of seconds to wait for a change before timing out. If @@ -587,7 +588,7 @@ def wait_for_state_change(self, old_state, timeout=None): Returns ------- - :py:class:`~spalloc.JobState` + :py:class:`~spalloc_client.JobState` The new state, or old state if timed out. """ finish_time = make_timeout(timeout) diff --git a/tests/scripts/test_alloc.py b/tests/scripts/test_alloc.py index 660a0bcbe..0e08b144f 100644 --- a/tests/scripts/test_alloc.py +++ b/tests/scripts/test_alloc.py @@ -32,8 +32,8 @@ def filename(): @pytest.fixture def mock_input(monkeypatch): m = Mock() - import spalloc.scripts.alloc - monkeypatch.setattr(spalloc.scripts.alloc, "_input", m) + import spalloc_client.scripts.alloc + monkeypatch.setattr(spalloc_client.scripts.alloc, "_input", m) return m @@ -50,8 +50,8 @@ def mock_popen(monkeypatch): def mock_job(monkeypatch): # A fake job which immediately exits with a connection error. job_returner = Mock(side_effect=OSError()) - import spalloc.scripts.alloc - monkeypatch.setattr(spalloc.scripts.alloc, "Job", job_returner) + import spalloc_client.scripts.alloc + monkeypatch.setattr(spalloc_client.scripts.alloc, "Job", job_returner) return job_returner @@ -59,8 +59,8 @@ def mock_job(monkeypatch): def mock_working_job(monkeypatch): job = Mock() job_returner = Mock(return_value=job) - import spalloc.scripts.alloc - monkeypatch.setattr(spalloc.scripts.alloc, "Job", job_returner) + import spalloc_client.scripts.alloc + monkeypatch.setattr(spalloc_client.scripts.alloc, "Job", job_returner) job.id = 123 job.state = JobState.queued @@ -80,15 +80,16 @@ def mock_working_job(monkeypatch): @pytest.fixture def mock_mc(monkeypatch): mc = Mock(return_value=Mock()) - import spalloc.scripts.alloc - monkeypatch.setattr(spalloc.scripts.alloc, "MachineController", mc) + import spalloc_client.scripts.alloc + monkeypatch.setattr(spalloc_client.scripts.alloc, "MachineController", mc) return mc @pytest.fixture def no_rig(monkeypatch): - import spalloc.scripts.alloc - monkeypatch.setattr(spalloc.scripts.alloc, "MachineController", None) + import spalloc_client.scripts.alloc + monkeypatch.setattr( + spalloc_client.scripts.alloc, "MachineController", None) def test_write_ips_to_file_empty(filename): @@ -359,9 +360,9 @@ def test_quiet_args(capsys, basic_config_file, mock_working_job, mock_input): @pytest.mark.parametrize("args,enable", [("--debug", True), ("", False)]) def test_debug_args(basic_config_file, mock_job, monkeypatch, args, enable): - import spalloc.scripts.alloc + import spalloc_client.scripts.alloc logging = Mock() - monkeypatch.setattr(spalloc.scripts.alloc, "logging", logging) + monkeypatch.setattr(spalloc_client.scripts.alloc, "logging", logging) assert main(args.split()) == 6 diff --git a/tests/scripts/test_ps.py b/tests/scripts/test_ps.py index 3d941afec..0c5d66908 100644 --- a/tests/scripts/test_ps.py +++ b/tests/scripts/test_ps.py @@ -42,9 +42,9 @@ def client(client_factory): @pytest.fixture def faux_render(monkeypatch): - import spalloc.scripts.ps + import spalloc_client.scripts.ps render_job_list = Mock() - monkeypatch.setattr(spalloc.scripts.ps, "render_job_list", render_job_list) + monkeypatch.setattr(spalloc_client.scripts.ps, "render_job_list", render_job_list) return render_job_list diff --git a/tests/test_job.py b/tests/test_job.py index fb831389d..873a7cc6e 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -33,11 +33,11 @@ def client(monkeypatch): client.version.return_value = GOOD_VERSION client.create_job.return_value = 123 - import spalloc.job - monkeypatch.setattr(spalloc.job, "ProtocolClient", + import spalloc_client.job + monkeypatch.setattr(spalloc_client.job, "ProtocolClient", Mock(return_value=client)) - import spalloc._keepalive_process - monkeypatch.setattr(spalloc._keepalive_process, "ProtocolClient", + import spalloc_client._keepalive_process + monkeypatch.setattr(spalloc_client._keepalive_process, "ProtocolClient", Mock(return_value=client)) return client From b50761575ee2fd5dc9d2324e1ffe6436795a53b0 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 12:14:03 +0100 Subject: [PATCH 04/12] still more spalloc_client --- .github/workflows/python_actions.yml | 11 ++++++++--- tests/scripts/test_ps.py | 3 ++- tests/test_job.py | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 5c91cf48e..019d26da2 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -29,8 +29,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Checkout uses: actions/checkout@v3 + - name: Checkout SupportScripts uses: actions/checkout@v3 with: @@ -39,6 +41,7 @@ jobs: - name: Install pip, etc uses: ./support/actions/python-tools + - name: Install Spinnaker Dependencies uses: ./support/actions/install-spinn-deps with: @@ -48,7 +51,7 @@ jobs: - name: Install uses: ./support/actions/run-install - - name: Extra setup + - name: Docs requirements Install run: pip install -r requirements-docs.txt - name: Test with pytest @@ -61,11 +64,12 @@ jobs: coveralls-token: ${{ secrets.GITHUB_TOKEN }} - name: Lint with flake8 - run: flake8 spalloc tests + run: flake8 spalloc_client tests + - name: Lint with pylint uses: ./support/actions/pylint with: - package: spalloc + package: spalloc_client exitcheck: 39 - name: Run rat copyright enforcement @@ -73,6 +77,7 @@ jobs: uses: ./support/actions/check-copyrights with: config_file: rat_asl20.xml + - name: Build documentation with sphinx if: matrix.python-version == 3.8 uses: ./support/actions/sphinx diff --git a/tests/scripts/test_ps.py b/tests/scripts/test_ps.py index 0c5d66908..b52b71700 100644 --- a/tests/scripts/test_ps.py +++ b/tests/scripts/test_ps.py @@ -44,7 +44,8 @@ def client(client_factory): def faux_render(monkeypatch): import spalloc_client.scripts.ps render_job_list = Mock() - monkeypatch.setattr(spalloc_client.scripts.ps, "render_job_list", render_job_list) + monkeypatch.setattr( + spalloc_client.scripts.ps, "render_job_list", render_job_list) return render_job_list diff --git a/tests/test_job.py b/tests/test_job.py index 873a7cc6e..098a9ffa4 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -16,7 +16,8 @@ from threading import Thread, Event import pytest from mock import Mock -from spalloc_client import Job, JobState, JobDestroyedError, ProtocolTimeoutError +from spalloc_client import ( + Job, JobState, JobDestroyedError, ProtocolTimeoutError) from spalloc_client._keepalive_process import keep_job_alive from spalloc_client.job import ( _JobStateTuple, _JobMachineInfoTuple, StateChangeTimeoutError, From a7eb8f6f54626d8be04f1fc1ca31cd43220d40fa Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 12:22:11 +0100 Subject: [PATCH 05/12] spalloc_client in docs --- docs/source/index.rst | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 816fd4a93..5e7a5742f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -62,28 +62,28 @@ three-board machine:: Configuration file format and defaults -------------------------------------- -.. automodule:: spalloc.config +.. automodule:: spalloc_client.config ``spalloc``: Allocate SpiNNaker machines ---------------------------------------- -.. automodule:: spalloc.scripts.alloc +.. automodule:: spalloc_client.scripts.alloc ``spalloc-job``: Manage and reset existing jobs and their boards ---------------------------------------------------------------- -.. automodule:: spalloc.scripts.job +.. automodule:: spalloc_client.scripts.job ``spalloc-ps``: List all running jobs ------------------------------------- -.. automodule:: spalloc.scripts.ps +.. automodule:: spalloc_client.scripts.ps ``spalloc-machine``: List available machines and their running jobs ------------------------------------------------------------------- -.. automodule:: spalloc.scripts.machine +.. automodule:: spalloc_client.scripts.machine ``spalloc-where-is``: Query the server for the physical/logical locations of boards/chips ----------------------------------------------------------------------------------------- -.. automodule:: spalloc.scripts.where_is +.. automodule:: spalloc_client.scripts.where_is Python library @@ -91,11 +91,11 @@ Python library Spalloc provides a pair of Python libraries which enable basic high- and low-level interaction with a spalloc server. The high-level -:py:class:`~spalloc.Job` interface makes the task of creating jobs (and keeping -them alive) straight-forward but only facilitates basic job management -functions such as resetting boards and getting their IP addresses. The -low-level :py:class:`~spalloc.ProtocolClient` provides an RPC-like interface to -the spalloc server enabling any spalloc server command to be sent. +:py:class:`~spalloc_client.Job` interface makes the task of creating jobs +(and keeping them alive) straight-forward but only facilitates basic job +management functions such as resetting boards and getting their IP addresses. +The low-level :py:class:`~spalloc_client.ProtocolClient` provides an RPC-like +interface to the spalloc server enabling any spalloc server command to be sent. .. note:: @@ -106,28 +106,28 @@ the spalloc server enabling any spalloc server command to be sent. .. _protocol: https://spalloc-server.readthedocs.org/en/stable/protocol.html -High level interface (:py:class:`spalloc.Job`) +High level interface (:py:class:`spalloc_client.Job`) `````````````````````````````````````````````` -.. autoclass:: spalloc.Job +.. autoclass:: spalloc_client.Job :members: :special-members: -.. autoclass:: spalloc.JobState +.. autoclass:: spalloc_client.JobState :members: -.. autoexception:: spalloc.JobDestroyedError +.. autoexception:: spalloc_client.JobDestroyedError -.. autoexception:: spalloc.StateChangeTimeoutError +.. autoexception:: spalloc_clientc.StateChangeTimeoutError -Lower level interface (:py:class:`spalloc.ProtocolClient`) +Lower level interface (:py:class:`spalloc_client.ProtocolClient`) `````````````````````````````````````````````````````````` -.. autoclass:: spalloc.ProtocolClient +.. autoclass:: spalloc_client.ProtocolClient :members: :special-members: -.. autoexception:: spalloc.ProtocolTimeoutError +.. autoexception:: spalloc_client.ProtocolTimeoutError Indicies and Tables From d019d14c5adfe0b259fce368b21a1d9d618fa23a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 12:27:08 +0100 Subject: [PATCH 06/12] title underline --- docs/source/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 5e7a5742f..cbceda4c3 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -107,7 +107,7 @@ interface to the spalloc server enabling any spalloc server command to be sent. .. _protocol: https://spalloc-server.readthedocs.org/en/stable/protocol.html High level interface (:py:class:`spalloc_client.Job`) -`````````````````````````````````````````````` +````````````````````````````````````````````````````` .. autoclass:: spalloc_client.Job :members: @@ -121,7 +121,7 @@ High level interface (:py:class:`spalloc_client.Job`) .. autoexception:: spalloc_clientc.StateChangeTimeoutError Lower level interface (:py:class:`spalloc_client.ProtocolClient`) -`````````````````````````````````````````````````````````` +````````````````````````````````````````````````````````````````` .. autoclass:: spalloc_client.ProtocolClient :members: From d7b82b37ce0d3bda47aa46723340e06dfa973c8a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 13:01:07 +0100 Subject: [PATCH 07/12] doc spacing --- spalloc_client/job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spalloc_client/job.py b/spalloc_client/job.py index 3e1a819f1..730af2644 100644 --- a/spalloc_client/job.py +++ b/spalloc_client/job.py @@ -163,7 +163,7 @@ def __init__(self, *args, **kwargs): the server details as well as the job requirements. Most parameters default to the values supplied in the local :py:mod:`~spalloc_client.config` - file allowing usage as in the examples above. + file allowing usage as in the examples above. Parameters ---------- From e795aa624925ce43fc907bccdbfdf8ae56cc3b50 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 13:04:40 +0100 Subject: [PATCH 08/12] fix spelling --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index cbceda4c3..919992d70 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -118,7 +118,7 @@ High level interface (:py:class:`spalloc_client.Job`) .. autoexception:: spalloc_client.JobDestroyedError -.. autoexception:: spalloc_clientc.StateChangeTimeoutError +.. autoexception:: spalloc_client.StateChangeTimeoutError Lower level interface (:py:class:`spalloc_client.ProtocolClient`) ````````````````````````````````````````````````````````````````` From 708207c6e598b7385e350c31fe6d578c94aef5db Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 30 Mar 2023 16:58:12 +0100 Subject: [PATCH 09/12] leave the install of coverage,flake8, pylint and spinx to the scripts --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 658af425e..7edd81160 100644 --- a/setup.cfg +++ b/setup.cfg @@ -54,9 +54,6 @@ install_requires = [options.extras_require] test = - flake8 >= 5.0 - coverage >= 4.4, < 5.0 # pytest will be brought in by pytest-cov pytest-cov - pytest-timeout mock \ No newline at end of file From 3a7dc6bafa2f14e329c9d51377330216865152ee Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 3 Apr 2023 12:05:37 +0100 Subject: [PATCH 10/12] put requirements files back in until we decide to keep tox.ini or not --- requirements-test.txt | 22 ++++++++++++++++++++++ requirements.txt | 15 +++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 requirements-test.txt create mode 100644 requirements.txt diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 000000000..f4068ffef --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2016 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test suite requirements +-r requirements.txt +coverage >= 4.4, < 5.0 +pytest-cov +# pytest will be brought in by pytest-cov +pytest-timeout +flake8 +mock diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..c9f6d085b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2016 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SpiNNUtilities == 1!6.0.1 From a7c415266c17ad0d12780513df11f92914058aee Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 3 Apr 2023 12:19:03 +0100 Subject: [PATCH 11/12] cleanup setup --- setup.cfg | 5 +++++ setup.py | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index e9d176909..14acfe442 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,6 +52,11 @@ install_requires = jsonschema SpiNNUtilities == 1!6.0.1 +[options.packages.find] +include = + spalloc_client + spalloc_client.* + [options.extras_require] test = # pytest will be brought in by pytest-cov diff --git a/setup.py b/setup.py index ecc61bec8..4c7a086f5 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +import distutils.dir_util from setuptools import setup +import os +import sys + + if __name__ == '__main__': - setup() \ No newline at end of file + # Repeated installs assume files have not changed + # https://github.com/pypa/setuptools/issues/3236 + if len(sys.argv) > 0 and sys.argv[1] == 'egg_info': + # on the first call to setpy.py remove files left by previous install + this_dir = os.path.dirname(os.path.abspath(__file__)) + build_dir = os.path.join(this_dir, "build") + if os.path.isdir(build_dir): + distutils.dir_util.remove_tree(build_dir) + egg_dir = os.path.join(this_dir, "spalloc.egg-info") + if os.path.isdir(egg_dir): + distutils.dir_util.remove_tree(egg_dir) + setup() From 1cd3551add6cc4655cfeb5cdc97598149da5300a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 4 Apr 2023 11:30:45 +0100 Subject: [PATCH 12/12] add CITATION.cff to MANIFEST.in --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 3487a3d39..8f37c2d96 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include LICENSE LICENSE_POLICY.md README.rst +include LICENSE LICENSE_POLICY.md README.rst CITATION.cff