sphinx-autoapi icon indicating copy to clipboard operation
sphinx-autoapi copied to clipboard

KeyError: preventing docs building

Open HKaras opened this issue 1 year ago • 5 comments

I am currently using autoapi to generate the documentation for my project . The docs build with no issues on my laptop however on github actions I keep running into the following error:

2024-04-03T08:56:19.2068879Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/sphinx/ext/autosummary/__init__.py", line 233, in run
2024-04-03T08:56:19.2068993Z     items = self.get_items(names)
2024-04-03T08:56:19.2069082Z             ^^^^^^^^^^^^^^^^^^^^^
2024-04-03T08:56:19.2069644Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/autoapi/directives.py", line 22, in get_items
2024-04-03T08:56:19.2069744Z     obj = all_objects[name]
2024-04-03T08:56:19.2069829Z           ~~~~~~~~~~~^^^^^^
2024-04-03T08:56:19.2069979Z KeyError: 'autodeer.DEERanalysis'
2024-04-03T08:56:19.2069987Z 
2024-04-03T08:56:19.2070081Z Exception occurred:
2024-04-03T08:56:19.2070649Z   File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/autoapi/directives.py", line 22, in get_items
2024-04-03T08:56:19.2070746Z     obj = all_objects[name]
2024-04-03T08:56:19.2070831Z           ~~~~~~~~~~~^^^^^^
2024-04-03T08:56:19.2070977Z KeyError: 'autodeer.DEERanalysis'
2024-04-03T08:56:19.2071512Z The full traceback has been saved in /tmp/sphinx-err-ngzm16u5.log, if you want to report the issue to the developers.
2024-04-03T08:56:19.2071903Z Please also report this if it was a user error, so that a better error message can be provided next time.
2024-04-03T08:56:19.2072329Z A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Using python 3.10 or 3.12, autoapi 3.0.0 and sphinx 7.2.6 Is this a known error with a simple fix. Am I doing something wrong?

HKaras avatar Apr 03 '24 10:04 HKaras

I ran into this issue as well with Toil

loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://cwltool.readthedocs.io/en/latest/objects.inv...
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 291 source files that are out of date
updating environment: [new config] 291 added, 0 changed, 0 removed
reading sources... [  2%] autoapi/debugWorkflow/index
Exception occurred:
  File "/home/heaucques/Documents/toil/venv/lib/python3.12/site-packages/autoapi/directives.py", line 22, in get_items
    obj = all_objects[name]
          ~~~~~~~~~~~^^^^^^
KeyError: 'debugWorkflow.initialize_jobs'
The full traceback has been saved in /tmp/sphinx-err-ad1oubiv.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Also using Python 3.12 with sphinx 7.2.6 Full logs here: sphinx-err-ad1oubiv.log

stxue1 avatar Apr 11 '24 17:04 stxue1

I think was able to resolve this. It seems like sphinx-autoapi was using cached docs from a previous run of sphinx with old source code. After removing the autoapi folder with rm -rf docs/autoapi, the docs are able to build successfully.

stxue1 avatar Apr 11 '24 18:04 stxue1

@HKaras Is this still an issue for you? Have you tried clearing the cache like @stxue1 suggested?

AWhetter avatar Jun 20 '24 01:06 AWhetter