From 4e4d605196011499f6b9dbe6b22130b0a2b947ad Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 30 Oct 2024 15:54:52 +0000 Subject: [PATCH] data_specification_loaded to turn off requires data spec / reset --- spinn_utilities/data/utils_data_view.py | 6 ++---- spinn_utilities/data/utils_data_writer.py | 10 +++++++++- unittests/data/test_utils_data.py | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spinn_utilities/data/utils_data_view.py b/spinn_utilities/data/utils_data_view.py index 2ed3c71b..76757d94 100644 --- a/spinn_utilities/data/utils_data_view.py +++ b/spinn_utilities/data/utils_data_view.py @@ -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 @@ -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 @@ -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 diff --git a/spinn_utilities/data/utils_data_writer.py b/spinn_utilities/data/utils_data_writer.py index 79a71370..170ce8fb 100644 --- a/spinn_utilities/data/utils_data_writer.py +++ b/spinn_utilities/data/utils_data_writer.py @@ -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: @@ -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. diff --git a/unittests/data/test_utils_data.py b/unittests/data/test_utils_data.py index 070a8158..bbb44aef 100644 --- a/unittests/data/test_utils_data.py +++ b/unittests/data/test_utils_data.py @@ -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