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

make RichProgressBar more flexible with Rich.Console #10875

Merged
merged 14 commits into from Dec 15, 2021
Merged

make RichProgressBar more flexible with Rich.Console #10875

merged 14 commits into from Dec 15, 2021

Conversation

quancs
Copy link
Member

@quancs quancs commented Dec 1, 2021

The Console inside RichProgressBar is fixed to have its default paramters, which leads to some problems: for example, when force_terminal is True, the progress_bar can be logged in nohup output file. Besides, that is very inflexible for people who want to make some other settings.

What does this PR do?

Add **kwargs to RichProgressBar's init args for initializing its inner Console, so that #10876 can be fixed by passing force_terminal=True

Fixes #10876

Does your PR introduce any breaking changes? If yes, please list them.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

when force_terminal is True, the progress_bar can be logged in nohup output file
@quancs quancs closed this Dec 1, 2021
@quancs quancs reopened this Dec 6, 2021
@quancs quancs changed the title make RichProgressBar compatible with nohup command make RichProgressBar more flexible with Rich.Console Dec 6, 2021
@quancs
Copy link
Member Author

quancs commented Dec 6, 2021

@kaushikb11 Hi, how do you think about this pull request

@kaushikb11
Copy link
Contributor

Hi @quancs, thanks for doing the PR!

I think it would be better to have console_kwargs argument for RichProgressBar.

    def __init__(
        self,
        refresh_rate: int = 1,
        leave: bool = False,
        theme: RichProgressBarTheme = RichProgressBarTheme(),
        console_kwargs: Optional[Dict[str, Any]] = None,
    ) -> None:

@quancs
Copy link
Member Author

quancs commented Dec 8, 2021

console_kwargs: Optional[Dict[str, Any]] = None,

Is this compatible with CLI? @kaushikb11

CHANGELOG.md Outdated Show resolved Hide resolved
kaushikb11 and others added 4 commits December 10, 2021 16:05
Copy link
Contributor

@SeanNaren SeanNaren left a comment

Choose a reason for hiding this comment

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

Thanks for this PR @quancs!

Would've been nicer if we could pass the console as an argument to the rich progress callback, however because of the pickling issue with the Console this would have to be a workaround

@mergify mergify bot added ready PRs ready to be merged has conflicts labels Dec 11, 2021
@awaelchli awaelchli added this to the 1.6 milestone Dec 14, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -324,7 +327,7 @@ def __getstate__(self):

def __setstate__(self, state):
self.__dict__ = state
state["_console"] = Console()
self._console = Console(**self._console_kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

after #10896 _init_progress should run in the spawned processes already. We can remove this setstate method entirely (in a new PR) if you agree.

Copy link
Contributor

Choose a reason for hiding this comment

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

:O this would mean we could easily pass in the console object directly through the callback (which would be much nicer imo). @quancs given #10896 has been merged what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

How about this

console_kwargs: Optional[Dict[str, Any], Console] = None,

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll be up for that, but we could add that in a separate PR if you'd prefer :)

Copy link
Member Author

@quancs quancs Dec 15, 2021

Choose a reason for hiding this comment

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

Yeah. So, let's merge this PR?
Or do you have any other thoughts? @awaelchli

Copy link
Member

Choose a reason for hiding this comment

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

Yes, are you interested to make a follow up with my proposed change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'd like to. Should I propose a issue first?

Copy link
Member

Choose a reason for hiding this comment

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

For my proposal here, no, you can just send a PR: #10875 (comment)

I didn't fully understand what @SeanNaren said but yeah, probably fine to send a PR without issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK

@mergify mergify bot removed the has conflicts label Dec 15, 2021
@awaelchli awaelchli added feature Is an improvement or enhancement progress bar: rich labels Dec 15, 2021
@awaelchli awaelchli merged commit fde326d into Lightning-AI:master Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement progress bar: rich ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RichProgressBar is not compatible with nohup command
5 participants