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
DOC: Add section on executing notebooks #191
Conversation
In this section we show how to execute a ``.ipynb`` notebook | ||
document saving the result in notebook format. | ||
To export the notebook to other formats see the | ||
:ref:`next section <nbconvert_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.
It's probably better to refer to this by name, because if we rearrange the docs or put another page in between, we won't think about this.
@takluyver, thanks for the comments. I fixed the the points you raised. Still, I left a note on |
Wait for a few fixes left. |
ae9cc26
to
82e5d34
Compare
Done with fixes.
Would be nice to add the |
I also rebased to clean the history. |
@tritemio Thanks for this PR. It's very helpful. I have some grammar and style edits to make the section more user friendly. 😎 |
|
||
Currently, ``nbconvert`` is provided as a command line tool, run as a script | ||
using Jupyter. It also powers the 'Download as' feature within the | ||
``nbconvert`` is both a python library and a command line tool (invoked as |
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.
Python
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.
@willingc is right, it should be a capital P here.
@willingc I applied your fixes. Let me know if you want to further tweak the intro. |
@Carreau, I think your example on exporting notebooks should go on a different section, for example here: However this section is currently a mess and should be heavily re-edited IMHO. @willingc, @Carreau, @takluyver is there a way to make traitlets descriptions appear in sphinx API documentation? |
I don't think so, unfortunately. Maybe it could be done with a Sphinx extension, if somebody is interested in writing one. |
@takluyver, regarding the
No reference to the opened file is saved and the file is closed when
And, in the final example on error handling, adding the
What's your take on this? |
On Python 3, a file that isn't explicitly closed and gets cleaned up when all references to it are gone generates a ResourceWarning. Admittedly these aren't visible by default, and perhaps it's overly strict, but they do show up during tests, so I still think it's better to point people to |
Ok, I didn't know that, I'll leave the PR as is then, using |
https://docs.python.org/3.5/library/warnings.html#default-warning-filters |
Yep, like I said, they're not visible by default. You can enable them without rebuilding Python, though, and doing that when testing is good practice. |
seeing that this is an improvement on our docs I would be +1 to merge and iterate. |
Regarding the verbosity of loading, executing and saving the notebook, I proposed in the past a top-level function #125 to run notebooks in one step. Nowadays I use a slightly improved version of that function which allows to optionally pass parameters to the notebook to be executed (~like a function). See nbrun, rudimentary but incredibly useful in my workflow. |
@Carreau +1 on merge and iterate. Will leave to you or @takluyver to merge. @tritemio Thank you! 🍪 |
@willingc, thanks, glad I earn a 🍪! |
@tritemio 👍 Also, 🏄 🌴 🍰 is a virtual vacation ;) |
Just added one last commit, I'm done now. |
help=dedent( | ||
""" | ||
The time to wait (in seconds) for output from executions. | ||
If a cell execution takes longer, a `CellExecutionError` |
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.
Looking at the code, it actually raises TimeoutError
on Python 3 and RuntimeError
on Python 2 (because TimeoutError is new in Python 3)
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.
@takluyver fixed in the last commit.
Thanks for all your work on this! |
DOC: Add section on executing notebooks
Yes! Thanks @tritemio for the good work and @takluyver for the helpful reviews. |
🍰 |
This section shows how to execute notebooks using nbconvert API. The executed notebook is saved in notebook format. There is no discussion on exporting notebooks to other format (topic already addressed in another section of the docs).
This is heavily based on this blog post: Batch Execution of Jupyter Notebooks.
Except for links/formatting fixes it should be ready for review. I can rebase to clean history before merge.