Improving logging of Jupyter task to capture cell output #4283
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is a response to #4265, which was raised on Slack. The user wanted to capture Jupyter notebook cell outputs in the Prefect logs.
Changes
There are two things needed to get this to work. One is to pass the
log_output
bool intopapermill
's execute_notebook function. By default this is False. It needs to be True. For consistency with the previous implementation, I kept the default asFalse, though I feel there might be benefits in making it True.The second thing is to get the
papermill
logger and change the level toINFO
orDEBUG
. By default, it is atWARN
so it does not log cell outputs. I think we should not do this change on the task side. Instead, Prefect users should use the (extra loggers)[https://docs.prefect.io/core/concepts/logging.html#extra-loggers] part of the TOML config and add thepapermill
logger.There is an added test to see if the
papermill
logs are being captured. There are some edits to the .ipynb to see more output from thepapermill
logs.Checklist
This PR:
changes/
directory (if appropriate)docs/outline.toml
for API reference docs (if appropriate)