Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github action fixes #97

Merged
merged 56 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ea45b86
global actions
Christian-B Jun 24, 2024
ef7229e
docs
Christian-B Jun 25, 2024
e30e66b
pylint fixes
Christian-B Jun 26, 2024
1bd0a14
flake8
Christian-B Jun 26, 2024
d170db6
pylint fixes
Christian-B Jun 26, 2024
3a2ff6b
fix f string
Christian-B Jun 26, 2024
1d60bd2
f string
Christian-B Jun 26, 2024
9eee347
docs
Christian-B Jun 26, 2024
41daf68
flake8
Christian-B Jun 26, 2024
46e3bae
flake8
Christian-B Jun 26, 2024
6b41eb2
remove not working disable
Christian-B Jun 27, 2024
ec0212d
fix spellings
Christian-B Jun 27, 2024
3b797d2
fix a spelling
Christian-B Jun 27, 2024
05284f1
docs
Christian-B Jun 27, 2024
277342b
spacing
Christian-B Jun 27, 2024
fe94c65
types-appdirs
Christian-B Jun 27, 2024
992ab5d
typing
Christian-B Jun 27, 2024
e3abf1a
simplify Terminate exception
Christian-B Jun 27, 2024
93b8388
Merge branch 'simplify_terminate' into use_build
Christian-B Jun 27, 2024
f1f086e
Flake8
Christian-B Jun 27, 2024
fa611b9
docs
Christian-B Jun 27, 2024
a29be98
fix types
Christian-B Jun 27, 2024
19b5ba0
flake8
Christian-B Jun 27, 2024
6b2fa2c
flake8
Christian-B Jun 27, 2024
4508986
reorder imports
Christian-B Jun 27, 2024
d414055
typing
Christian-B Jun 27, 2024
39bf8bf
flake8
Christian-B Jun 27, 2024
37f5ca4
more typing
Christian-B Jun 27, 2024
c17ea08
flake8
Christian-B Jun 27, 2024
6fa3d14
typing
Christian-B Jun 27, 2024
4de6031
Terminal TableType
Christian-B Jun 27, 2024
2e159d0
flake8
Christian-B Jun 27, 2024
7654416
more typing
Christian-B Jun 27, 2024
fdb9871
increase default timout
Christian-B Jul 1, 2024
90aab29
typing
Christian-B Jul 1, 2024
3ec07a2
overrides
Christian-B Jul 1, 2024
995d505
TIMEOUT constant
Christian-B Jul 1, 2024
152e7cb
typing
Christian-B Jul 1, 2024
55c2b8d
flake8
Christian-B Jul 1, 2024
f330ce5
flake8
Christian-B Jul 1, 2024
066e817
sphinx_directory
Christian-B Jul 1, 2024
ccbd2b4
times differ between operating systems
Christian-B Jul 1, 2024
79dcd37
fix times differ between operating systems
Christian-B Jul 1, 2024
f892516
Darwin asserts
Christian-B Jul 1, 2024
b0cdfb5
mock act weird on macos
Christian-B Jul 1, 2024
a30432d
test adjustments for different systems
Christian-B Jul 1, 2024
7dbbca4
mac is different
Christian-B Jul 1, 2024
4b851ab
skip on mac
Christian-B Jul 1, 2024
d45ad27
MagicMock
Christian-B Jul 1, 2024
fd398ff
normal Mock
Christian-B Jul 1, 2024
35217d4
skip test on mac due to mock weirdness
Christian-B Jul 1, 2024
62d3974
Except PemmissionError
Christian-B Jul 1, 2024
81be4ea
strftime("%s") does not work in windows
Christian-B Jul 2, 2024
5f2a9cf
adapt time tests for windows
Christian-B Jul 2, 2024
ed1912e
does not work in widnows either
Christian-B Jul 2, 2024
df3144c
does not work in windows
Christian-B Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 12 additions & 70 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,76 +15,18 @@
# This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python Build
name: Python Actions
on: [push]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
call:
uses: SpiNNakerManchester/SupportScripts/.github/workflows/python_checks.yml@main
with:
dependencies: SpiNNUtils
test_directories: tests
coverage-package: spalloc tests
flake8-packages: spalloc_client tests
pylint-packages: spalloc_client
mypy-packages: spalloc_client tests
sphinx_directory: docs/source
secrets: inherit

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Checkout
uses: actions/checkout@v4

- name: Checkout SupportScripts
uses: actions/checkout@v4
with:
repository: SpiNNakerManchester/SupportScripts
path: support

- name: Install pip, etc
uses: ./support/actions/python-tools

- name: Install Spinnaker Dependencies
uses: ./support/actions/install-spinn-deps
with:
repositories: SpiNNUtils
install: true

- name: Install
uses: ./support/actions/run-install

- name: Docs requirements Install
run: pip install -r requirements-docs.txt

- name: Test with pytest
uses: ./support/actions/pytest
with:
tests: tests
options: --durations=10 --timeout=120
coverage: ${{ matrix.python-version == 3.12 }}
cover-packages: spalloc tests
coveralls-token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint with flake8
run: flake8 spalloc_client tests

- name: Lint with pylint
uses: ./support/actions/pylint
with:
package: spalloc_client
exitcheck: 39

- name: Run rat copyright enforcement
if: matrix.python-version == 3.12
uses: ./support/actions/check-copyrights
with:
config_file: rat_asl20.xml

- name: Build documentation with sphinx
if: matrix.python-version == 3.12
uses: ./support/actions/sphinx
with:
directory: docs/source

- name: Validate CITATION.cff
if: matrix.python-version == 3.12
uses: dieghernan/cff-validator@main
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ test =
# pytest will be brought in by pytest-cov
pytest-cov
mock
types-appdirs

[options.entry_points]
console_scripts =
Expand Down
2 changes: 1 addition & 1 deletion spalloc_client/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def make_timeout(delay_seconds):
return time.time() + delay_seconds


def render_timestamp(timestamp):
def render_timestamp(timestamp) -> str:
""" Convert a timestamp (Unix seconds) into a local human-readable\
timestamp string.
"""
Expand Down
15 changes: 10 additions & 5 deletions spalloc_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=wrong-spelling-in-docstring
""" The spalloc command-line tool and Python library determine their default
configuration options from a spalloc configuration file if present.

Expand Down Expand Up @@ -62,7 +63,7 @@
The name of a specific machine on which to run all jobs or None to use any
available machine. (Default: None)
``tags``
The set of tags, comma seperated, to require a machine to have when
The set of tags, comma separated, to require a machine to have when
allocating jobs. (Default: default)
``min_ratio``
Require that when allocating a number of boards the allocation is at least
Expand All @@ -78,17 +79,19 @@
requires the allocation of a whole machine. If False, wrap-around links may
or may-not be present in allocated machines. (Default: False)
"""
import configparser
import os.path
from typing import Any, Dict, List, Optional

import appdirs
import configparser

# The application name to use in config file names
_name = "spalloc"

# Standard config file names/locations
SYSTEM_CONFIG_FILE = appdirs.site_config_dir(_name)
USER_CONFIG_FILE = appdirs.user_config_dir(_name)
CWD_CONFIG_FILE = os.path.join(os.curdir, ".{}".format(_name))
CWD_CONFIG_FILE = os.path.join(os.curdir, f".{_name}")

# Search path for config files (lowest to highest priority)
SEARCH_PATH = [
Expand All @@ -97,12 +100,14 @@
CWD_CONFIG_FILE,
]

TIMEOUT = 10.0

SECTION = "spalloc"
DEFAULT_CONFIG = {
"port": "22244",
"keepalive": "60.0",
"reconnect_delay": "5.0",
"timeout": "5.0",
"timeout": str(TIMEOUT),
"machine": "None",
"tags": "None",
"min_ratio": "0.333",
Expand Down Expand Up @@ -137,7 +142,7 @@ def _read_none_or_str(parser, option):
return parser.get(SECTION, option)


def read_config(filenames=None):
def read_config(filenames: Optional[List[str]] = None) -> Dict[str, Any]:
""" Attempt to read local configuration files to determine spalloc client
settings.

Expand Down
29 changes: 16 additions & 13 deletions spalloc_client/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# 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_client.scripts.support import (
VERSION_RANGE_START, VERSION_RANGE_STOP)

# A high-level Python interface for allocating SpiNNaker boards.

Expand All @@ -21,13 +19,18 @@
import subprocess
import time
import sys

from spalloc_client.scripts.support import (
VERSION_RANGE_START, VERSION_RANGE_STOP)

from .protocol_client import ProtocolClient, ProtocolTimeoutError
from .config import read_config, SEARCH_PATH
from .states import JobState
from ._utils import time_left, timed_out, make_timeout

logger = logging.getLogger(__name__)

# pylint: disable=wrong-spelling-in-docstring
# In Python 2, no default handler exists for software which doesn't configure
# its own logging so we must add one ourselves as per
# https://docs.python.org/3.1/library/logging.html#configuring-logging-for-a-library
Expand Down Expand Up @@ -267,11 +270,14 @@ def __init__(self, *args, **kwargs):
job_state = self._get_state()
if (job_state.state == JobState.unknown or
job_state.state == JobState.destroyed):
raise JobDestroyedError("Job {} does not exist: {}{}{}".format(
resume_job_id,
job_state.state.name,
": " if job_state.reason is not None else "",
job_state.reason if job_state.reason is not None else ""))
if job_state.reason is not None:
reason = job_state.reason
else:
reason = ""
raise JobDestroyedError(
f"Job {resume_job_id} does not exist: "
f"{job_state.state.name}"
f"{': ' if job_state.reason is not None else ''}{reason}")

# Snag the keepalive interval from the job
self._keepalive = job_state.keepalive
Expand Down Expand Up @@ -363,8 +369,7 @@ def _assert_compatible_version(self):
if not (VERSION_RANGE_START <= v_ints < VERSION_RANGE_STOP):
self._client.close()
raise ValueError(
"Server version {} is not compatible with this client.".format(
v))
f"Server version {v} is not compatible with this client.")

def _reconnect(self):
""" Reconnect to the server and check version.
Expand Down Expand Up @@ -758,8 +763,7 @@ class _JobStateTuple(namedtuple("_JobStateTuple",
reason the job was terminated.
"""

# Python 3.4 Workaround: https://bugs.python.org/issue24931
__slots__ = tuple()
__slots__ = ()


class _JobMachineInfoTuple(namedtuple("_JobMachineInfoTuple",
Expand All @@ -786,5 +790,4 @@ class _JobMachineInfoTuple(namedtuple("_JobMachineInfoTuple",
None if none allocated yet.
"""

# Python 3.4 Workaround: https://bugs.python.org/issue24931
__slots__ = tuple()
__slots__ = ()
Loading