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
dismiss "Black is not installed, parameters wont be formatted" message #661
Comments
Hello @edublancas, you want to remove this message or replace it by something else? |
we want to suppress it, note that this is coming from an external library (papermill), so I think we need to modify the command-line interface code to suppress warnings coming from papermill to reproduce: first, get an example pip install ploomber
ploomber -n templates/ml-basic -o example
cd example
pip install -r requirements.txt Then:
Note: ensure black isn't installed in the environment |
maybe you have black installed?
|
Will look into it @edublancas. Meanwhile, while looking into this issue I found another issue #664 |
sure, merged your PR, thanks! as a tip, I think we want to use the when calling parametrize_notebook, we should temporarily suppress loggings coming from papermill, here's we were are calling parametrize_notebook (note that we are calling it in multiple places):
|
@rishav-karanjit any updates here? |
I don't think I would be working on this issue @idomic |
For the reproduce example, I think Looking into how to suppress warnings from imported modules with logging. |
hi @94rain, the message is coming from papermill, a library we use to execute notebooks. Ideally, we only want to suppress warnings when this message is displayed, as there might be other warnings that are important for the user. the first step is to figure out where exactly papermill is generating the warning. it should be in one of these two places: when we prepare the notebook: https://github.com/ploomber/ploomber/blob/master/src/ploomber/sources/notebooksource.py or when we execute it: https://github.com/ploomber/ploomber/blob/master/src/ploomber/tasks/notebook.py |
I am able to suppress all messages output by the codify function (which outputs the Black is not installed message) using the following code snippet in notebooksource.py. + logging.basicConfig(level=logging.ERROR)
from papermill.parameterize import parameterize_notebook
+ class IgnoreBlackWarning(logging.Filter):
+ def filter(self, record):
+ return not record.funcName == 'codify'
+ logging.getLogger("papermill").addHandler(IgnoreBlackWarning) I am not sure if there are simpler ways to implement this. I tried to do things like I'm not sure if adding |
@94rain does it suppress all warnings or just black? I think the better option instead of instantiating a logger is to catch the specific black warning. Did you try something along the lines of the functions Eduardo sent?
Then in it you can match the warning text and remove it only if there's a match. |
At this time the snippet above will suppress all warnings. I mean we can pass in the logger level from cli? ploomber/src/ploomber/cli/parsers.py Line 513 in 1048e5e
Yeah, I tried things in that block like the following but they do not seem to work
So we have to use the logging module (The warning is generated by logging). I am still finding out if there are easy ways to do text matching. Another possible approach is to suppress all warnings from the logger of papermill before calling
|
You're right, for some reason even when putting in the main class:
Which should ignore all warnings, this is still being printed, not sure exactly why. |
@94rain is right: papermill is generating the message using logging, so using |
After some retries, I just realized what I did wrong here. I need to use The following code snippet is able to remove only the messages that contain with warnings.catch_warnings():
warnings.simplefilter('ignore', FutureWarning)
class IgnoreBlackWarning(logging.Filter):
def filter(self, record):
return 'Black is not installed' not in record.msg
logging.getLogger("papermill.translators").addFilter(IgnoreBlackWarning()) I will create a PR tomorrow. Do we need test cases for this? |
great, thanks for figuring this out. no need to add test cases question, do we need this? with warnings.catch_warnings(): I thought we didn't need to use the warnings module, maybe this alone will work? class IgnoreBlackWarning(logging.Filter):
def filter(self, record):
return 'Black is not installed' not in record.msg
logging.getLogger("papermill.translators").addFilter(IgnoreBlackWarning()) |
That alone will work for suppressing the black warning. I found there is a comment above |
ok, so let's just keep the code to remove the black warning and remove the about pyarrow: they fixed that in the latest papermill release, so no need to worry about it. |
Sounds good! Will remove |
No worries, thanks for helping out!
…On Mon, May 23, 2022, 20:09 Rishav karanjit ***@***.***> wrote:
I don't think I would be working on this issue @idomic
<https://github.com/idomic>
—
Reply to this email directly, view it on GitHub
<#661 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACYPJOOXLEAFKKFHZ5ZEIETVLQM2RANCNFSM5RDLZPJQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
papermill shows a logging message if black is not installed, which is causing confusion for ploomber users.
https://github.com/nteract/papermill/blob/aecd0ac16d34dd41a1a8e4ca3351844932af3d94/papermill/translators.py#L195
we should suppress the message
The text was updated successfully, but these errors were encountered: