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

Defaults from cfg #1086

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions spinn_front_end_common/interface/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down
22 changes: 17 additions & 5 deletions spinn_front_end_common/interface/config_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
2 changes: 1 addition & 1 deletion unittests/data/manual_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion unittests/data/test_simulator_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion unittests/interface/ds/test_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down