Skip to content

Build remote registry indices on first use, not at construction - #291

Merged
g5t merged 2 commits into
mainfrom
delay-remote-registry-interaction
Aug 12, 2026
Merged

Build remote registry indices on first use, not at construction#291
g5t merged 2 commits into
mainfrom
delay-remote-registry-interaction

Conversation

@g5t

@g5t g5t commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

GitHubRegistry and ModuleRemoteRegistry acquired their pooch index in init, which reads a cache file or, failing that, fetches one over the network and writes it back. Registries are reconstructed while deserializing an instrument, so constructing one did I/O before anything had asked it for a file.

Build the index on first use instead: pooch becomes a property that constructs on demand, leaving every existing consumer unchanged.

Name, version and filename are interpolated into cache paths and can come from a serialized instrument, so they are now reduced to a single path component; find_registry_file() likewise refuses a name that would resolve outside the package.

RemoteRegistry.eq compared pooch internals, which under lazy construction would build an index just to answer an equality test. It now compares the declared name, url, version and filename. That also fixes a pre-existing bug: the old implementation returned False when other.pooch is None, so a registry whose index had not been built was not equal to itself, and every equality assertion about one was vacuous.

g5t added 2 commits August 12, 2026 15:01
GitHubRegistry and ModuleRemoteRegistry acquired their pooch index in __init__,
which reads a cache file or, failing that, fetches one over the network and
writes it back. Registries are reconstructed while deserializing an instrument,
so constructing one did I/O before anything had asked it for a file.

Build the index on first use instead: `pooch` becomes a property that constructs
on demand, leaving every existing consumer unchanged.

Name, version and filename are interpolated into cache paths and can come from a
serialized instrument, so they are now reduced to a single path component;
find_registry_file() likewise refuses a name that would resolve outside the
package.

RemoteRegistry.__eq__ compared pooch internals, which under lazy construction
would build an index just to answer an equality test. It now compares the
declared name, url, version and filename. That also fixes a pre-existing bug:
the old implementation returned False when `other.pooch is None`, so a registry
whose index had not been built was not equal to itself, and every equality
assertion about one was vacuous.
@g5t
g5t merged commit 1ae9695 into main Aug 12, 2026
32 checks passed
@g5t g5t added the enhancement New feature or request label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant