Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

GitHub Actions autodoc skipped large parts of the API due to import-time failures (missing deps, side-effectful modules like main/playground), leading to incomplete docs.

  • Autodoc safety: Allow village.main to import in headless/docs environments by not raising on os.nice permission errors.
  • Side-effect isolation: Guard the playground latency benchmark so it only runs under __main__, keeping autodoc/import harmless.
  • Doc build hygiene: Deduplicate picamera2 in autodoc_mock_imports to avoid redundant mocks.

Example:

if __name__ == "__main__":
    mybpod = BpodWithLatencyTest()
    measure_softcode_latency(mybpod, 200)
Original prompt

I am running sphinxs autodocs to generate the documentation for the API of this repo. I can run it locally with no problem, but the github actions that I am using is not documenting the whole thing. These are some of the errors I am seeing. I want you to identify the problem:

loading translations [en]... done
making output directory... done
[autosummary] generating autosummary for: api_index.rst, faq/faq.md, faq_index.rst, how_to_build/assembly_instructions.md, how_to_build/list_of_parts.md, how_to_build/software_installation.md, how_to_build_index.rst, index.rst, initial_configuration/backup.md, initial_configuration/hardware.md, ..., user_guide/detection.md, user_guide/maintenance.md, user_guide/plots.md, user_guide/settings.md, user_guide/started.md, user_guide/state_machine.md, user_guide/subjects.md, user_guide/test.md, user_guide/use.md, user_guide_index.rst
WARNING: [autosummary] failed to import village.main.
Possible hints:

  • AttributeError: module 'village' has no attribute 'main'
  • ImportError:
  • ModuleNotFoundError: No module named 'numpy'
    WARNING: [autosummary] failed to import village.manager.
    Possible hints:
  • ModuleNotFoundError: No module named 'numpy'
  • ImportError:
  • AttributeError: module 'village' has no attribute 'manager'
    [autosummary] generating autosummary for: /home/runner/work/village/village/docs/source/api_generated/village.calibration.rst, /home/runner/work/village/village/docs/source/api_generated/village.classes.rst, /home/runner/work/village/village/docs/source/api_generated/village.custom_classes.rst, /home/runner/work/village/village/docs/source/api_generated/village.devices.rst, /home/runner/work/village/village/docs/source/api_generated/village.gui.rst, /home/runner/work/village/village/docs/source/api_generated/village.plots.rst, /home/runner/work/village/village/docs/source/api_generated/village.screen.rst, /home/runner/work/village/village/docs/source/api_generated/village.scripts.rst
    WARNING: [autosummary] failed to import village.calibration.sound_calibration.
    Possible hints:
  • ModuleNotFoundError: No module named 'numpy'
  • ImportError:
  • AttributeError: module 'village.calibration' has no attribute 'sound_calibration'
    WARNING: [autosummary] failed to import village.calibration.water_calibration.
    Possible hints:
  • ModuleNotFoundError: No module named 'numpy'
  • ImportError:
  • AttributeError: module 'village.calibration' has no attribute 'water_calibration'
    WARNING: [autosummary] failed to import village.classes.collection.
    Possible hints:
  • ModuleNotFoundError: No module named 'numpy'
  • ImportError:
  • AttributeError: module 'village.classes' has no attribute 'collection'
    WARNING: [autosummary] failed to import village.classes.subject.
    Possible hints:
  • AttributeError: module 'village.classes' has no attribute 'subject'
  • ImportError:
  • ModuleNotFoundError: No module named 'pandas'
    WARNING: [autosummary] failed to import village.custom_classes.after_session_base.
    Possible hints:
  • AttributeError: module 'village.custom_classes' has no attribute 'after_session_base'
  • ImportError:
  • ModuleNotFoundError: No module named 'fire'
    WARNING: [autosummary] failed to import village.custom_classes.change_cycle_base.
    Possible hints:
  • ModuleNotFoundError: No module named 'fire'
  • ImportError:
  • AttributeError: module 'village.custom_classes' has no attribute 'change_cycle_base'
    WARNING: [autosummary] failed to import village.custom_classes.online_plot_base.
    Possible hints:
  • ImportError:
  • AttributeError: module 'village.custom_classes' has no attribute 'online_plot_base'
  • ModuleNotFoundError: No module named 'matplotlib'
    WARNING: [autosummary] failed to import village.custom_classes.session_plot_base.
    Possible hints:
  • ModuleNotFoundError: No module named 'matplotlib'
  • ImportError:
  • AttributeError: module 'village.custom_classes' has no attribute 'session_plot_base'
    WARNING: [autosummary] failed to import village.custom_classes.subject_plot_base.
    Possible hints:
  • ImportError:
  • AttributeError: module 'village.custom_classes' has no attribute 'subject_plot_base'
  • ModuleNotFoundError: No module named 'matplotlib'
    WARNING: [autosummary] failed to import village.custom_classes.task.
    Possible hints:
  • ModuleNotFoundError: No module named 'numpy'
  • AttributeError: module 'village.custom_classes' has no attribute 'task'
  • ImportError:
    WARNING: [autosummary] failed to import village.custom_classes.training_protocol_base.
    Possible hints:
  • ImportError:
  • AttributeError: module 'village.custom_classes' has no attribute 'training_protocol_base'
  • ModuleNotFoundError: No module named 'pandas'
    WARNING: [autosummary] failed to import village.devices.bpod.
    Possible hints:
  • ModuleNotFoundError: No module named 'numpy'
  • ImportError:
  • AttributeError: module 'village.devices' has no attribute 'bpod'
    WARNING: [autosummary] failed to import village.devices.camera.
    Possible hints:
  • ImportError:
  • AttributeError: module 'village.devices' has no attribute 'camera'
  • ModuleNo...

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

pre-commit-ci bot and others added 3 commits January 8, 2026 14:47
Co-authored-by: HernandoMV <6049065+HernandoMV@users.noreply.github.com>
Co-authored-by: HernandoMV <6049065+HernandoMV@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix errors in Sphinx autodocs for API documentation Harden Sphinx autodoc imports to include full API Jan 8, 2026
Copilot AI requested a review from HernandoMV January 8, 2026 15:03
@HernandoMV HernandoMV marked this pull request as ready for review January 8, 2026 15:14
Copilot AI review requested due to automatic review settings January 8, 2026 15:14
@HernandoMV HernandoMV merged commit 79aa746 into main Jan 8, 2026
6 of 8 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Sphinx autodoc import failures in GitHub Actions by making several key improvements to allow safe module imports during documentation builds.

Key changes:

  • Modified village/main.py to allow imports when os.nice() fails due to permission errors in restricted environments
  • Added __main__ guard in village/scripts/playground.py to prevent benchmark execution during imports
  • Fixed docs/source/conf.py by removing duplicate picamera2 entry and eliminating a duplicate autodoc_mock_imports assignment that was overwriting the comprehensive mock imports list

Reviewed changes

Copilot reviewed 41 out of 42 changed files in this pull request and generated no comments.

Show a summary per file
File Description
village/main.py Removed raise from PermissionError handler to allow imports in restricted environments
village/scripts/playground.py Added __main__ guard to prevent side-effectful benchmark execution during imports
docs/source/conf.py Deduplicated picamera2 mock import and removed duplicate autodoc_mock_imports assignment
village/gui/layout.py Consolidated State import with DataTable import and added blank lines after class definitions
village/gui/data_layout.py Consolidated State import with DataTable import
village/classes/scale.py Fixed indentation from 5 spaces to 4 spaces
village/classes/settings_class.py Fixed indentation from 5 spaces to 4 spaces
village/screen/video_worker.py Fixed docstring formatting by replacing trailing spaces with newlines
Multiple files Removed trailing newlines and added blank lines after class definitions for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants