Skip to content
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

Add condensed time column #1992

Merged
merged 3 commits into from Feb 27, 2022

Conversation

bhrutledge
Copy link
Contributor

@bhrutledge bhrutledge commented Feb 22, 2022

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

While replacing Twine's progress bar with Rich, I got into some bike-shedding/yak-shaving to declutter the time column. After looking at several download progress indicators (e.g. Chrome, Firefox, wget, scp), it seems more common to show time remaining than time elapsed. Both wget and scp show time remaining until the download is finished, then switch to time elapsed. So, I implemented that behavior here.

For example:

twine-progress-rich-time.mp4

rich/progress.py Outdated
@@ -357,6 +357,30 @@ def render(self, task: "Task") -> Text:
return Text(str(remaining_delta), style="progress.remaining")


class CondensedTimeColumn(ProgressColumn):
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming isn't clear. What is condensed time? How is it different from TimeRemaining or TimeElapsed? I know the answers, but I don't think it would be obvious to a user.

I do like the functionality. But if we add it I think it should be rolled in to the TimeRemainingColumn class so that the defaults continue to work as before, but with options for the new features.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't love Condensed, but I chose that thinking of "a shorter time column with more information". Maybe Compact would be clearer.

However, I'm happy to roll it into TimeRemainingColumn. How about:

class TimeRemainingColumn(ProgressColumn):
    """Renders estimated time remaining.

    Args:
        compact (bool, optional): Render MM:SS when time remaining is less than an hour. Defaults to False.
        elapsed_when_finished (bool, optional): Render time elapsed when the task is finished. Defaults to False.
    """

Or, should compact (or another name) encompass both behaviors? Or ???

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that idea!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2022

Codecov Report

Merging #1992 (e2ccd5b) into master (e839bfb) will decrease coverage by 0.01%.
The diff coverage is 99.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1992      +/-   ##
==========================================
- Coverage   99.82%   99.81%   -0.02%     
==========================================
  Files          71       71              
  Lines        6943     7055     +112     
==========================================
+ Hits         6931     7042     +111     
- Misses         12       13       +1     
Flag Coverage Δ
unittests 99.81% <99.13%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/default_styles.py 100.00% <ø> (ø)
rich/highlighter.py 100.00% <ø> (ø)
rich/markdown.py 100.00% <ø> (ø)
rich/syntax.py 99.27% <97.72%> (-0.34%) ⬇️
rich/pretty.py 99.71% <98.79%> (-0.29%) ⬇️
rich/__main__.py 100.00% <100.00%> (ø)
rich/_inspect.py 100.00% <100.00%> (ø)
rich/color.py 100.00% <100.00%> (ø)
rich/console.py 100.00% <100.00%> (ø)
rich/filesize.py 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c3e6be...e2ccd5b. Read the comment docs.

@willmcgugan
Copy link
Collaborator

Thanks.

@willmcgugan willmcgugan merged commit 646d933 into Textualize:master Feb 27, 2022
@bhrutledge
Copy link
Contributor Author

My pleasure; thanks for accepting it. Any idea of when it might be released? No pressure, just curious when I can start using this in Twine. 😉

@willmcgugan
Copy link
Collaborator

Just a few days I expect.

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.

None yet

3 participants