Add -m, -e and -d filters to %logstart 🤖🤖 - #15401
Open
costajohnt wants to merge 1 commit into
Open
costajohnt wants to merge 1 commit into
costajohnt wants to merge 1 commit into
Conversation
Let %logstart leave out cells with IPython special commands, input that raised, and input already logged, so a session log replays cleanly. Errored input (and its logged output) is held until post_run_cell reports the result; pending entries are a stack so cells run from inside a cell (%%capture, %rerun, %paste) are kept. Closes ipython#15344
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #15344
%logstartgets three flags for keeping a session log that replays cleanly:-mleaves out cells containing IPython special commands (magics, shell escapes, help lookups), i.e. input that IPython rewrites intoget_ipython()calls.-eleaves out input that raised. The entry, and its-ooutput, is held untilpost_run_cellreports the result. Pending entries are a stack, so cells run from inside a cell (%%capture,%rerun,%paste) are kept; an inner cell is written when it finishes, so it precedes the outer one.-dleaves out input that was already logged in the session. An errored entry dropped by-edoes not count as logged.They combine, for example
%logstart -med session.py.%logstatereports them.Two limits, both stated in the docstring: the filters apply to input entered after
%logstart(the history written when the log starts is not filtered), and-mworks per cell rather than per line, since raw-mode lines do not map one-to-one onto the transformed cell.Docs: the magic docstring,
docs/source/interactive/reference.rst, and awhatsnew/prfile.Tests in
tests/test_logger.py: each flag on its own,-rm,-oeoutput ordering, a nested%%capturecell under-e,-edtogether,-dresetting between logs, a check that magics are still logged without-m, and%logstateoutput.🤖🤖