Skip to content

Commit 13d95db

Browse files
authored
Apply suggestions from code review
1 parent 36dda87 commit 13d95db

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ignite/engine/engine.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,10 @@ def _internal_run_as_gen(self) -> Generator[Any, None, State]:
998998
# update time wrt handlers
999999
self.state.times[Events.EPOCH_COMPLETED.name] = epoch_time_taken
10001000

1001-
self.should_terminate_single_epoch = False
1001+
if self.should_terminate_single_epoch:
1002+
# We skip raising _EngineTerminateSingleEpochException exception on Events.EPOCH_COMPLETED
1003+
# as epoch is already completed and nothing to terminate
1004+
self.should_terminate_single_epoch = False
10021005
yield from self._maybe_terminate_or_interrupt()
10031006

10041007
hours, mins, secs = _to_hours_mins_secs(epoch_time_taken)
@@ -1192,7 +1195,10 @@ def _internal_run_legacy(self) -> State:
11921195
# update time wrt handlers
11931196
self.state.times[Events.EPOCH_COMPLETED.name] = epoch_time_taken
11941197

1195-
self.should_terminate_single_epoch = False
1198+
if self.should_terminate_single_epoch:
1199+
# We skip raising _EngineTerminateSingleEpochException exception on Events.EPOCH_COMPLETED
1200+
# as epoch is already completed and nothing to terminate
1201+
self.should_terminate_single_epoch = False
11961202
self._maybe_terminate_legacy()
11971203

11981204
hours, mins, secs = _to_hours_mins_secs(epoch_time_taken)

0 commit comments

Comments
 (0)