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

chore: resolve (or suppress) all Sphinx warnings #14349

Merged
merged 11 commits into from
Jan 25, 2024

Conversation

ecormany
Copy link
Contributor

@ecormany ecormany commented Jan 24, 2024

Overview

Every Python docs build was spewing hundreds of Sphinx warnings. This prevented us from treating warnings as errors in CI. It also made it really hard to tell if you introduced some new problem, like a broken link.

This PR brings the current docs to zero reported warnings. Warnings with easily fixable root causes are actually fixed. Warnings resulting from type hints in the API Reference have been suppressed. Is this a kludge? Kinda. But the only other way out — as far as I can tell — is to actually publicly document every single thing in those type hints. I believe we have multiple reasons not to do that. Hopefully each warning suppression pattern that I've added to conf.py matches all and only a category of things we have motivated reasons to not document.

Addresses RTC-198 (except for hardware docs).

Test Plan

  • Check out the sandboxes. Plural, because the CI changes could affect hardware, v1, and v2 docs.
  • Check out the API docs build action for this branch and see how clean the v2 build is!

Changelog

Fix warnings

  • Fix stuff only Sphinx cares about, like linking the same text twice on a page (yes really).
  • Don't link to classes we've decided to not put in the reference, like TrashBin and WasteChute.
  • Don't use fake class names, like ModuleContext to refer to ThermocyclerContext, HeaterShakerContext, etc.
  • Give up on trying to link to pop() (what are the Python docs doing??)

Suppress warnings

Adds a long list of nitpick_ignore_regex options.

CI

  • Switches the v% builds away from allowing warnings. (v1 already had no warnings, hooray.)
  • Deletes the unused lightbulb image and stops copying it around AWS and everywhere every time we build.

Review requests

Is the warning suppression strategy valid? Are there things that should be cleaned up in source instead? Should we publicize and document some of these instead?

Risk assessment

Low. Changes CI slightly but should only fail for actual Sphinx problems that we should catch as soon as they happen.

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9e286e2) 68.11% compared to head (0fb3ba7) 68.11%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #14349   +/-   ##
=======================================
  Coverage   68.11%   68.11%           
=======================================
  Files        2502     2502           
  Lines       71580    71580           
  Branches     9111     9111           
=======================================
+ Hits        48755    48756    +1     
  Misses      20696    20696           
+ Partials     2129     2128    -1     
Flag Coverage Δ
app 65.60% <ø> (ø)
components 48.83% <ø> (+0.04%) ⬆️
g-code-testing 96.48% <ø> (ø)
labware-library 41.10% <ø> (ø)
notify-server 89.13% <ø> (ø)
protocol-designer 35.30% <ø> (ø)
step-generation 86.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...i/src/opentrons/protocol_api/instrument_context.py 89.18% <ø> (ø)
api/src/opentrons/protocol_api/labware.py 90.58% <ø> (ø)
api/src/opentrons/protocol_api/protocol_context.py 91.92% <ø> (ø)

... and 1 file with indirect coverage changes

@ecormany ecormany marked this pull request as ready for review January 24, 2024 21:01
@ecormany ecormany requested a review from a team as a code owner January 24, 2024 21:01
Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

Yay, thank you!

RIP lightbulb.jpg.

Is the warning suppression strategy valid? Are there things that should be cleaned up in source instead? Should we publicize and document some of these instead?

Yeah, this makes sense.

I haven't looked very closely at the list of stuff that we need to ignore because I'm not very API-brained at the moment (sorry). I think it's likely that a lot of them are pointing to things that we should resolve "properly," like you said. But it's definitely a good idea to ignore them for now so we can treat new warnings as errors and stop things from getting worse.

The :py:class:`TrashBin` class doesn't have any callable methods, so you don't have to save the result of ``load_trash_bin()`` to a variable, especially if your protocol only loads a single trash container. Being able to reference the trash bin by name is useful when dealing with multiple trash containers.
The ``TrashBin`` class doesn't have any callable methods, so you don't have to save the result of ``load_trash_bin()`` to a variable, especially if your protocol only loads a single trash container. Being able to reference the trash bin by name is useful when dealing with multiple trash containers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's publicize opentrons.protocol_api.TrashBin and opentrons.protocol_api.WasteChute, I think. Doesn't have to happen in this PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll do it here, since otherwise I'll have to refer back to this PR to figure out which occurrences I want to re-link.

# The goal here is to pass through any warnings for bad targets of MANUALLY
# created links.
nitpick_ignore_regex = [
("py:class", r".*\._.*"), # anything private
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally do want it to be an error if we accidentally mention something private in the docs. It looks like this is only triggering on TrashBin and WasteChute now, which makes sense. Once we publicize those, I hope we can delete this rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I thought this was catching something else too, but it must be addressed by one of the less broad filters.

I did have to add types.DeckSlotName in its place, because just including that in the reference was a can of worms, which is now RTC-386.

If the labware is on a module, a :py:class:`ModuleContext`.
If the labware is on a module, a module context.
Copy link
Contributor

@SyntaxColoring SyntaxColoring Jan 24, 2024

Choose a reason for hiding this comment

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

We don't have to list them all out, but it might be worth linking some example of a module context here and in the other places where we're replacing broken ModuleContext links. Again, doesn't have to happen in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A couple other options here:

  • Link to the top of the Modules section of the reference (which starts with Heater-Shaker because it's first alphabetically). We could even insert some text into new_protocol_api.rst to explain that everything in that section is a "module context".
  • Link to the Module Setup section, which talks about module contexts, although somewhat obliquely.

@ecormany ecormany requested review from sfoster1, SyntaxColoring and a team January 24, 2024 21:38
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for fixing it all!

@ecormany ecormany merged commit b2d1498 into edge Jan 25, 2024
46 checks passed
@ecormany ecormany deleted the destroy-all-sphinx-warnings branch January 25, 2024 19:42
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.

3 participants