-
Notifications
You must be signed in to change notification settings - Fork 921
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
Rich installation creates a non-uniform CLI experience #1752
Comments
It was our eventual plan to (at least try) to move kedro over to At the moment I find there's a more significant non-uniformity that exists inside kedro already: log messages are styled according to While on the topic, I'm curious what you think of typer. Do you think we should consider moving to it? Note that we have a relatively complicated click setup with some weird custom stuff going on (e.g. enable the hierarchy kedro built in command < plugin command < project cli.py), so I'm not sure how straightforward it would be. If we do want to adopt rich on the CLI then from what you say here it seems like we'd get it for free if we used typer with no need for rich-click. |
I'll try to remember. I was a mixture of sleep-deprived and annoyed at Rich when I wrote this. 😛
I'm not sure it's straightforward, but I think it's possible. I looked into it briefly when I learned about Typer, but it looked daunting, because of some of the things you mentioned; however, you can always generate underlying Click objects from Typer and use them where necessary. If we wanted to do this, would probably do it piece by piece, again because Typer is meant to be interoperable with Click. It would help getting rid of all those |
Two optional solutions that have been suggested When we start on working on Rich again, we'll need to make a decision on which solution to implement. |
Description
Kedro 0.18.2 requires Rich, but it doesn't use Rich in the CLI. Typer 0.6.x doesn't require Rich, but it detects and uses it, if installed. This means that a plugin with a Typer CLI will look different for the part if provides, compared to the default/other plugins' CLIs.
Context
How has this bug affected you? What were you trying to accomplish?
I'm using Typer to develop a Kedro plugin, because it's compatible with Click and has some advantages (e.g. type-hint-based syntax for specifying arguments). However, I spent several hours last night figuring out how to patch Typer in my plugin so that it wouldn't use Rich to format the usage messages, since Kedro doesn't (see below).
Steps to Reproduce
Create a plugin. The core code can look something like:
Install it.
From a Kedro project, run
kedro -h
,kedro kitty -h
, andkedro kitty meow -h
Expected Result
Tell us what should happen.
Ideally, you should have a uniform CLI.
You can achieve this by adding
under
import typer
, thereby monkeypatchingtyper
to make it think Rich wasn't installed/it's import attempt resulted in anImportError
. But this is probably fragile.Alternatively, you could just pin Typer to versions before it introduced Rich support, but that's obviously not ideal...
Other possibilities include using
rich-click
or Typer to use Rich uniformly through the CLI, but I'm personally not a fan of forcing a Rich CLI.Actual Result
Tell us what happens instead.
Yes, my conda env name betrays that I'm not actually working on Kedro-Kitty. 😿
Your Environment
Include as many relevant details about the environment in which you experienced the bug:
pip show kedro
orkedro -V
): 0.18.2python -V
): 3.10.5The text was updated successfully, but these errors were encountered: