Skip to content

Commit

Permalink
Make the internal attribute skip_completed_after_termination private
Browse files Browse the repository at this point in the history
  • Loading branch information
bonassifabio committed Dec 4, 2024
1 parent a27632f commit e2980de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ignite/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, process_function: Callable[["Engine", Any], Any]):
self._process_function = process_function
self.last_event_name: Optional[Events] = None
self.should_terminate = False
self.skip_completed_after_termination = False
self._skip_completed_after_termination = False
self.should_terminate_single_epoch = False
self._skip_epoch_completed_after_termination = False
self.should_interrupt = False
Expand Down Expand Up @@ -627,7 +627,7 @@ def terminate():
"""
self.logger.info("Terminate signaled. Engine will stop after current iteration is finished.")
self.should_terminate = True
self.skip_completed_after_termination = skip_completed
self._skip_completed_after_termination = skip_completed

def terminate_epoch(self, skip_epoch_completed: bool = False) -> None:
"""Sends terminate signal to the engine, so that it terminates the current epoch. The run
Expand Down Expand Up @@ -1015,7 +1015,7 @@ def _internal_run_as_gen(self) -> Generator[Any, None, State]:
self.state.times[Events.COMPLETED.name] = time_taken

# do not fire Events.COMPLETED if we terminated the run with flag `skip_completed=True`
if not (self.should_terminate and self.skip_completed_after_termination):
if not (self.should_terminate and self._skip_completed_after_termination):
handlers_start_time = time.time()
self._fire_event(Events.COMPLETED)
time_taken += time.time() - handlers_start_time
Expand Down Expand Up @@ -1204,7 +1204,7 @@ def _internal_run_legacy(self) -> State:
self.state.times[Events.COMPLETED.name] = time_taken

# do not fire Events.COMPLETED if we terminated the run with flag `skip_completed=True`
if not (self.should_terminate and self.skip_completed_after_termination):
if not (self.should_terminate and self._skip_completed_after_termination):
handlers_start_time = time.time()
self._fire_event(Events.COMPLETED)
time_taken += time.time() - handlers_start_time
Expand Down
4 changes: 2 additions & 2 deletions tests/ignite/engine/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def set_interrupt_resume_enabled(self, interrupt_resume_enabled):
def test_terminate(self, skip_completed):
engine = Engine(lambda e, b: 1)
assert not engine.should_terminate
assert not engine.skip_completed_after_termination
assert not engine._skip_completed_after_termination
engine.terminate(skip_completed)
assert engine.should_terminate
assert engine.skip_completed_after_termination == skip_completed
assert engine._skip_completed_after_termination == skip_completed

def test_invalid_process_raises_with_invalid_signature(self):
with pytest.raises(ValueError, match=r"Engine must be given a processing function in order to run"):
Expand Down

0 comments on commit e2980de

Please sign in to comment.