Skip to content

Commit

Permalink
is_stop_requested
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 31, 2024
1 parent d8347f9 commit 90d04f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions spinn_utilities/data/utils_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,17 @@ def is_reset_last(cls) -> bool:
f"{cls.__data._run_status}")

@classmethod
def is_no_stop_requested(cls) -> bool:
def is_stop_requested(cls) -> bool:
"""
Checks that a stop request has not been sent.
Checks that a stop request has been sent.
:raises NotImplementedError:
If this is called from an unexpected state
"""
if cls.__data._run_status == RunStatus.IN_RUN:
return True
if cls.__data._run_status == RunStatus.STOP_REQUESTED:
return False
if cls.__data._run_status == RunStatus.STOP_REQUESTED:
return True
raise NotImplementedError(
f"This call was not expected with run status "
f"{cls.__data._run_status}")
Expand Down
44 changes: 22 additions & 22 deletions unittests/data/test_utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_not_setup(self):
with self.assertRaises(NotImplementedError):
UtilsDataView.is_reset_last()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertFalse(UtilsDataView.is_setup())
# No writer yet so no way to call state change methods
Expand All @@ -88,7 +88,7 @@ def test_mocked(self):
with self.assertRaises(NotImplementedError):
UtilsDataView.is_reset_last()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertFalse(UtilsDataView.is_setup())

Expand Down Expand Up @@ -125,7 +125,7 @@ def test_setup(self):
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())

# writer.start_run() see test_start
Expand Down Expand Up @@ -157,7 +157,7 @@ def check_shut_down(self, writer):
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertFalse(UtilsDataView.is_setup())
self.check_after_shutdown(writer)
Expand Down Expand Up @@ -198,7 +198,7 @@ def check_stopping(self, writer):
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
self.assertTrue(UtilsDataView.is_no_stop_requested())
self.assertTrue(UtilsDataView.is_stop_requested())
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -234,7 +234,7 @@ def test_start(self):
self.assertFalse(UtilsDataView.is_ran_ever())
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
self.assertTrue(UtilsDataView.is_no_stop_requested())
self.assertTrue(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -276,7 +276,7 @@ def check_start_finish(self, writer):
self.assertTrue(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -307,7 +307,7 @@ def check_start_finish_shut_down(self, writer):
self.assertTrue(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertFalse(UtilsDataView.is_setup())

Expand Down Expand Up @@ -335,7 +335,7 @@ def check_start_finish_stopping(self, writer):
self.assertTrue(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -375,7 +375,7 @@ def check_start_finish_hard(self, writer):
self.assertFalse(UtilsDataView.is_ran_last())
self.assertTrue(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -409,7 +409,7 @@ def check_start_finish_hard_shut_down(self, writer):
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_reset_last()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertFalse(UtilsDataView.is_setup())

Expand Down Expand Up @@ -439,7 +439,7 @@ def check_start_finish_hard_stopping(self, writer):
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_reset_last()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -479,7 +479,7 @@ def check_start_finish_hard_start(self, writer):
self.assertTrue(UtilsDataView.is_ran_ever())
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
self.assertTrue(UtilsDataView.is_no_stop_requested())
self.assertFalse(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -536,7 +536,7 @@ def check_start_finish_hard_start_request(self, writer):
self.assertFalse(UtilsDataView.is_ran_last())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_reset_last()
self.assertFalse(UtilsDataView.is_no_stop_requested())
self.assertTrue(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -590,7 +590,7 @@ def test_start_finish_start(self):
self.assertTrue(UtilsDataView.is_ran_ever())
self.assertTrue(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
self.assertTrue(UtilsDataView.is_no_stop_requested())
self.assertFalse(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -649,7 +649,7 @@ def test_start_finish_start_request(self):
self.assertTrue(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
self.assertFalse(UtilsDataView.is_reset_last())
self.assertFalse(UtilsDataView.is_no_stop_requested())
self.assertTrue(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -710,7 +710,7 @@ def test_start_finish_soft(self):
self.assertFalse(UtilsDataView.is_ran_last())
self.assertTrue(UtilsDataView.is_reset_last())
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -743,7 +743,7 @@ def check_start_finish_soft_shutdown(self, writer):
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_reset_last()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertFalse(UtilsDataView.is_setup())

Expand Down Expand Up @@ -773,7 +773,7 @@ def check_start_finish_start_soft_stopping(self, writer):
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_reset_last()
with self.assertRaises(NotImplementedError):
UtilsDataView.is_no_stop_requested()
UtilsDataView.is_stop_requested()
self.assertFalse(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -819,7 +819,7 @@ def test_start_finish_soft_start(self):
self.assertTrue(UtilsDataView.is_ran_ever())
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_reset_last())
self.assertTrue(UtilsDataView.is_no_stop_requested())
self.assertFalse(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -881,7 +881,7 @@ def test_start_finish_soft_start_request(self):
self.assertFalse(UtilsDataView.is_ran_last())
with self.assertRaises(SimulatorShutdownException):
UtilsDataView.is_reset_last()
self.assertFalse(UtilsDataView.is_no_stop_requested())
self.assertTrue(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down Expand Up @@ -944,7 +944,7 @@ def test_start_request(self):
# Only set at end of the current run
self.assertFalse(UtilsDataView.is_ran_ever())
self.assertFalse(UtilsDataView.is_ran_last())
self.assertFalse(UtilsDataView.is_no_stop_requested())
self.assertTrue(UtilsDataView.is_stop_requested())
self.assertTrue(UtilsDataView.is_running())
self.assertTrue(UtilsDataView.is_setup())

Expand Down

0 comments on commit 90d04f0

Please sign in to comment.