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

RC_v1.5.0 API docs broken #297

Closed
freemansw1 opened this issue Jun 9, 2023 · 11 comments
Closed

RC_v1.5.0 API docs broken #297

freemansw1 opened this issue Jun 9, 2023 · 11 comments
Assignees
Labels
bug Code that is failing or producing the wrong result documentation Updates and improvements to documentation and examples
Milestone

Comments

@freemansw1
Copy link
Member

https://tobac.readthedocs.io/en/rc_v1.5.0/tobac.html

@freemansw1 freemansw1 added this to the Version 1.5 milestone Jun 9, 2023
@freemansw1 freemansw1 self-assigned this Jun 9, 2023
@w-k-jones
Copy link
Member

w-k-jones commented Jun 11, 2023

Just went back through the pull requests for RC_v1.5.0, the docs breaking occurs with #259 and #127

Which is odd because as far as I can see neither modifies the API reference section of the docs...

Could it be something to do with the changes to the utils structure?

@fsenf
Copy link
Member

fsenf commented Jun 12, 2023

autodoc seems to run into an import error:

...
WARNING: autodoc: failed to import module 'analysis' from module 'tobac'; the following exception was raised:
...

@fsenf
Copy link
Member

fsenf commented Jun 12, 2023

OK, now I read further:

...
  File "/home/docs/checkouts/readthedocs.org/user_builds/tobac/checkouts/293/tobac/utils/periodic_boundaries.py", line 261, in <module>
    high: float = 2 * np.pi,
TypeError: unsupported operand type(s) for *: 'int' and '_MockObject'

The problem comes with the fact that we mock all python libs like numpy and this appear to be in conflict with the variable definition using type hints.

@freemansw1 : You could try out float = 2. * np.pi ...

@JuliaKukulies
Copy link
Member

JuliaKukulies commented Jun 13, 2023

I tried that @fsenf @freemansw1 and the API looks fine when I locally build the page, but it does not seem to do the job (https://tobac--303.org.readthedocs.build/en/303/tobac.html ).

The pull requests that have not merged in the period boundary changes seem to work, e.g.
https://tobac--281.org.readthedocs.build/en/281/tobac.html#tobac-utils-general-modules And we had already changed the utils structure in these, so I am not sure if it is really related to the utils submodules @w-k-jones.

We forgot indeed to add tobac.utils.periodic_boundaries and tobac.utils.internal to doc/tobac.rst but this does not fix it either :(

@fsenf
Copy link
Member

fsenf commented Jun 22, 2023

Hi,

I was able to reproduce the bug in a clean setup using the description here: https://github.com/tobac-project/tobac-tutorials/blob/main/docs/Testing-Sphinx-based-Rendering.md up to the end of Section 1 (replacing tobac-tutorials with tobac).

Some additional commands:

 pip install sphinx_rtd_theme
sphinx-build -b html doc doc/_build/html

Last command also fails with

...
  File "/tmp/website-testing/tobac/tobac/utils/periodic_boundaries.py", line 261, in <module>
    high: float = 2 * np.pi,
TypeError: unsupported operand type(s) for *: 'int' and 'pi'
...

@fsenf
Copy link
Member

fsenf commented Jun 22, 2023

float = 2. * np.pi does not help.

@fsenf
Copy link
Member

fsenf commented Jun 22, 2023

SOLUTION:

The API doc come back again if we do not mock numpy:

> git diff
diff --git a/doc/conf.py b/doc/conf.py
index 0f5e48e..e897fd7 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -43,7 +43,7 @@ def setup(app):
 # This should include all modules used in tobac. These are dummy imports,
 # but should include both required and optional dependencies.
 autodoc_mock_imports = [
-    "numpy",
+#    "numpy",
     "scipy",
     "scikit-image",
     "pandas",
diff --git a/doc/requirements.txt b/doc/requirements.txt
index 82f69f7..6ba789a 100644
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -1,2 +1,3 @@
 ipykernel
 nbsphinx
+numpy

@fsenf
Copy link
Member

fsenf commented Jun 22, 2023

@freemansw1 @w-k-jones @JuliaKukulies : Can we afford to install numpy at each readthedocs re-rendering? I think, yes. What do you think?

@w-k-jones
Copy link
Member

w-k-jones commented Jun 22, 2023

Would it be possible to switch to using math.pi for the default value instead? That way we should be able to keep numpy as a mock

@fsenf
Copy link
Member

fsenf commented Jun 22, 2023

Yes, this works!

But

  1. one need to input an import that is barely used import math
  2. the internals of the function use np.pi which would be inconsistent with the opt. arg definition

@freemansw1 freemansw1 added bug Code that is failing or producing the wrong result documentation Updates and improvements to documentation and examples labels Jul 6, 2023
@freemansw1
Copy link
Member Author

Resolved with #305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Code that is failing or producing the wrong result documentation Updates and improvements to documentation and examples
Projects
None yet
Development

No branches or pull requests

4 participants