Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data_specification_loaded to turn off requires data spec / reset #287

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 17 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,6 @@ 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_mapping = False

def _hard_reset(self) -> None:
Expand Down Expand Up @@ -205,6 +204,23 @@ 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

@classmethod
def set_requires_data_generation(cls) -> None:
"""
Sets `requires_data_generation` to True.

Set to False after data is loaded
"""
cls.__data._requires_data_generation = True

def request_stop(self) -> None:
"""
Used to indicate a user has requested a stop.
Expand Down
11 changes: 9 additions & 2 deletions unittests/data/test_utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,13 +1030,20 @@ def test_requires(self):
self.assertTrue(writer.get_requires_mapping())
# Can not be changed during run
with self.assertRaises(SimulatorRunningException):
writer.set_requires_data_generation()
UtilsDataView.set_requires_data_generation()
with self.assertRaises(SimulatorRunningException):
writer.set_requires_mapping()
writer.data_specification_loaded()
self.assertFalse(writer.get_requires_data_generation())
with self.assertRaises(SimulatorRunningException):
UtilsDataView.set_requires_data_generation()
writer.set_requires_data_generation()
self.assertTrue(writer.get_requires_data_generation())
writer.finish_run()

# Stay as it was
self.assertTrue(writer.get_requires_data_generation())
# False after run
self.assertFalse(writer.get_requires_data_generation())
self.assertFalse(writer.get_requires_mapping())

# Setting requires mapping sets both to True
Expand Down