-
Notifications
You must be signed in to change notification settings - Fork 908
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 it possible to use Kedro after uninstalling Rich. #3838
Conversation
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
kedro/logging.py
Outdated
@@ -30,6 +30,10 @@ class RichHandler(rich.logging.RichHandler): | |||
""" | |||
|
|||
def __init__(self, *args: Any, **kwargs: Any): | |||
if rich is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the basic idea that users who don't install rich should default to this? So for users who already have rich installed and no longer want it they need to pip uninstall rich
? If that is the case we should document the steps they need to take.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noklam do you have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought on this it shouldn't touch the log handler.
If the custom logger has Rich handler, it should raise error when it is not installed. To get rid of this the solution is just remove rich from the handler.
The thing that user cannot change now is all the traceback error / CLI that ties with rich. Essentially one cannot run Kedro without rich. @astrojuanlu
I am surprised the _ProjectLogging isn't changed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SajidAlamQB yes, the way this is set up at the moment, if the user does not want rich to be used, it would need to be uninstalled.
Hey @lrcouto, this is an interesting approach, I think we will also need to modify |
Co-authored-by: Sajid Alam <[email protected]> Signed-off-by: L. R. Couto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Co-authored-by: Sajid Alam <[email protected]> Signed-off-by: L. R. Couto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
Don't quite understand that part, could you elaborate @noklam ? |
Co-authored-by: Juan Luis Cano Rodríguez <[email protected]> Signed-off-by: L. R. Couto <[email protected]>
@astrojuanlu Alright I was confused because I see no changes on these: Line 35 in 9da8b37
and Lines 56 to 60 in 9da8b37
Now I realise the logic is in the early My question is, why do we want to be clever about the In that case, I think it's reasonable to fail rather than being smart about it. kedro/kedro/framework/project/__init__.py Lines 220 to 224 in 9da8b37
|
@@ -40,4 +40,4 @@ loggers: | |||
level: INFO | |||
|
|||
root: | |||
handlers: [rich, info_file_handler] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need both handlers? would it duplicates the log?
I was looking into this idea of adding a non-rich default yesterday, but that would mean having to try to import rich on init.py to check if it is installed, and I was trying to avoid adding more imports. I think it's a valid idea regardless. We could have a non-rich version that gets defaulted to if rich is not present, and that would allow us to not have to mess with the logging handler. What do you think? |
Signed-off-by: lrcouto <[email protected]>
Ugh, thanks for the investigation @lrcouto. We'll give this some thought. |
pyproject.toml
Outdated
@@ -16,7 +16,7 @@ dependencies = [ | |||
"build>=0.7.0", | |||
"cachetools>=4.1", | |||
"click>=4.0", | |||
"cookiecutter>=2.1.1,<3.0", | |||
"cookiecutter>=2.1.1,<2.3", # 2.3 onwards depends on rich, which we want to avoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't pin cookiecutter so strictly, but instead clarify in docs that if users don't want to use rich
they might have to downgrade their cookiecutter
version.
Signed-off-by: lrcouto <[email protected]>
…o-org/kedro into remove-rich-as-mandatory-dependence
In line with #2928 (comment), maybe let's rename the PR to make it clear that we're not marking |
Signed-off-by: lrcouto <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments, but nothing blocking.
Great work! 👍
@@ -241,3 +241,21 @@ Customise the configuration loader arguments in `settings.py` as follows if your | |||
```python | |||
CONFIG_LOADER_ARGS = {"default_run_env": "base"} | |||
``` | |||
|
|||
### How to use Kedro without the rich library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section will fit better in the logging docs: https://docs.kedro.org/en/stable/logging/index.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about putting it in the logging page, as it already mentions rich
a lot, but since it affects features other than logging I thought it'd fit better as more general configuration information. What do you think about adding it to both pages?
kedro/ipython/__init__.py
Outdated
@@ -39,6 +44,8 @@ | |||
|
|||
FunctionParameters = MappingProxyType | |||
|
|||
RICH = True if importlib.util.find_spec("rich") is not None else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name this RICH_INSTALLED
?
Co-authored-by: Merel Theisen <[email protected]> Signed-off-by: L. R. Couto <[email protected]>
Signed-off-by: lrcouto <[email protected]>
…o-org/kedro into remove-rich-as-mandatory-dependence
Signed-off-by: lrcouto <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @lrcouto for taking this on, tested this manually and this looks good to me. 🌟
Description
Allows Kedro to work regardless of the
rich
library being installed. At this moment, installing Kedro will still installrich
, but the user will have the option to remove the library and still have everything work.Because
cookiecutter
versions 2.3 and above depend onrich
, it is also necessary to remove the version installed automatically by Kedro and install a compatible one to be able to run withoutrich
.Logging, prompts, and the
kedro ipython
command will work withoutrich
given a compatiblecookiecutter
version is also being used. Our own unit tests will not, they will fail withoutrich
.Development notes
Developer Certificate of Origin
We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a
Signed-off-by
line in the commit message. See our wiki for guidance.If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.
Checklist
RELEASE.md
file