Skip to content

fix: Reset task timer when calling progress.reset() #3711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IAdityaKaushal
Copy link

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

This PR fixes an issue where restarting progress bar tasks did not reset their running clocks, causing the elapsed time to continue from its previous state.

Problem

When using progress.reset() to restart a task, the elapsed time would not reset properly. This was particularly noticeable in scenarios with multiple progress bars (like AI training with epochs, training, and validation phases) where tasks needed to be reset between iterations.

Solution

The fix ensures that stop_time is cleared when a task is reset, allowing the elapsed time to be calculated correctly from the new start time.

Changes

  • Added task.stop_time = None in the reset() method to clear the stop time
  • Added comprehensive tests to verify the fix
  • Created an example demonstrating the correct behavior

Fixes bug #3273

- Clear stop_time when resetting tasks to allow proper restart
- Fix elapsed time not resetting when tasks are restarted

- Add tests and example demonstrating the fix
Bug fix Textualize#3273
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.

1 participant