From 7c28b1518cb46db2a3148542152aeb51773db7e3 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 7 Jul 2023 15:41:51 +0100 Subject: [PATCH 1/4] board_type in unittest_setup --- .../test_database_interface.py | 2 +- .../test_front_end_common_insert_lpgs.py | 2 +- .../interface/config_setup.py | 22 ++++++++++++++----- unittests/data/test_simulator_data.py | 2 +- .../test_buffered_database.py | 2 +- unittests/interface/ds/test_ds.py | 2 +- .../test_load_data_specification.py | 2 +- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/fec_integration_tests/interface/interface_functions/test_database_interface.py b/fec_integration_tests/interface/interface_functions/test_database_interface.py index e329af0f09..3c08eac19f 100644 --- a/fec_integration_tests/interface/interface_functions/test_database_interface.py +++ b/fec_integration_tests/interface/interface_functions/test_database_interface.py @@ -103,7 +103,7 @@ def _place_vertices(app_vertex, placements, chips): def test_database_interface(): - unittest_setup() + unittest_setup(board_type=1) set_config("Database", "create_database", "True") set_config("Database", "create_routing_info_to_neuron_id_mapping", "True") diff --git a/fec_integration_tests/interface/interface_functions/test_front_end_common_insert_lpgs.py b/fec_integration_tests/interface/interface_functions/test_front_end_common_insert_lpgs.py index 4a43d9f8c4..4a91e39cea 100644 --- a/fec_integration_tests/interface/interface_functions/test_front_end_common_insert_lpgs.py +++ b/fec_integration_tests/interface/interface_functions/test_front_end_common_insert_lpgs.py @@ -37,7 +37,7 @@ class TestInsertLPGs(unittest.TestCase): """ def setUp(self): - unittest_setup() + unittest_setup(board_type=1) def test_that_3_lpgs_are_generated_on_3_board_app_graph(self): writer = FecDataWriter.mock() diff --git a/spinn_front_end_common/interface/config_setup.py b/spinn_front_end_common/interface/config_setup.py index 2d0b60ce85..437007862d 100644 --- a/spinn_front_end_common/interface/config_setup.py +++ b/spinn_front_end_common/interface/config_setup.py @@ -22,7 +22,7 @@ BASE_CONFIG_FILE = "spinnaker.cfg" -def unittest_setup(): +def unittest_setup(*, board_type=None): """ Does all the steps that may be required before a unit test. @@ -33,16 +33,28 @@ def unittest_setup(): .. note:: This file should only be called from `spinn_front_end_common/tests` + + :param board_type: Value to say how to confuire the system. + This includes defining what a VirtualMachine would be + Can be 1 for Spin1 boards, 2 for Spin2 boards or + None if the test do not depend on knowing the board type. + :type board_type: None or int """ clear_cfg_files(True) - add_spinnaker_cfg() FecDataWriter.mock() + add_spinnaker_cfg(board_type) -def add_spinnaker_cfg(): +def add_spinnaker_cfg(board_type): """ Add the local configuration and all dependent configuration files. + + :param board_type: Value to say how to confuire the system. + This includes defining what a VirtualMachine would be + Can be 1 for Spin1 boards, 2 for Spin2 boards or + None if the test do not depend on knowing the board type. + :type board_type: None or int """ - add_pacman_cfg() # This add its dependencies too - add_spinnman_cfg() # double adds of dependencies ignored add_default_cfg(os.path.join(os.path.dirname(__file__), BASE_CONFIG_FILE)) + add_pacman_cfg(board_type) # This add its dependencies too + add_spinnman_cfg(board_type) # double adds of dependencies ignored diff --git a/unittests/data/test_simulator_data.py b/unittests/data/test_simulator_data.py index 57a2ebd07d..c6148c0d78 100644 --- a/unittests/data/test_simulator_data.py +++ b/unittests/data/test_simulator_data.py @@ -45,7 +45,7 @@ class TestSimulatorData(unittest.TestCase): def setUp(cls): - unittest_setup() + unittest_setup(board_type=1) def test_setup(self): # What happens before setup depends on the previous test diff --git a/unittests/interface/buffer_management/test_buffered_database.py b/unittests/interface/buffer_management/test_buffered_database.py index 8f091d7abc..08c9fdf9d8 100644 --- a/unittests/interface/buffer_management/test_buffered_database.py +++ b/unittests/interface/buffer_management/test_buffered_database.py @@ -25,7 +25,7 @@ class TestBufferedDatabase(unittest.TestCase): def setUp(self): - unittest_setup() + unittest_setup(board_type=1) def test_use_database(self): f = BufferDatabase.default_database_file() diff --git a/unittests/interface/ds/test_ds.py b/unittests/interface/ds/test_ds.py index 1ba45182f0..ff833e41c1 100644 --- a/unittests/interface/ds/test_ds.py +++ b/unittests/interface/ds/test_ds.py @@ -50,7 +50,7 @@ def get_binary_start_type(self): class TestDataSpecification(unittest.TestCase): def setUp(self): - unittest_setup() + unittest_setup(board_type=1) def test_init(self): db = DsSqlliteDatabase() diff --git a/unittests/interface/interface_functions/test_load_data_specification.py b/unittests/interface/interface_functions/test_load_data_specification.py index 0dff74dc93..9e3d8d428b 100644 --- a/unittests/interface/interface_functions/test_load_data_specification.py +++ b/unittests/interface/interface_functions/test_load_data_specification.py @@ -87,7 +87,7 @@ def get_binary_start_type(self): class TestLoadDataSpecification(unittest.TestCase): def setUp(cls): - unittest_setup() + unittest_setup(board_type=1) set_config("Machine", "enable_advanced_monitor_support", "False") def test_call(self): From f297cf3454aa3ef92da4bddc80a8c7d4d72310d3 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 7 Jul 2023 16:10:38 +0100 Subject: [PATCH 2/4] always setup spin1 (for now) --- spinn_front_end_common/interface/config_handler.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spinn_front_end_common/interface/config_handler.py b/spinn_front_end_common/interface/config_handler.py index 2b6edbf5b3..b925b96d5b 100644 --- a/spinn_front_end_common/interface/config_handler.py +++ b/spinn_front_end_common/interface/config_handler.py @@ -22,6 +22,7 @@ config_options, load_config, get_config_bool, get_config_int, get_config_str, get_config_str_list, set_config) from spinn_machine import Machine +from spinn_machine.config_setup import setup_spin1 from spinn_front_end_common.interface.provenance import LogStoreDB from spinn_front_end_common.data.fec_data_writer import FecDataWriter from spinn_front_end_common.utilities.exceptions import ConfigurationException @@ -70,6 +71,7 @@ def __init__(self, data_writer_cls=None): logger.set_log_store(LogStoreDB()) # set up machine targeted data + self._setup_board_type() self._debug_configs() self._previous_handler() @@ -78,6 +80,14 @@ def __init__(self, data_writer_cls=None): if max_machine_core is not None: Machine.set_max_cores_per_chip(max_machine_core) + def _setup_board_type(self): + """ + Stub to detect between spin1 and spin2 and update tej cofnigs + + """ + # TODO read config and determine if spin1 or spin2 + setup_spin1() + def _debug_configs(self): """ Adjusts and checks the configuration based on mode and From 23df3a625866f0979406e1e1c07269840a6ba305 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jul 2023 07:02:56 +0100 Subject: [PATCH 3/4] board_type --- .../file_convertor_tests/test_write_json_machine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fec_integration_tests/file_convertor_tests/test_write_json_machine.py b/fec_integration_tests/file_convertor_tests/test_write_json_machine.py index 7677444141..5cc7e751c2 100644 --- a/fec_integration_tests/file_convertor_tests/test_write_json_machine.py +++ b/fec_integration_tests/file_convertor_tests/test_write_json_machine.py @@ -38,7 +38,7 @@ class TestWriteJson(unittest.TestCase): mainPort = 22244 def setUp(self): - unittest_setup() + unittest_setup(board_type=1) class_file = sys.modules[self.__module__].__file__ path = os.path.dirname(os.path.abspath(class_file)) os.chdir(path) From 66904646e7a41e4c404f35e624d5eed15eef7666 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jul 2023 07:06:48 +0100 Subject: [PATCH 4/4] no board_type needed --- unittests/data/manual_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/data/manual_check.py b/unittests/data/manual_check.py index bf07bc6ee7..0f4ac216ca 100644 --- a/unittests/data/manual_check.py +++ b/unittests/data/manual_check.py @@ -25,7 +25,7 @@ # reset the configs without mocking the global data clear_cfg_files(True) -add_spinnaker_cfg() +add_spinnaker_cfg(board_type=None) view = FecDataView() try: