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

Use a complex workflow on Support scripts #404

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
100 changes: 8 additions & 92 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,95 +18,11 @@
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"]

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 mypy
run: pip install mypy

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

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

- name: Test with pytest
uses: ./support/actions/pytest
with:
tests: unittests
coverage: ${{ matrix.python-version == 3.12 }}
cover-packages: spinnman
coveralls-token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint with flake8
run: flake8 spinnman unittests
- name: Lint with pylint
uses: ./support/actions/pylint
with:
package: spinnman
exitcheck: 31 # Action fails on any message
language: en_GB
rcfile: global_strict
- name: Lint with mypy
run: mypy spinnman

validate:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [3.12]

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 SpiNNMachine
install: true
- name: Run Install
uses: ./support/actions/run-install

- name: Run rat copyright enforcement
uses: ./support/actions/check-copyrights
with:
config_file: rat_asl20.xml
- name: Build documentation with sphinx
uses: ./support/actions/sphinx
with:
directory: doc/source
- name: Validate CITATION.cff
uses: dieghernan/cff-validator@main
call:
uses: SpiNNakerManchester/SupportScripts/.github/workflows/python_checks.yml@main
with:
base-package: spinnman
dependencies: SpiNNUtils SpiNNMachine
test_directories: unittests spinnman_integration_tests
flake8-packages: spinnman unittests spinnman_integration_tests
secrets: inherit
13 changes: 13 additions & 0 deletions spinnman_integration_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2024 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.
73 changes: 73 additions & 0 deletions spinnman_integration_tests/test_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright (c) 2024 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.

import os
import unittest

from spinn_utilities.config_holder import set_config

from spinn_machine.version import FIVE
from spinnman.config_setup import unittest_setup
from spinnman.spalloc import SpallocClient, SpallocState


class TestTransceiver(unittest.TestCase):

def setUp(self):
unittest_setup()
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)
# job = client.create_job_rect_at_board(
# WIDTH, HEIGHT, triad=(x, y, b), machine_name=SPALLOC_MACHINE,
# max_dead_boards=1)
job = client.create_job(
num_boards=2, machine_name=self.spalloc_machine)
with job:
job.wait_until_ready()

connections = job.get_connections()
self.assertGreaterEqual(len(connections), 2)
self.assertIn((0, 0), connections)

txrx = job.create_transceiver()

dims = txrx._get_machine_dimensions()
# May be 12 as we only asked for 2 boards
self.assertGreaterEqual(dims.height, 12)
self.assertGreaterEqual(dims.width, 12)

machine = txrx.get_machine_details()
self.assertGreaterEqual(len(machine.ethernet_connected_chips), 2)

state = job.get_state()
self.assertEqual(state, SpallocState.READY)

credentials = job.get_session_credentials_for_db()
self.assertIn(('SPALLOC', 'service uri'), credentials)
self.assertIn(('SPALLOC', 'job uri'), credentials)
self.assertIn(('COOKIE', 'JSESSIONID'), credentials)
self.assertIn(('HEADER', 'X-CSRF-TOKEN'), credentials)

client.close() # print(2^(1/(2^1)


if __name__ == '__main__':
unittest.main()