Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Add support for resuming a ProgressBar#46242
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedMay 3, 2022
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
carsonbot commentedMay 4, 2022
Hey! I think@boesing has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
fabpot commentedJul 23, 2022
Thank you@yivi. |
…uiluz)This PR was squashed before being merged into the 6.2 branch.Discussion----------[Console] Rename some arguments in ProgressBar| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -While documenting#46242, I thought something was odd: the code and docs talk about "resuming progress bars". But that's only a use-case of this feature. There are others: e.g. some task with optional steps; if you skip some step, you might want to show the progress at a certain starting point instead of `0`.So, this PR propose to rename some arguments. In any case, this is minor, so feel free to close if you think this is not relevant enough.Commits-------c03e815 [Console] Rename some arguments in ProgressBar
Uh oh!
There was an error while loading.Please reload this page.
Add an
(int) $resumeAtargument forProgressBar#start(), so that the progress bar is initialized at a specific progress level, with a new property so thatgetEstimated()andgetRemaining()report the right number.As pointed out on a recently postedSO question), when working on a longish task one may want to create a progress bar for aresumed task.
Calling
advance()works to increase the progress bar counter, but the results ofgetRemaining()andgetEstimated()will be "broken", since whatever steps one "skipped" will be considered to have taken 0 seconds. For a longer running task, the estimation will bevery inaccurate, and will remain so for a long while. Using the example code from the linked question:This will output this to begin with:
The estimated time will keep growing as the tasks progresses, but the estimation won't be remotely useful for a long while.
This PR adds a
$resumeAtparameter toProgresBar#start(), so that's possible to write:And calls to
$bar->getEstimated()and$bar->getRemaining()will return sane results (and calling the initial->advance()would be no longer necessary).TODO: