Skip to content

test: cover resuming engine with unknown epoch length#3786

Open
nightcityblade wants to merge 2 commits into
pytorch:masterfrom
nightcityblade:fix/issue-1331
Open

test: cover resuming engine with unknown epoch length#3786
nightcityblade wants to merge 2 commits into
pytorch:masterfrom
nightcityblade:fix/issue-1331

Conversation

@nightcityblade

Copy link
Copy Markdown
Contributor

Fixes #1331

Description:

Adds regression coverage for continuing an engine after terminate() when the data iterator has unknown epoch_length.

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@vfdev-5

vfdev-5 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

@nightcityblade resolve the conflict with master branch

@nightcityblade

Copy link
Copy Markdown
Contributor Author

Rebased fix/issue-1331 on current master and resolved the import conflict in tests/ignite/engine/test_engine.py by keeping both itertools and the current master imports.

Validation run:

  • python3 -m pytest tests/ignite/engine/test_engine.py::TestEngine::test_continue_after_terminate_with_unknown_epoch_length -q — 2 passed
  • python3 -m ruff check tests/ignite/engine/test_engine.py — passed

assert state.epoch_length is None

state = engine.run(itertools.count(start=0), max_epochs=engine.state.epoch + 1)
assert state.epoch == 2

@vfdev-5 vfdev-5 Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert state.epoch == 2
# TODO: engine bug that increments the epoch counter: https://github.com/pytorch/ignite/issues/1386
# Uncomment the check when fixed
# assert state.epoch == 1

@nightcityblade

Copy link
Copy Markdown
Contributor Author

Addressed the inline suggestion in commit 4ebadba: I replaced the first state.epoch assertion with a TODO referencing the known engine epoch-counter bug in #1386, while keeping the regression coverage for iteration and unknown epoch_length. Validation rerun: python3 -m pytest tests/ignite/engine/test_engine.py::TestEngine::test_continue_after_terminate_with_unknown_epoch_length -q and python3 -m ruff check tests/ignite/engine/test_engine.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Engine - Continue run throws error because epoch_length is None

2 participants