Skip to content

Commit

Permalink
data_specification_loaded to turn off requires data spec / reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 30, 2024
1 parent e0781d6 commit 4e4d605
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 2 additions & 4 deletions spinn_utilities/data/utils_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ def get_requires_data_generation(cls) -> bool:
Set to True at the start and by any change that could require
data generation or mapping
Remains True during the first run after a data change
Only set to False at the *end* of the first run
Only set to False after the data is loaded.
"""
return cls.__data._requires_data_generation

Expand All @@ -546,7 +545,7 @@ def set_requires_data_generation(cls) -> None:
"""
Sets `requires_data_generation` to True.
Only the end of a run can set it to False
Set to False after data is loaded
"""
cls.check_user_can_act()
cls.__data._requires_data_generation = True
Expand Down Expand Up @@ -588,7 +587,6 @@ def _mock_has_run(cls) -> None:
"""
cls.__data._run_status = RunStatus.NOT_RUNNING
cls.__data._reset_status = ResetStatus.HAS_RUN
cls.__data._requires_data_generation = False
cls.__data._requires_mapping = False

@classmethod
Expand Down
10 changes: 9 additions & 1 deletion spinn_utilities/data/utils_data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def finish_run(self) -> None:
f"{self.__data._run_status}")
self.__data._run_status = RunStatus.NOT_RUNNING
self.__data._reset_status = ResetStatus.HAS_RUN
self.__data._requires_data_generation = False
#self.__data._requires_data_generation = False
self.__data._requires_mapping = False

def _hard_reset(self) -> None:
Expand Down Expand Up @@ -205,6 +205,14 @@ def soft_reset(self) -> None:
f"Unexpected call to reset while reset status is "
f"{self.__data._reset_status}")

def data_specification_loaded(self) -> None:
"""
Used to indicate that load data specification has run/
.
Causes get_requires_data_generation to report False
"""
self.__data._requires_data_generation = False

def request_stop(self) -> None:
"""
Used to indicate a user has requested a stop.
Expand Down
2 changes: 2 additions & 0 deletions unittests/data/test_utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ def test_requires(self):
writer.set_requires_data_generation()
with self.assertRaises(SimulatorRunningException):
writer.set_requires_mapping()
writer.data_specification_loaded()
self.assertFalse(writer.get_requires_data_generation())
writer.finish_run()

# False after run
Expand Down

0 comments on commit 4e4d605

Please sign in to comment.