-
Notifications
You must be signed in to change notification settings - Fork 269
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
Convert all notebooks to sphinx gallery format #2377
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@maxnoe do you know why the docs build is failing? I only see Warnings in the log of the CI but no errors |
nvm, fixed it. Now it's failing because of magic commands |
(cta-dev) ~/D/p/c/examples ❯❯❯ black --preview examples/core/containers.py ✘ 146 sphinx-gallery-notebooks ✭ ✚ ◼
error: cannot format examples/core/containers.py: Cannot parse: 90:0: ?EventContainer # fmt: skip
Oh no! 💥 💔 💥
1 file failed to reformat. |
You need to add the needed packages to the |
I do have a problem building the environment for python 3.11:
With the main branch, I can install 3.11, so it must have something to do with sphinx's dependencies. With 3.10 it works |
I get the same error when I switch to the main branch and set python=3.11 in the environment.yml |
Could be a macos issue: I installed the ctapipe env with mamba and 3.11 a while ago, and haven't had issues. However, it could have changed if something updated in the mean time. I opened #2379 to check. With 3.10, I also can't build the docs on macos, but not sure if that is a general issue. The file "theta_square.py" fails with hundreds of errors like:
|
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.
Ah yes, I was busy with compiling this without errors. I will take a look. |
Some pretty funny stuff is happening that I don't understand :D So this is currently failing since Tools.ipynb gets stuck in an infinite loop.
try:
tool2.run(argv=["--config", "Tools.json"])
except SystemExit as e:
assert e.code == 0, f"Tool returned with error status {e}" The debug output prints some stuff about
|
Is there another python script in the |
-rw-r--r-- 1 stefan staff 5246 Jul 7 16:09 InstrumentDescription.py
-rw-r--r-- 1 stefan staff 66 Jul 7 16:09 README.rst
-rw-r--r-- 1 stefan staff 183546 Jul 11 09:59 Tools-thisbranch.ipynb
-rw-r--r-- 1 stefan staff 158 Jul 7 16:11 Tools.json
-rw-r--r-- 1 stefan staff 10125 Jul 7 16:11 Tools.py
-rw-r--r-- 1 stefan staff 13533 Jul 7 16:10 container.h5
-rw-r--r-- 1 stefan staff 5852 Jul 7 16:09 containers.py
-rw-r--r-- 1 stefan staff 32022561 Jul 11 09:39 mytool.provenance.log
-rw-r--r-- 1 stefan staff 3212 Jul 7 16:09 provenance.py
-rw-r--r-- 1 stefan staff 7941 Jul 7 16:09 table_writer_reader.py |
the problem seems to be having a file |
6996e9a
to
ee0ae22
Compare
We figured out what happened. The converted notebook file is called Traitlets loads all files in the directory with the same basename and extensions it supports for configuration files. So in the notebook, the tool tried to load the notebook itself as config file, resulting in an endless loop. I opened an issue here: ipython/traitlets#850 For now I'd just propose to call the config file |
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.
The animations don't seem to render correctly. See here for example
0d24947
to
2a2a66f
Compare
@kosack animations are rendering now |
23136dc
to
c6662cd
Compare
@maxnoe done |
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.
There is a weird double examples/examples
structure now and things that are rendered as part of the docs are living outside of the docs/
directory, I don't like that very much.
Why move out these things from where they are also in the toc hierarchy? Makes finding where things are defined much harder.
Also, I'd prefer to have the title be Tutorials and Examples
and have the Tutorials come first.
docs/user-guide/examples/README.txt
Outdated
.. _tutorials_and_examples_gallery: | ||
|
||
Tutorials and Examples gallery | ||
============================== |
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.
Minor style issue: this headline is at the section level, so the ones below it (each example/tutorial) should be a level deeper (so subsection)
For RST:
# with overline, for parts
* with overline, for chapters
= for sections
- for subsections
^ for subsubsections
" for paragraphs
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.
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.
Why is this a README.txt
file and not a .rst
file called index?
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 just the default sphinx gallery style
By default, Sphinx-Gallery creates all the files that are written in the sphinx-build directory, either by generating rst and images from a *.py in the gallery-source, or from creating index.rst from README.txt in the gallery-source.
I think I can change it
You may also want to pass raw rst from the gallery-source to the sphinx-build[...] To accommodate this, you may set copyfile_regex in sphinx_gallery_conf. The following copies across rst files.
sphinx_gallery_conf = {
...
'copyfile_regex': r'.*\.rst',
}
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.
Maybe the copyfile_regex is not needed since source and build dir are the same in this case
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.
But if I do this the toctree will not be generated by sphinx-gallery
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.
By default, Sphinx-Gallery creates all the files that are written in the sphinx-build directory,
Why did you change that so that the generated files clutter the docs source directory?
Thanks a lot! |
Ok, maybe we do need to move the scripts out of the docs directory. It seems the "doctest-modules" hangs on plots being opened because it tries to run the examples. |
This interfered with doctests collection, running the examples during the collection, which, since they are not modules but scripts, blocked it. Also added git and sphinx build dirs to pytest ignore directories.
d0af02a
to
6fb72e8
Compare
As discussed in #2221