Skip to content

Commit

Permalink
Merge pull request #222 from SpiNNakerManchester/is_config_none
Browse files Browse the repository at this point in the history
Is config none
  • Loading branch information
Christian-B authored Sep 11, 2023
2 parents 76c5a8a + 41a3afc commit d7447f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
12 changes: 7 additions & 5 deletions spinn_machine/version/abstract_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from spinn_utilities.abstract_base import (
AbstractBase, abstractmethod, abstractproperty)
from spinn_utilities.log import FormatAdapter
from spinn_utilities.config_holder import get_config_int
from spinn_utilities.config_holder import get_config_int_or_none
from spinn_machine.exceptions import SpinnMachineException

logger = FormatAdapter(logging.getLogger(__name__))
Expand Down Expand Up @@ -45,8 +45,8 @@ def __verify_config_width_height(self):
:raises SpinnMachineException:
If the cfg width or height is unexpected
"""
width = get_config_int("Machine", "width")
height = get_config_int("Machine", "height")
width = get_config_int_or_none("Machine", "width")
height = get_config_int_or_none("Machine", "height")
if width is None:
if height is None:
pass
Expand All @@ -62,7 +62,8 @@ def __verify_config_width_height(self):

def __set_max_cores_per_chip(self, max_cores_per_chip):
self._max_cores_per_chip = max_cores_per_chip
max_machine_core = get_config_int("Machine", "max_machine_core")
max_machine_core = get_config_int_or_none(
"Machine", "max_machine_core")
if max_machine_core is not None:
if max_machine_core > self._max_cores_per_chip:
logger.info(
Expand All @@ -78,7 +79,8 @@ def __set_max_cores_per_chip(self, max_cores_per_chip):

def __set_max_sdram_per_chip(self, max_sdram_per_chip):
self._max_sdram_per_chip = max_sdram_per_chip
max_sdram = get_config_int("Machine", "max_sdram_allowed_per_chip")
max_sdram = get_config_int_or_none(
"Machine", "max_sdram_allowed_per_chip")
if max_sdram is not None:
if max_sdram > self._max_sdram_per_chip:
logger.info(
Expand Down
14 changes: 8 additions & 6 deletions spinn_machine/version/version_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.

import logging
from spinn_utilities.config_holder import get_config_int, get_config_str
from spinn_utilities.config_holder import (
get_config_int_or_none, get_config_str_or_none)
from spinn_utilities.log import FormatAdapter
from spinn_machine.exceptions import SpinnMachineException

Expand All @@ -32,23 +33,24 @@ def version_factory():
from .version_3 import Version3
from .version_5 import Version5

version = get_config_int("Machine", "version")
version = get_config_int_or_none("Machine", "version")
if version in [2, 3]:
return Version3()

if version in [4, 5]:
return Version5()

spalloc_server = get_config_str("Machine", "spalloc_server")
spalloc_server = get_config_str_or_none("Machine", "spalloc_server")
if spalloc_server is not None:
return Version5()

remote_spinnaker_url = get_config_str("Machine", "remote_spinnaker_url")
remote_spinnaker_url = get_config_str_or_none(
"Machine", "remote_spinnaker_url")
if remote_spinnaker_url is not None:
return Version5()

height = get_config_int("Machine", "height")
width = get_config_int("Machine", "width")
height = get_config_int_or_none("Machine", "height")
width = get_config_int_or_none("Machine", "width")
if height is not None and width is not None:
if height == width == 2:
logger.info("Your cfg file does not have a ")
Expand Down
8 changes: 4 additions & 4 deletions spinn_machine/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from collections import defaultdict
import logging
from spinn_utilities.config_holder import get_config_str
from spinn_utilities.config_holder import get_config_str_or_none
from spinn_utilities.log import FormatAdapter
from .chip import Chip
from .router import Router
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(

# Store the down items
unused_chips = []
for down_chip in IgnoreChip.parse_string(get_config_str(
for down_chip in IgnoreChip.parse_string(get_config_str_or_none(
"Machine", "down_chips")):
if isinstance(down_chip, IgnoreChip):
if down_chip.ip_address is None:
Expand All @@ -81,7 +81,7 @@ def __init__(
unused_chips.append((down_chip[0], down_chip[1]))

self._unused_cores = defaultdict(set)
for down_core in IgnoreCore.parse_string(get_config_str(
for down_core in IgnoreCore.parse_string(get_config_str_or_none(
"Machine", "down_cores")):
if isinstance(down_core, IgnoreCore):
if down_core.ip_address is None:
Expand All @@ -92,7 +92,7 @@ def __init__(
down_core[2])

self._unused_links = set()
for down_link in IgnoreLink.parse_string(get_config_str(
for down_link in IgnoreLink.parse_string(get_config_str_or_none(
"Machine", "down_links")):
if isinstance(down_link, IgnoreLink):
if down_link.ip_address is None:
Expand Down

0 comments on commit d7447f6

Please sign in to comment.