executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
200 stars 80 forks source link

Using include directive, conf.py configuration is not picked up #583

Open enryH opened 4 months ago

enryH commented 4 months ago

Describe the bug

context When I include a notebook into sphinx from a different location as described here, the conf.py parameter is not picked up:

.. include:: ../../some/nexted/path/include.ipynb
   :parser: myst_nb.docutils_

My notebook is executed correctly in the local context and included.

expectation I expected it to pick up the configuration from my conf.py.

bug But instead I ran into a "Executing notebook failed: CellTimeoutError [mystnb.exec]" error, which I tried to fix using the following configuration in conf.py

# https://myst-nb.readthedocs.io/en/latest/configuration.html#global-configuration
nb_execution_timeout = 240  # otherwise it's a 30 seconds maximum per cell,

# https://myst-nb.readthedocs.io/en/latest/configuration.html
# Execution
nb_execution_raise_on_error = True

problem So it might be only a documentation question, but: How do I set the configuration if I want to include a notebook which is not present in the docs folder with the sphinx conf.py file?

If I try to set the docutils.conf file as

[general]
nb_execution_mode = auto
nb_execution_raise_on_error = true
nb_merge_streams = true
nb_execution_timeout = 120

I get the warning: (ERROR/3) myst-nb configuration invalid: 'execution_timeout' must be of type <class 'int'> (got '120' that is a <class 'str'>). [mystnb]

Is there any way to set the NbParserConfig in the include directive?

Reproduce the bug

  1. Use the include directive and add it to the extra/test.rst file:
.. include:: ../../project/test.ipynb
   :parser: myst_nb.docutils_

and then include that into index.rst:

 .. toctree::
   :maxdepth: 2
   :caption: test

   extra/test

List your environment

myst-nb                       0.17.2
myst-parser                 0.18.1

I don't have jupyter book installed.

welcome[bot] commented 4 months ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

enryH commented 4 months ago

Adding the desired configuration to the notebook metadata works, see documentation here.