Skip to content
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
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[[tool.mypy.overrides]]
module = ["parameterized"]
ignore_missing_imports = true
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ test =
testfixtures
httpretty != 1.0.0
deepdiff
parameterized

2 changes: 0 additions & 2 deletions spinn_machine/spinn_machine.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ version = None
* This replaces deprecated "width" and "height" options
* "versions" option is for testing only and picks a version based on python version
# Used Instead of version if multiple versions should be tested!
versions = None
@versions = Testing Option. Picks a valid version based on python version. Requires [virtual_board](virtual_board)
width = None
@width = Deprecated use [version](version). Width for a virtual machine.
If used requires [height](height) and [virtual_board](virtual_board)
Expand Down
10 changes: 7 additions & 3 deletions spinn_machine/version/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .version_factory import (FIVE, SPIN2_1CHIP, SPIN2_48CHIP, THREE,
version_factory)
from .version_factory import (
ALL_BOARD_TYPES, BIG_BOARD_TYPES, FOUR_PLUS_BOARD_TYPES,
FPGA_BOARD_TYPES, MANY_BOARD_TYPES,
FIVE, SPIN2_1CHIP, SPIN2_48CHIP, THREE, version_factory)

__all__ = ["FIVE", "SPIN2_1CHIP", "SPIN2_48CHIP", "THREE", "version_factory"]
__all__ = ["ALL_BOARD_TYPES", "BIG_BOARD_TYPES", "FOUR_PLUS_BOARD_TYPES",
"FPGA_BOARD_TYPES", "MANY_BOARD_TYPES", "version_factory",
"FIVE", "SPIN2_1CHIP", "SPIN2_48CHIP", "THREE"]
32 changes: 19 additions & 13 deletions spinn_machine/version/version_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

from __future__ import annotations
import logging
import sys
from typing import Optional, TYPE_CHECKING
import os

from typing_extensions import Never

from spinn_utilities.config_holder import (
get_config_bool, get_config_int_or_none, get_config_str_or_none)
get_config_bool, get_config_int_or_none, get_config_str_or_none,
has_config_option)
from spinn_utilities.log import FormatAdapter
from spinn_machine.exceptions import SpinnMachineException
from .version_strings import VersionStrings
if TYPE_CHECKING:
from .abstract_version import AbstractVersion

Expand All @@ -36,6 +36,19 @@
SPIN2_1CHIP = 201
SPIN2_48CHIP = 248

ALL_BOARD_TYPES = [["THREE", str(THREE)], ["FIVE", str(FIVE)],
["SPIN2_1CHIP", str(SPIN2_1CHIP)],
["SPIN2_48CHIP", str(SPIN2_48CHIP)]]
FOUR_PLUS_BOARD_TYPES = [["THREE", THREE], ["FIVE", str(FIVE)],
["SPIN2_48CHIP", str(SPIN2_48CHIP)]]
BIG_BOARD_TYPES = [["FIVE", str(FIVE)],
["SPIN2_48CHIP", str(SPIN2_48CHIP)]]
FPGA_BOARD_TYPES = [["FIVE", str(FIVE)]]
if os.environ.get("SPINNAKER_TEST_ALL") == "true":
MANY_BOARD_TYPES = ALL_BOARD_TYPES
else:
MANY_BOARD_TYPES = BIG_BOARD_TYPES


def version_factory() -> AbstractVersion:
"""
Expand Down Expand Up @@ -86,16 +99,9 @@ def version_factory() -> AbstractVersion:

def _get_cfg_version() -> Optional[int]:
version = get_config_int_or_none("Machine", "version")
versions = get_config_str_or_none("Machine", "versions")
if versions is not None:
if version is not None:
raise SpinnMachineException(
f"Both {version=} and {versions=} found in cfg")
vs = VersionStrings.from_string(versions)
options = vs.options
# Use the fact that we run actions against different python versions
minor = sys.version_info.minor
version = options[minor % len(options)]
if has_config_option("Machine", "versions"):
raise SpinnMachineException(
"versions in cfg is no longer supported.")
if version is None:
logger.warning(
"The cfg has no version. This is deprecated! Please add a version")
Expand Down
99 changes: 0 additions & 99 deletions spinn_machine/version/version_strings.py

This file was deleted.

53 changes: 10 additions & 43 deletions unittests/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from parameterized import parameterized
import unittest

from spinn_utilities.config_holder import set_config
from spinn_utilities.exceptions import (ConfigException, DataNotYetAvialable)

from spinn_machine import virtual_machine
from spinn_machine.config_setup import unittest_setup
from spinn_machine.data import MachineDataView
from spinn_machine.data.machine_data_writer import MachineDataWriter
from spinn_machine.exceptions import SpinnMachineException
from spinn_machine.version import FIVE, THREE, SPIN2_48CHIP
from spinn_machine.version.version_strings import VersionStrings
from spinn_machine.version import BIG_BOARD_TYPES, FIVE, THREE, SPIN2_48CHIP


class TestSimulatorData(unittest.TestCase):
Expand Down Expand Up @@ -59,8 +61,9 @@ def test_machine(self) -> None:
writer.set_machine("bacon") # type: ignore[arg-type]
self.assertTrue(MachineDataView.has_machine())

def test_where_is_mocked(self) -> None:
set_config("Machine", "versions", VersionStrings.BIG.text)
@parameterized.expand(BIG_BOARD_TYPES) # needs multiple boards
def test_where_is_mocked(self, _: str, ver_num: str) -> None:
set_config("Machine", "version", ver_num)
writer = MachineDataWriter.mock()
self.assertEqual(
"No Machine created yet",
Expand All @@ -77,8 +80,9 @@ def test_where_is_mocked(self) -> None:
"global chip 2, 8 on 127.0.0.0 is chip 6, 4 on 127.0.8.4",
MachineDataView.where_is_chip(machine[2, 8]))

def test_where_is_setup(self) -> None:
set_config("Machine", "versions", VersionStrings.BIG.text)
@parameterized.expand(BIG_BOARD_TYPES) # Needs multiple boards
def test_where_is_setup(self, _: str, ver_num: str) -> None:
set_config("Machine", "version", ver_num)
writer = MachineDataWriter.setup()
self.assertEqual(
"No Machine created yet",
Expand Down Expand Up @@ -138,43 +142,6 @@ def test_v_to_p_spin2(self) -> None:
self.assertEqual("",
writer.get_physical_string((1, 2), 234))

def test_mock_any(self) -> None:
# Should work with any version
set_config("Machine", "versions", VersionStrings.ANY.text)
# check there is a value not what it is
machine = MachineDataView.get_machine()
self.assertGreaterEqual(machine.n_chips, 1)

def test_mock_4_or_more(self) -> None:
# Should work with any version that has 4 plus Chips
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.text)
# check there is a value not what it is
machine = MachineDataView.get_machine()
self.assertGreaterEqual(machine.n_chips, 4)

def test_mock_big(self) -> None:
# Should work with any version
set_config("Machine", "versions", VersionStrings.BIG.text)
# check there is a value not what it is
machine = MachineDataView.get_machine()
self.assertGreaterEqual(machine.n_chips, 48)

def test_mock3(self) -> None:
# Should work with any version
set_config("Machine", "version", "3")
# check there is a value not what it is
MachineDataView.get_machine()

def test_mock5(self) -> None:
set_config("Machine", "version", "5")
# check there is a value not what it is
MachineDataView.get_machine()

def test_mock201(self) -> None:
set_config("Machine", "version", "201")
# check there is a value not what it is
MachineDataView.get_machine()

def test_get_monitors(self) -> None:
writer = MachineDataWriter.setup()
self.assertEqual(0, MachineDataView.get_all_monitor_cores())
Expand Down
3 changes: 0 additions & 3 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
from typing import Optional
import unittest

from spinn_utilities.config_holder import set_config
from spinn_utilities.ordered_set import OrderedSet
from spinn_machine import Link, Router, Chip
from spinn_machine.config_setup import unittest_setup
from spinn_machine.version.version_strings import VersionStrings


class TestingChip(unittest.TestCase):

def setUp(self) -> None:
unittest_setup()
set_config("Machine", "versions", VersionStrings.ANY.text)
self._x = 0
self._y = 1

Expand Down
17 changes: 11 additions & 6 deletions unittests/test_ignore_cores.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,28 @@
# limitations under the License.

import unittest

from parameterized import parameterized

from spinn_utilities.config_holder import set_config
from spinn_utilities.exceptions import ConfigException

from spinn_machine.config_setup import unittest_setup
from spinn_machine.exceptions import SpinnMachineException
from spinn_machine.ignores import IgnoreChip, IgnoreCore, IgnoreLink
from spinn_machine.version import SPIN2_1CHIP
from spinn_machine.version import SPIN2_1CHIP, MANY_BOARD_TYPES
from spinn_machine.version.version_201 import Version201
from spinn_machine.version.version_5 import Version5
from spinn_machine.version.version_strings import VersionStrings


class TestDownCores(unittest.TestCase):

def setUp(self) -> None:
unittest_setup()

def test_bad_ignores(self) -> None:
set_config("Machine", "versions", VersionStrings.BIG.text)
@parameterized.expand(MANY_BOARD_TYPES)
def test_bad_ignores(self, _: str, ver_num: str) -> None:
set_config("Machine", "version", ver_num)

try:
IgnoreChip.parse_string("4,4,3,4:6,6,ignored_ip")
Expand All @@ -50,8 +54,9 @@ def test_bad_ignores(self) -> None:
except Exception as ex:
self.assertTrue("downed_link" in str(ex))

def test_down_cores_bad_string(self) -> None:
set_config("Machine", "versions", VersionStrings.BIG.text)
@parameterized.expand(MANY_BOARD_TYPES)
def test_down_cores_bad_string(self, _: str, ver_num: str) -> None:
set_config("Machine", "version", ver_num)
with self.assertRaises(ConfigException):
IgnoreCore.parse_string("4,4,bacon")

Expand Down
Loading
Loading