Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Jun 21, 2021
2 parents 63c47f9 + 4cb4be5 commit 21620a9
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

import time
import os
from spinn_front_end_common.utilities.utility_calls import get_region_base_address_offset
from spinn_front_end_common.utilities import globals_variables
from spinn_front_end_common.utilities.utility_calls import (
get_region_base_address_offset)
from data_specification.utility_calls import get_region_base_address_offset
from spinn_front_end_common.utilities.helpful_functions import n_word_struct
import spinnaker_graph_front_end as sim
from gfe_integration_tests.test_extra_monitor.sdram_writer import (
Expand Down Expand Up @@ -102,7 +103,6 @@ def check_extra_monitor(self):
mbs = _TRANSFER_SIZE_MEGABYTES

# setup system
globals_variables.unset_simulator()
sim.setup(model_binary_folder=os.path.dirname(__file__),
n_chips_required=2)

Expand Down
3 changes: 0 additions & 3 deletions gfe_integration_tests/test_hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

class TestHelloWorld(ScriptChecker):

def setUp(self):
globals_variables.unset_simulator()

def test_hello_world(self):
with LogCapture("hello_world") as lc:
self.check_script(
Expand Down
6 changes: 1 addition & 5 deletions gfe_integration_tests/test_hello_world_untimed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from testfixtures import LogCapture
from spinn_front_end_common.utilities import globals_variables
from spinnaker_testbase import ScriptChecker


class TestHelloWorldUntimed(ScriptChecker):

def setUp(self):
globals_variables.unset_simulator()

def test_hello_world_untimed(self):
def test_hello_world_untimed(self):
with LogCapture("hello_world") as lc:
self.check_script(
"gfe_examples/hello_world_untimed/hello_world.py")
Expand Down
2 changes: 0 additions & 2 deletions gfe_integration_tests/test_rte/test_rte_during_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
import traceback
import pytest
from spinn_front_end_common.utilities.utility_objs import ExecutableType
from spinn_front_end_common.utilities import globals_variables
from spinnman.exceptions import SpinnmanException
import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex


def test_rte_during_run():
globals_variables.unset_simulator()
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_rte_during_run.aplx",
Expand Down
2 changes: 0 additions & 2 deletions gfe_integration_tests/test_rte/test_rte_during_run_forever.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
from spinn_front_end_common.utilities.exceptions import (
ExecutableFailedToStopException)
from spinn_front_end_common.utilities.database import DatabaseConnection
from spinn_front_end_common.utilities import globals_variables
import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex
import pytest


def test_rte_during_run_forever():
globals_variables.unset_simulator()

def start():
sleep(3.0)
Expand Down
2 changes: 0 additions & 2 deletions gfe_integration_tests/test_rte/test_rte_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
import os
import pytest
from spinn_front_end_common.utilities.utility_objs import ExecutableType
from spinn_front_end_common.utilities import globals_variables
from spinnman.exceptions import SpinnmanException
import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex


def test_rte_at_start():
globals_variables.unset_simulator()
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(
RunVertex(
Expand Down
1 change: 0 additions & 1 deletion gfe_integration_tests/test_rte/test_run_too_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


def test_run_too_long():
globals_variables.unset_simulator()
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_run_too_long.aplx",
Expand Down
39 changes: 29 additions & 10 deletions spinnaker_graph_front_end/config_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,45 @@
import os
from spinn_utilities.config_holder import (
clear_cfg_files, set_cfg_files)
from spinn_front_end_common.interface.config_setup import add_spinnaker_cfg
from spinn_front_end_common.interface.config_setup import (
add_default_cfg, add_spinnaker_cfg)
from spinn_front_end_common.utilities.globals_variables import (
setup_for_unittest)

#: The name of the configuration file
CONFIG_FILE_NAME = "spiNNakerGraphFrontEnd.cfg"


def reset_configs():
def setup_configs():
"""
Resets the configs so only the local default config is included.
"""
clear_cfg_files()
add_gfe_cfg()
Sets up the configs including the users cfg file
Clears out any previous read configs but does not load the new configs
so a warning is generated if a config is used before setup is called.
def add_gfe_cfg():
"""
Add the local cfg and all dependent cfg files.
"""
clear_cfg_files(False)
add_spinnaker_cfg() # This add its dependencies too
set_cfg_files(
configfile=CONFIG_FILE_NAME,
default=os.path.join(os.path.dirname(__file__), CONFIG_FILE_NAME))


def unittest_setup():
"""
Does all the steps that may be required before a unittest
Resets the configs so only the local default configs are included.
The user cfg is NOT included!
Unsets any previous simulators and tempdirs
.. note::
This file should only be called from Spynnaker tests
that do not call sim.setup
"""
setup_for_unittest()
clear_cfg_files(True)
add_spinnaker_cfg() # This add its dependencies too
add_default_cfg(os.path.join(os.path.dirname(__file__), CONFIG_FILE_NAME))
9 changes: 4 additions & 5 deletions spinnaker_graph_front_end/spinnaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from spinn_utilities.log import FormatAdapter
from spinn_front_end_common.interface.abstract_spinnaker_base import (
AbstractSpinnakerBase)
from spinnaker_graph_front_end.config_setup import reset_configs
from spinnaker_graph_front_end.config_setup import setup_configs
from ._version import __version__ as version

logger = FormatAdapter(logging.getLogger(__name__))
Expand Down Expand Up @@ -81,6 +81,9 @@ def __init__(
Where to look for algorithm descriptors
"""
# DSG algorithm store for user defined algorithms

# At import time change the default FailedState
setup_configs()
self._user_dsg_algorithm = dsg_algorithm

front_end_versions = [("SpiNNakerGraphFrontEnd", version)]
Expand Down Expand Up @@ -140,7 +143,3 @@ def run(self, run_time):
def __repr__(self):
return "SpiNNaker Graph Front End object for machine {}".format(
self._hostname)


# At import time change the default FailedState
reset_configs()
7 changes: 3 additions & 4 deletions unittests/test_cfg_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
import os
import unittest
from spinn_utilities.config_holder import run_config_checks
from spinnaker_graph_front_end.config_setup import reset_configs
from spinnaker_graph_front_end.config_setup import unittest_setup


class TestCfgChecker(unittest.TestCase):

@classmethod
def setUpClass(cls):
reset_configs()
def setUp(self):
unittest_setup()

def test_config_checks(self):
unittests = os.path.dirname(__file__)
Expand Down
3 changes: 3 additions & 0 deletions unittests/test_import_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@


class ImportAllModule(unittest.TestCase):

# no unittest_setup to check all imports work without it

def test_import_all(self):
package_loader.load_module("spinnaker_graph_front_end",
remove_pyc_files=(_CI != 'true'))
2 changes: 2 additions & 0 deletions unittests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Test(unittest.TestCase):
""" Tests for the component version comparison
"""

# no unittest_setup to check version without it

def test_compare_versions(self):
spinn_utilities_parts = spinn_utilities.__version__.split('.')
spinn_machine_parts = spinn_machine.__version__.split('.')
Expand Down

0 comments on commit 21620a9

Please sign in to comment.