Skip to content

Conversation

mkoeppe
Copy link
Contributor

@mkoeppe mkoeppe commented Apr 24, 2024

We also change how the SPKG index in the reference manual is generated.
index.rst is now a static file that uses .. include directives to read in generated files index_standard.rst, index_optional.rst, etc.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Apr 25, 2024

Documentation preview for this PR (built with commit 1c6e248; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@kwankyu
Copy link
Collaborator

kwankyu commented Apr 26, 2024

This needs to be updated:

Features

(btw, I think this list should be automatically generated and split from spkgs list and moved to a new location.)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 26, 2024

Shall we use a sphinx .. include directive for that?

@kwankyu
Copy link
Collaborator

kwankyu commented Apr 27, 2024

I don't know. Anyway, this is for a new PR. I may work on it later.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 27, 2024

Here's an attempt. The list of features is not autogenerated (we don't do that for any Python modules); but at least it's now in an ordinary editable index file.

Copy link
Collaborator

@kwankyu kwankyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

LGTM.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 27, 2024

Thank you!

@vbraun
Copy link
Member

vbraun commented Apr 28, 2024

I'm getting

[sagemath_doc_html-none] [spkg-install] sage --docbuild --no-pdf-links reference/modules inventory --no-prune-empty-dirs
[sagemath_doc_html-none] [spkg-install] [spkg     ] The inventory file is in ../../local/share/doc/sage/inventory/en/reference/spkg.
[sagemath_doc_html-none] [spkg-install] Error building the documentation.
[sagemath_doc_html-none] [spkg-install] Traceback (most recent call last):
[sagemath_doc_html-none] [spkg-install]   File "<frozen runpy>", line 198, in _run_module_as_main
[sagemath_doc_html-none] [spkg-install]   File "<frozen runpy>", line 88, in _run_code
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/__main__.py", line 514, in <module>
[sagemath_doc_html-none] [spkg-install]     sys.exit(main())
[sagemath_doc_html-none] [spkg-install]              ^^^^^^
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/__main__.py", line 510, in main
[sagemath_doc_html-none] [spkg-install]     builder()
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/builders.py", line 823, in _wrapper
[sagemath_doc_html-none] [spkg-install]     getattr(DocBuilder, build_type)(self, *args, **kwds)
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/builders.py", line 163, in f
[sagemath_doc_html-none] [spkg-install]     runsphinx()
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/sphinxbuild.py", line 319, in runsphinx
[sagemath_doc_html-none] [spkg-install]     sys.stderr.raise_errors()
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/sphinxbuild.py", line 255, in raise_errors
[sagemath_doc_html-none] [spkg-install]     raise OSError(self._error)
[sagemath_doc_html-none] [spkg-install] OSError: /home/release/Sage/src/doc/en/reference/spkg/index.rst:28: WARNING: toctree contains reference to nonexisting document 'sage/features'

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 28, 2024

@vbraun Is that in an incremental build? This looks like #37786.

Anyway I have pushed a possible fix

@vbraun
Copy link
Member

vbraun commented Apr 29, 2024

Yes, incremental

@vbraun
Copy link
Member

vbraun commented May 1, 2024

Still fails. Try

./bootstrap
cd src/doc
make doc-inventory--reference-spkg     # fail
make doc-inventory--reference-spkg     # succeeds

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 9, 2024

I can't reproduce a failure

@vbraun
Copy link
Member

vbraun commented Jun 9, 2024

I'm getting

[sagemath_doc_html-none] [spkg-install] Error building the documentation.
[sagemath_doc_html-none] [spkg-install] Traceback (most recent call last):
[sagemath_doc_html-none] [spkg-install]   File "<frozen runpy>", line 198, in _run_module_as_main
[sagemath_doc_html-none] [spkg-install]   File "<frozen runpy>", line 88, in _run_code
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/__main__.py", line 530, in <module>
[sagemath_doc_html-none] [spkg-install]     sys.exit(main())
[sagemath_doc_html-none] [spkg-install]              ^^^^^^
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/__main__.py", line 526, in main
[sagemath_doc_html-none] [spkg-install]     builder()
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/builders.py", line 823, in _wrapper
[sagemath_doc_html-none] [spkg-install]     getattr(DocBuilder, build_type)(self, *args, **kwds)
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/builders.py", line 163, in f
[sagemath_doc_html-none] [spkg-install]     runsphinx()
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/sphinxbuild.py", line 319, in runsphinx
[sagemath_doc_html-none] [spkg-install]     sys.stderr.raise_errors()
[sagemath_doc_html-none] [spkg-install]   File "/home/release/Sage/src/sage_docbuild/sphinxbuild.py", line 255, in raise_errors
[sagemath_doc_html-none] [spkg-install]     raise OSError(self._error)
[sagemath_doc_html-none] [spkg-install] OSError: /home/release/Sage/src/doc/en/reference/spkg/index.rst:28: WARNING: toctree contains reference to nonexisting document 'sage/features'

@vbraun
Copy link
Member

vbraun commented Jun 9, 2024

Looks like this is a parallel build race, works when building in a single thread. But make doc-clean && make -j10 doc-html errors out reliably for me. One of the parallel tasks prints a line

[sagemath_doc_html-none] [spkg-install] Deleting empty directory /home/release/Sage/src/doc/en/reference/spkg/sage/features

Seems like the doc-inventory--reference-spkg target conflicts

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 9, 2024

Thanks for the details. I'll try to repro

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 10, 2024

@vbraun What is your system?

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 10, 2024

@vbraun Would you try #38185? This time with make doc-clean doc-uninstall.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 12, 2024
sagemathgh-38185: Simplify doc build process by removing empty directories locally
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

and thus hopefully fixes the mysterious issue
sagemath#37858 (comment).

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

sagemath#37858

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38185
Reported by: Kwankyu Lee
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 12, 2024
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

- Part of sagemath#35856

We also change how the SPKG index in the reference manual is generated.
`index.rst` is now a static file that uses `.. include` directives to
read in generated files `index_standard.rst`, `index_optional.rst`, etc.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->

URL: sagemath#37858
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
@kwankyu
Copy link
Collaborator

kwankyu commented Jun 13, 2024

@vbraun Does #38185 work well with you? Then it needs review.

@vbraun
Copy link
Member

vbraun commented Jun 14, 2024

Worked for me

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 14, 2024

Great! Thanks.

@vbraun
Copy link
Member

vbraun commented Jun 15, 2024

Actually no, still happens upon further testing

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 15, 2024

It is hard to "fix" an invisible issue. So what is your system and reproducing procedure?

vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 16, 2024
sagemathgh-38185: Simplify doc build process by removing empty directories locally
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

and thus hopefully fixes the mysterious issue
sagemath#37858 (comment).

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

sagemath#37858

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38185
Reported by: Kwankyu Lee
Reviewer(s):
@vbraun
Copy link
Member

vbraun commented Jun 16, 2024

The following steps reproducably cause the failure for me:

$ git clean -f -d -x ./src/doc/en/reference/spkg && ./bootstrap && touch src/doc/en/reference/spkg/index.rst  && ./sage --docbuild --no-pdf-links reference/spkg inventory --no-prune-empty-dirs
[...]
OSError: /home/release/Sage/src/doc/en/reference/spkg/index.rst:28: WARNING: toctree contains reference to nonexisting document 'sage/features'

Running the docbuild command a second time succeeds, then

$ ./sage --docbuild --no-pdf-links reference/spkg inventory --no-prune-empty-dirs
[spkg     ] updating environment: 31 added, 1 changed, 0 removed
[spkg     ] The inventory file is in local/share/doc/sage/inventory/en/reference/spkg.

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 16, 2024

Don't you get the same failure if you replace spkg with coding everywhere? I do.

There may be some bug hidden in the doc build procedure in general...

Strangely, this

$ git clean -f -d -x ./src/doc/en/reference/coding && touch src/doc/en/reference/coding/index.rst && ./sage --docbuild --no-pdf-links --no-prune-empty-dirs reference/coding inventory 

fails every other time...

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 16, 2024

After more experiments, I now realized there is nothing strange in the above experiments. We are breaking assumptions by git clean -f -d -x ./src/doc/en/reference/spkg (or coding). No fault on the doc build mechanism.

The doc build starts initially with the state made by make doc-clean (cleaning src/doc/sage) and make doc-uninstall (removing local/share/doc). This should work

$ make doc-uninstall && git clean -f -d -x ./src/doc/en/reference/spkg && ./bootstrap && touch src/doc/en/reference/spkg/index.rst  && ./sage --docbuild --no-pdf-links reference/spkg inventory --no-prune-empty-dirs

reliably.

Not a bug unless you see it after make doc-clean doc-uninstall

@vbraun
Copy link
Member

vbraun commented Jun 17, 2024

I've seen it after make doc-clean doc-uninstall (because that is in my merge / incremental build script), I just don't have a repro. But it is out there. I run into this issue occasionally when making incremental builds.

And the issue is that dependencies of docbuild artifacts are apparently insufficient.

I think this branch exacerbates the issue because it places /doc/en/reference/spkg/index.rst under version control. So if you frequently change branches its easy to update timestaps which triggers incremental rebuilds, and then if you are unlucky docbuild trips over missing dependencies.

@kwankyu
Copy link
Collaborator

kwankyu commented Jun 17, 2024

I just now met the bug. As you say, It seems related with switching branches.

@@ -173,7 +173,7 @@ distclean: build-clean
bootstrap-clean:
rm -rf config/install-sh config/compile config/config.guess config/config.sub config/missing configure build/make/Makefile-auto.in
rm -f src/doc/en/installation/*.txt
rm -rf src/doc/en/reference/spkg/*.rst
find src/doc/en/reference/spkg -name index.rst -prune -o -name *.rst -exec rm -f {} \+
for a in environment environment-optional src/environment src/environment-dev src/environment-optional; do rm -f $$a.yml $$a-3.[89].yml $$a-3.1[0-9].yml; done
Copy link
Collaborator

@kwankyu kwankyu Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the source of the "bug" Volker was experiencing.

Unlike previous rm -rf src/doc/en/reference/spkg/*.rst, where the option -r is really ineffective, the find command searches the directory src/doc/en/reference/spkg and its subdirectories, and removes all *.rst files. In particular the file src/doc/en/reference/spkg/sage/features.rst is removed.

The file is in control of the doc builder and to be updated by it if necessary. Suppose that the file is created by the doc builder in other git branch. After switching to this PR branch, ./bootstrap removes the file, but the doc builder still believes the file is intact, and the removed file is not recreated. Hence the boom.

Incremental doc build mixed with switching git branches is inherently instable. But the changed behavior caused by this PR (the command in line 176) exacerbates the instability, as Volker could see through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this detective work!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Works well with me (that is, no more the bug for me).

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 19, 2024

Thanks!

@vbraun vbraun merged commit b7ae5f9 into sagemath:develop Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants