diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index d99038264..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,14 +41,17 @@ 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: Extra setup + + - name: Install + uses: ./support/actions/run-install + + - name: Docs requirements Install run: pip install -r requirements-docs.txt - name: Test with pytest @@ -59,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 + with: + package: spalloc_client exitcheck: 39 - name: Run rat copyright enforcement @@ -71,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 @@ -79,4 +86,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..8f37c2d96 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 CITATION.cff 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..919992d70 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) @@ -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_client.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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..ddb15f360 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +# 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. + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..14acfe442 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,64 @@ +# 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_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 +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.packages.find] +include = + spalloc_client + spalloc_client.* + +[options.extras_require] +test = + # pytest will be brought in by pytest-cov + pytest-cov + mock \ No newline at end of file diff --git a/setup.py b/setup.py index 21d871e96..4c7a086f5 100644 --- a/setup.py +++ b/setup.py @@ -12,64 +12,22 @@ # 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" -) +import distutils.dir_util +from setuptools import setup +import os +import sys + + +if __name__ == '__main__': + # 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() 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 98% rename from spalloc/job.py rename to spalloc_client/job.py index 23737bb07..730af2644 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) @@ -160,7 +161,8 @@ 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` + default to the values supplied in the local + :py:mod:`~spalloc_client.config` file allowing usage as in the examples above. Parameters @@ -310,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 @@ -335,7 +337,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) @@ -578,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 @@ -586,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/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..0e08b144f 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 @@ -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_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..b52b71700 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 @@ -41,9 +42,10 @@ 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/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..098a9ffa4 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -16,9 +16,10 @@ 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) @@ -33,11 +34,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 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)