Skip to content

Commit

Permalink
allow writer only to require data spec during run
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 30, 2024
1 parent 4e4d605 commit 5e789ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 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 @@ -213,6 +212,14 @@ def data_specification_loaded(self) -> None:
"""
self.__data._requires_data_generation = False

def set_requires_data_generation(self) -> None:
"""
Sets `requires_data_generation` to True.
Set to False after data is loaded
"""
self.__data._requires_data_generation = True

def request_stop(self) -> None:
"""
Used to indicate a user has requested a stop.
Expand Down
9 changes: 7 additions & 2 deletions unittests/data/test_utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,15 +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

0 comments on commit 5e789ae

Please sign in to comment.