Skip to content
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

pytest: build_sphinx failing when examples are modified #1174

Open
ddkohler opened this issue Mar 23, 2024 · 1 comment · May be fixed by #1173
Open

pytest: build_sphinx failing when examples are modified #1174

ddkohler opened this issue Mar 23, 2024 · 1 comment · May be fixed by #1173

Comments

@ddkohler
Copy link
Contributor

This test fails only when examples are modified (e.g. #1173 ).

tests/docs/_sphinx.py::test_build_docs FAILED                            [ 73%]

My guess is that build_sphinx doesn't render examples unless the files have been modified, so that is why this error is coming up now. I could be wrong.

test fails in fringes_transform.py importing datasets:

WARNING: /home/runner/work/WrightTools/WrightTools/examples/fringes_transform.py failed to execute correctly: Traceback (most recent call last):
  File "/home/runner/work/WrightTools/WrightTools/examples/fringes_transform.py", line 14, in <module>
    p = datasets.PyCMDS.w2_w1_000
        ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'WrightTools.datasets.PyCMDS' has no attribute 'w2_w1_000'

Seems to be related to special module load conditions in sphinx_build. If I query datasets.PyCMDS.dict, I get items:

dict_items([('__name__', 'WrightTools.datasets.PyCMDS'), ('__doc__', None), ('__package__', 'WrightTools.datasets.PyCMDS'), ('__loader__', <_frozen_importlib_external.NamespaceLoader object at 0x7fe20e02dfd0>), ('__spec__', ModuleSpec(name='WrightTools.datasets.PyCMDS', loader=<_frozen_importlib_external.NamespaceLoader object at 0x7fe20e02dfd0>, submodule_search_locations=_NamespacePath(['/home/runner/work/WrightTools/WrightTools/WrightTools/datasets/PyCMDS']))), ('__file__', None), ('__path__', _NamespacePath(['/home/runner/work/WrightTools/WrightTools/WrightTools/datasets/PyCMDS']))])

Possibly related to our special need to delete the datasets module between runs (see docs/conf.py:sphinx_gallery_conf)

Why does this example fail in particular? All other examples run without issue, including others that use datasets.PyCMDS. It's probably important that PyCMDS.w2_w1_000 is the only dataset used in multiple scripts. The first script that uses it (split.py) runs fine...

@ddkohler
Copy link
Contributor Author

ddkohler commented Mar 23, 2024

I can confirm the issue is opening w2_w1_000 twice. If split.py doesn't access this attribute, it works as expected in fringes_transform.py; the reset_wt hack is not working as desired atm.

cf. https://sphinx-gallery.github.io/stable/advanced.html#cleaning-the-gallery-files

@ddkohler ddkohler linked a pull request Apr 1, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant