Skip to content

Commit

Permalink
VersionStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Apr 12, 2024
1 parent 61b2ceb commit a9b3a62
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from spinn_utilities.config_holder import set_config
from spinn_machine.version import ANY_VERSION
from spinn_machine.version.version_strings import VersionStrings
from spinn_machine.tags.iptag import IPTag
from pacman.model.graphs.application import ApplicationVertex, ApplicationEdge
from pacman.model.graphs.machine import SimpleMachineVertex
Expand Down Expand Up @@ -116,7 +116,7 @@ def _place_vertices(app_vertexes, placements):

def test_database_interface():
unittest_setup()
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
set_config("Database", "create_database", "True")
set_config("Database", "create_routing_info_to_neuron_id_mapping", "True")

Expand Down
6 changes: 3 additions & 3 deletions unittests/data/test_simulator_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from spinn_utilities.data.utils_data_writer import _UtilsDataModel
from spinn_utilities.exceptions import (
DataNotYetAvialable, NotSetupException)
from spinn_machine.version import FOUR_PLUS_CHIPS
from spinn_machine.version.version_strings import VersionStrings
from spinnman.messages.scp.enums.signal import Signal
from spinn_utilities.socket_address import SocketAddress
from spinnman.model import ExecutableTargets
Expand Down Expand Up @@ -575,7 +575,7 @@ def test_executable_targets(self):

def test_gatherer_map(self):
writer = FecDataWriter.mock()
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
with self.assertRaises(DataNotYetAvialable):
FecDataView.get_gatherer_by_xy(0, 0)
with self.assertRaises(DataNotYetAvialable):
Expand Down Expand Up @@ -624,7 +624,7 @@ def test_gatherer_map(self):

def test_monitor_map(self):
writer = FecDataWriter.mock()
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
self.assertFalse(FecDataView.has_monitors())
with self.assertRaises(DataNotYetAvialable):
FecDataView.get_monitor_by_xy(0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import unittest
import os
from spinn_utilities.config_holder import set_config
from spinn_machine.version import ANY_VERSION, BIG_MACHINE
from spinn_machine.version.version_strings import VersionStrings
from pacman.model.graphs.machine import SimpleMachineVertex
from pacman.model.placements import Placement, Placements
from spinn_front_end_common.data.fec_data_writer import FecDataWriter
Expand All @@ -30,7 +30,7 @@ def setUp(self):
unittest_setup()

def test_use_database(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
f = BufferDatabase.default_database_file()
self.assertFalse(os.path.isfile(f), "no existing DB at first")

Expand All @@ -52,7 +52,7 @@ def test_use_database(self):
self.assertTrue(os.path.isfile(f), "DB still exists")

def test_placements(self):
set_config("Machine", "version", BIG_MACHINE)
set_config("Machine", "versions", VersionStrings.BIG.value)
writer = FecDataWriter.mock()
info = Placements([])
p1 = Placement(SimpleMachineVertex(None, label="V1"), 1, 2, 3)
Expand Down
30 changes: 14 additions & 16 deletions unittests/interface/ds/test_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from spinn_utilities.config_holder import set_config
from spinn_utilities.overrides import overrides
from spinn_machine import Chip, Router
from spinn_machine.version import (
ANY_VERSION, FOUR_PLUS_CHIPS, MULTIPLE_BOARDS)
from spinn_machine.version.version_strings import VersionStrings
from spinn_machine.virtual_machine import virtual_machine_by_min_size
from spinnman.model.enums import ExecutableType
from pacman.model.graphs.machine import SimpleMachineVertex
Expand Down Expand Up @@ -54,25 +53,24 @@ class TestDataSpecification(unittest.TestCase):

def setUp(self):
unittest_setup()
set_config("Machine", "version", 201)

def test_init(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex1 = _TestVertexWithBinary(
"off_board__system", ExecutableType.SYSTEM)
with DsSqlliteDatabase() as db:
DataSpecificationGenerator(0, 1, 2, vertex1, db)
DataSpecificationReloader(0, 1, 2, db)

def test_none_ds_vertex(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex = SimpleMachineVertex(0)
with DsSqlliteDatabase() as db:
with self.assertRaises(AttributeError):
DataSpecificationGenerator(0, 1, 2, vertex, db)

def test_bad_x_y_ds_vertex(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex = _TestVertexWithBinary(
"off_board__system", ExecutableType.SYSTEM)
width, height = FecDataView.get_machine_version().board_shape
Expand All @@ -82,7 +80,7 @@ def test_bad_x_y_ds_vertex(self):
DataSpecificationGenerator(width, height, 2, vertex, db)

def test_repeat_x_y_ds_vertex(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex1 = _TestVertexWithBinary(
"v1", ExecutableType.SYSTEM)
vertex2 = _TestVertexWithBinary(
Expand All @@ -93,7 +91,7 @@ def test_repeat_x_y_ds_vertex(self):
DataSpecificationGenerator(0, 1, 2, vertex2, db)

def test_core_infos(self):
set_config("Machine", "version", MULTIPLE_BOARDS)
set_config("Machine", "versions", VersionStrings.MULTIPLE_BOARDS.value)
writer = FecDataWriter.mock()
writer.set_machine(virtual_machine_by_min_size(9, 9))
with DsSqlliteDatabase() as db:
Expand All @@ -117,7 +115,7 @@ def test_core_infos(self):
self.assertEqual(app_infos, db.get_core_infos(False))

def test_bad_ethernet(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
router = Router([], 123)
width, height = FecDataView.get_machine_version().board_shape
bad = Chip(width, height, 15, router, 100, 8, 8)
Expand All @@ -129,7 +127,7 @@ def test_bad_ethernet(self):
DataSpecificationGenerator(width, height, 2, vertex, db)

def test_reserve_memory_region(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex = _TestVertexWithBinary(
"binary", ExecutableType.SYSTEM)
with DsSqlliteDatabase() as db:
Expand Down Expand Up @@ -171,11 +169,11 @@ def test_reserve_memory_region(self):
self.assertEqual(0, db.get_total_regions_size(0, 1, 3))

def test_switch_write_focus(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.ANY.value)
vertex = _TestVertexWithBinary(
"binary", ExecutableType.SYSTEM)
with DsSqlliteDatabase() as db:
dsg = DataSpecificationGenerator(0, 1, 2, vertex, db)
dsg = DataSpecificationGenerator(0, 0, 2, vertex, db)
dsg.reserve_memory_region(10, 123456, "test_region")
dsg.switch_write_focus(10)
# check internal fields used later are correct
Expand All @@ -185,7 +183,7 @@ def test_switch_write_focus(self):
dsg.switch_write_focus(8)

def test_pointers(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
# You can use a reference before defining it
vertex = _TestVertexWithBinary(
"binary1", ExecutableType.SYSTEM)
Expand Down Expand Up @@ -251,7 +249,7 @@ def test_pointers(self):
db.get_region_pointer(1, 2, 3, 9)

def test_write(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex = _TestVertexWithBinary(
"binary", ExecutableType.SYSTEM)

Expand Down Expand Up @@ -304,7 +302,7 @@ def test_write(self):
0, 1, 4, 5, bytearray(b'\x0c\x00\x00\x00'), "test")

def test_ds_cores(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex = _TestVertexWithBinary(
"binary", ExecutableType.SYSTEM)
with DsSqlliteDatabase() as db:
Expand All @@ -322,7 +320,7 @@ def test_ds_cores(self):
self.assertIn((1, 0, 3), cores)

def test_memory_to_write(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
vertex = _TestVertexWithBinary(
"binary", ExecutableType.SYSTEM)
with DsSqlliteDatabase() as db:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import BinaryIO, Optional, Sequence, Tuple, Union
from spinn_utilities.config_holder import set_config
from spinn_utilities.overrides import overrides
from spinn_machine.version import ANY_VERSION
from spinn_machine.version.version_strings import VersionStrings
from spinnman.model.enums import ExecutableType
from pacman.model.placements import Placements, Placement
from spinn_front_end_common.abstract_models import (
Expand Down Expand Up @@ -130,7 +130,7 @@ class TestFrontEndCommonDSGRegionReloader(unittest.TestCase):

def setUp(self):
unittest_setup()
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)

def test_with_good_sizes(self):
""" Test that an application vertex's data is rewritten correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import unittest
from spinn_utilities.config_holder import set_config
from spinn_utilities.overrides import overrides
from spinn_machine.version import ANY_VERSION, FOUR_PLUS_CHIPS
from spinn_machine.version.version_strings import VersionStrings
from spinnman.transceiver.version5transceiver import Version5Transceiver
from spinnman.model.enums import ExecutableType
from pacman.model.graphs.machine import SimpleMachineVertex
Expand Down Expand Up @@ -96,7 +96,7 @@ def setUp(self):
set_config("Machine", "enable_advanced_monitor_support", "False")

def test_call(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
writer = FecDataWriter.mock()
transceiver = _MockTransceiver()
writer.set_transceiver(transceiver)
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_call(self):
header_and_table_size + 16)

def test_multi_spec_with_references(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
writer = FecDataWriter.mock()
transceiver = _MockTransceiver()
writer.set_transceiver(transceiver)
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_multi_spec_with_references(self):
self.assertEqual(header_data[2][2 * 3], header_data[1][2 * 3])

def test_multispec_with_reference_error(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
writer = FecDataWriter.mock()
transceiver = _MockTransceiver()
writer.set_transceiver(transceiver)
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_multispec_with_reference_error(self):
load_application_data_specs()

def test_multispec_with_double_reference(self):
set_config("Machine", "version", ANY_VERSION)
set_config("Machine", "versions", VersionStrings.ANY.value)
writer = FecDataWriter.mock()
transceiver = _MockTransceiver()
writer.set_transceiver(transceiver)
Expand All @@ -279,7 +279,7 @@ def test_multispec_with_double_reference(self):
spec.reserve_memory_region(1, 12, reference=1)

def test_multispec_with_wrong_chip_reference(self):
set_config("Machine", "version", FOUR_PLUS_CHIPS)
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.value)
writer = FecDataWriter.mock()
transceiver = _MockTransceiver()
writer.set_transceiver(transceiver)
Expand Down

0 comments on commit a9b3a62

Please sign in to comment.