opendp / docs.smartnoise.org

A work in progress.

Home Page:http://docs.opendp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot built docs: AttributeError: module 'opendp.smartnoise.synthesizers' has no attribute 'QUAILSynthesizer'

pdurbin opened this issue · comments

This relates to the automated building of Python docs added in pull request #13.

I'm not sure where the QUAILSynthesizer error comes from. I just did a fresh install and here are the versions I'm using:

Successfully installed Jinja2-3.0.1 MarkupSafe-2.0.1 Pygments-2.9.0 alabaster-0.7.12 antlr4-python3-runtime-4.8 babel-2.9.1 beautifulsoup4-4.9.3 certifi-2021.5.30 chardet-4.0.0 docutils-0.16 greenlet-1.1.0 idna-2.10 imagesize-1.2.0 isodate-0.6.0 msrest-0.6.21 numpy-1.20.3 oauthlib-3.1.1 opendp-smartnoise-0.1.4 opendp-smartnoise-core-0.2.2 packaging-20.9 pandas-1.2.4 pandasql-0.7.3 patsy-0.5.1 protobuf-3.17.3 pydata-sphinx-theme-0.6.3 pyparsing-2.4.7 python-dateutil-2.8.1 pytz-2021.1 pyyaml-5.4.1 requests-2.25.1 requests-oauthlib-1.3.0 scipy-1.6.3 six-1.16.0 snowballstemmer-2.1.0 soupsieve-2.2.1 sphinx-3.5.2 sphinx-multiversion-0.2.4 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 sqlalchemy-1.4.17 statsmodels-0.12.2 urllib3-1.26.5

I poked around in https://github.com/opendp/smartnoise-sdk/commits/main and https://pypi.org/project/opendp-smartnoise/#history but I'm not sure what changed.

Here's the full output of the error:

(venv) HMDC-beamish:opendp-documentation pdurbin$ make html
sphinx-build -W -D 'html_sidebars.**'=search-field.html,sidebar-nav-bs.html source build/html
Running Sphinx v3.5.2
*****************************************
/private/tmp/sdafssda/opendp-documentation/source/..
/private/tmp/sdafssda
/private/tmp/sdafssda/opendp-documentation/venv/bin
/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9
/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload
/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages
*****************************************
ModuleSpec(name='opendp.smartnoise', loader=<_frozen_importlib_external.SourceFileLoader object at 0x10e6dffd0>, origin='/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/opendp/smartnoise/__init__.py', submodule_search_locations=['/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/opendp/smartnoise'])
*****************************************
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 28 source files that are out of date
updating environment: [new config] 28 added, 0 changed, 0 removed
reading sources... [ 50%] smartnoise/api-reference/opendp.smartnoise.core.componreading sources... [ 64%] smartnoise/api-reference/opendp.smartnoise.synthesizerreading sources... [ 67%] smartnoise/api-reference/opendp.smartnoise.synthesizerreading sources... [100%] user/related-projects                                 

Warning, treated as error:
autodoc: failed to import class 'QUAILSynthesizer' from module 'opendp.smartnoise.synthesizers'; the following exception was raised:
Traceback (most recent call last):
  File "/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/util/inspect.py", line 393, in safe_getattr
    return getattr(obj, name, *defargs)
AttributeError: module 'opendp.smartnoise.synthesizers' has no attribute 'QUAILSynthesizer'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/ext/autodoc/importer.py", line 111, in import_object
    obj = attrgetter(obj, mangled_name)
  File "/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 320, in get_attr
    return autodoc_attrgetter(self.env.app, obj, name, *defargs)
  File "/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 2604, in autodoc_attrgetter
    return safe_getattr(obj, name, *defargs)
  File "/private/tmp/sdafssda/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/util/inspect.py", line 409, in safe_getattr
    raise AttributeError(name) from exc
AttributeError: QUAILSynthesizer

make: *** [html] Error 2
(venv) HMDC-beamish:opendp-documentation pdurbin$ 

Obviously, this isn't a solution but deleting the following gets the docs to build:

diff --git a/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.pytorch.nn.rst b/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.pytorch.nn.rst
index 0f1c0c7..de5f3b0 100644
--- a/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.pytorch.nn.rst
+++ b/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.pytorch.nn.rst
@@ -1,22 +1,3 @@
 opendp\.smartnoise\.synthesizers\.pytorch\.nn package
 =====================================================
 
-.. autoclass:: opendp.smartnoise.synthesizers.pytorch.nn.PATECTGAN
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-.. autoclass:: opendp.smartnoise.synthesizers.pytorch.nn.DPCTGAN
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-.. autoclass:: opendp.smartnoise.synthesizers.pytorch.nn.PATEGAN
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-.. autoclass:: opendp.smartnoise.synthesizers.pytorch.nn.DPGAN
-    :members:
-    :undoc-members:
-    :show-inheritance:
diff --git a/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.rst b/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.rst
index 29c0090..1f51000 100644
--- a/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.rst
+++ b/source/smartnoise/api-reference/opendp.smartnoise.synthesizers.rst
@@ -1,12 +1,3 @@
 opendp\.smartnoise\.synthesizers package
 =================================================
 
-.. autoclass:: opendp.smartnoise.synthesizers.QUAILSynthesizer
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-.. autoclass:: opendp.smartnoise.synthesizers.MWEMSynthesizer
-    :members:
-    :undoc-members:
-    :show-inheritance:

I tried pinning versions like this:

Here are the versions installed:

Successfully installed Jinja2-3.0.1 MarkupSafe-2.0.1 Pygments-2.9.0 alabaster-0.7.12 antlr4-python3-runtime-4.8 babel-2.9.1 beautifulsoup4-4.9.3 certifi-2021.5.30 chardet-4.0.0 docutils-0.16 greenlet-1.1.0 idna-2.10 imagesize-1.2.0 isodate-0.6.0 msrest-0.6.21 numpy-1.20.3 oauthlib-3.1.1 opendp-smartnoise-0.1.3.1 opendp-smartnoise-core-0.2.2 packaging-20.9 pandas-1.2.4 pandasql-0.7.3 patsy-0.5.1 protobuf-3.17.3 pydata-sphinx-theme-0.6.3 pyparsing-2.4.7 python-dateutil-2.8.1 pytz-2021.1 pyyaml-5.4.1 requests-2.25.1 requests-oauthlib-1.3.0 scipy-1.6.3 six-1.16.0 snowballstemmer-2.1.0 soupsieve-2.2.1 sphinx-3.5.2 sphinx-multiversion-0.2.4 sphinxcontrib-applehelp-1.0.2 sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.3 sphinxcontrib-serializinghtml-1.1.5 sqlalchemy-1.4.17 statsmodels-0.12.2 urllib3-1.26.5

The error seems to be the same:

(venv) HMDC-beamish:opendp-documentation pdurbin$ make html
sphinx-build -W -D 'html_sidebars.**'=search-field.html,sidebar-nav-bs.html source build/html
Running Sphinx v3.5.2
*****************************************
/Users/pdurbin/github/opendp/opendp-documentation/source/..
/Users/pdurbin/github/opendp
/Users/pdurbin/github/opendp/opendp-documentation/venv/bin
/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9
/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload
/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages
*****************************************
ModuleSpec(name='opendp.smartnoise', loader=<_frozen_importlib_external.SourceFileLoader object at 0x10fd8ad60>, origin='/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/opendp/smartnoise/__init__.py', submodule_search_locations=['/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/opendp/smartnoise'])
*****************************************
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 28 source files that are out of date
updating environment: [new config] 28 added, 0 changed, 0 removed
reading sources... [ 50%] smartnoise/api-reference/opendp.smartnoise.core.componreading sources... [ 64%] smartnoise/api-reference/opendp.smartnoise.synthesizerreading sources... [ 67%] smartnoise/api-reference/opendp.smartnoise.synthesizerreading sources... [100%] user/related-projects                                 

Warning, treated as error:
autodoc: failed to import class 'QUAILSynthesizer' from module 'opendp.smartnoise.synthesizers'; the following exception was raised:
Traceback (most recent call last):
  File "/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/util/inspect.py", line 393, in safe_getattr
    return getattr(obj, name, *defargs)
AttributeError: module 'opendp.smartnoise.synthesizers' has no attribute 'QUAILSynthesizer'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/ext/autodoc/importer.py", line 111, in import_object
    obj = attrgetter(obj, mangled_name)
  File "/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 320, in get_attr
    return autodoc_attrgetter(self.env.app, obj, name, *defargs)
  File "/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 2604, in autodoc_attrgetter
    return safe_getattr(obj, name, *defargs)
  File "/Users/pdurbin/github/opendp/opendp-documentation/venv/lib/python3.9/site-packages/sphinx/util/inspect.py", line 409, in safe_getattr
    raise AttributeError(name) from exc
AttributeError: QUAILSynthesizer

make: *** [html] Error 2
(venv) HMDC-beamish:opendp-documentation pdurbin$ 

I just merged pull request #33 as a test to kick off a build and it succeeded (somewhat to my surprise). What I learned (or remembered) is that while make html (which developers use) is strict and make versions (used by GitHub Actions) is lax.

It turns out that the following pages are missing content...

... but because make versions (again, used by GitHub Actions) doesn't treat warnings as errors, the build doesn't fail properly.

If you look at build from the the pull request above, for example ( https://github.com/opendp/opendp-documentation/actions/runs/925719739 ) you'll see many similar warnings:

  • WARNING: autodoc: failed to import class 'MWEMSynthesizer' from module 'opendp.smartnoise.synthesizers'; the following exception was raised:
  • WARNING: autodoc: failed to import class 'nn.PATECTGAN' from module 'opendp.smartnoise.synthesizers.pytorch'; the following exception was raised:
  • WARNING: autodoc: failed to import class 'nn.DPCTGAN' from module 'opendp.smartnoise.synthesizers.pytorch'; the following exception was raised:
  • etc.

To get make versions to be more strict, we should add $(SPHINXOPTS) to the Makefile like this (to pick up the -W flag):

$(SPHINXMULTI) $(SPHINXOPTS) source $(BUILDDIR)/html/en

I'm not sure how to fix the underlying error in smartnoise packages, which we should probably fix first. I'm in touch with @lurosenb about it.

* WARNING: autodoc: failed to import class

The first build where these warnings appear is https://github.com/opendp/opendp-documentation/actions/runs/894340068 when pull request #25 was merged.

I tried this:

diff --git a/requirements.txt b/requirements.txt
index 3853c42..327d2f5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,4 +2,4 @@ sphinx==3.5.2
 sphinx-multiversion
 pydata-sphinx-theme
 opendp-smartnoise-core
-opendp-smartnoise
+git+https://github.com/opendp/smartnoise-sdk#subdirectory=sdk

But I still got errors:

Warning, treated as error:
autodoc: failed to import class 'nn.PATECTGAN' from module 'opendp.smartnoise.synthesizers.pytorch'; the following exception was raised:
No module named 'torch'
make: *** [html] Error 2

I'm thinking we should remove the problematic pages for now.

To resolve this error, I removed the pages that don't build. That was pull request #34. I also gave a heads up on pull request #25 that I had to remove a good deal of that pull request.

So that we catch errors like this (pages missing content, etc.) earlier I changed the builds from GitHub Actions to fail on warnings. That was pull request #38 and there's a longer writeup at #36 including some thoughts on how we want to deal with pull requests both in terms of previewing them (#24) but also knowing if they break the build or not (new issue)?

I'm closing this. Obviously we should add back in the problematic pages at some point.