Skip to content

The gallery check cannot catch an example that imports a package it does not declare #120

Description

@bdbarnett

drum_machine imported audioinstruments while its header said # deps: lvgl, so the gallery loader never installed the package and the demo died on the import. Nothing failed: gallery_generator.py --check was green, unit tests were green, and the card rendered. Fixed in 20a0173 by declaring the dep.

The class of bug is what matters. A missing entry in # deps: is invisible everywhere except in a browser, on the deployed site, when someone opens that one demo.

A guard is cheap, because the generator already parses every example. In --check (and in the normal run), for each discovered example compare the modules it imports against its declared deps, and fail on any import of an installable package that is not declared. Installable means in the MIP index: palettes, pygraphics, pdwidgets, audioinstruments, audioeffects (pydevices and pydevices-desktop are the runtime). Everything else an example imports (lvgl, synthio/audioif, appdev, displaydev, multimer, board_config, board_peripherals) is frozen into the wasm runtime and must NOT be required in the header, which is why a naive import-vs-deps check produces 79 false positives and a useful one produces none.

For a package example, walk every .py in the example's directory, not just the entry point: the import that breaks the demo can sit in a helper module.

Sweep run when this was filed, using the generator's own discover() and that installable set: 0 of 72 examples import an installable package they do not declare. So the guard would start green and only ever fire on a real regression.

Worth pairing with the reverse check as a warning rather than an error: a declared dep the example never imports (piano declares audioif, which is frozen in and needs no install). Harmless today, but it is the same header drifting from the truth.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions