Skip to content

Commit

Permalink
Merge pull request #263 from SpiNNakerManchester/better_error
Browse files Browse the repository at this point in the history
Better error on bad cfg
  • Loading branch information
rowleya authored Jun 3, 2024
2 parents 8c5a728 + 8b3cc89 commit 487a2fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 5 additions & 2 deletions spinn_machine/version/version_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def version_factory() -> AbstractVersion:
return Version5()

if version is None:
raise SpinnMachineException("cfg [Machine]version {version} is None")

machine_name = get_config_str_or_none("Machine", "machineName")
raise SpinnMachineException(
"cfg [Machine]version {version} is None. "
f"Other cfg settings are {machine_name=} {spalloc_server=}, "
f"{remote_spinnaker_url=} {width=} {height=}")
raise SpinnMachineException(f"Unexpected cfg [Machine]version {version}")
12 changes: 11 additions & 1 deletion unittests/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

import unittest
from spinn_utilities.config_holder import set_config
from spinn_utilities.exceptions import (DataNotYetAvialable)
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

Expand Down Expand Up @@ -185,3 +186,12 @@ def test_get_monitors(self):
writer.add_monitor_core(True)
self.assertEqual(2, MachineDataView.get_all_monitor_cores())
self.assertEqual(3, MachineDataView.get_ethernet_monitor_cores())

def test_no_version(self):
set_config("Machine", "machineName", "SpiNNaker1M")
try:
MachineDataView.get_machine_version()
raise ConfigException("Should not get here")
except SpinnMachineException as ex:
msg = str(ex)
self.assertIn("SpiNNaker1M", msg)

0 comments on commit 487a2fa

Please sign in to comment.