Make the registry self-tests report the backends they promise - #4
Open
egeboy35 wants to merge 1 commit into
Open
Make the registry self-tests report the backends they promise#4egeboy35 wants to merge 1 commit into
egeboy35 wants to merge 1 commit into
Conversation
egeboy35
force-pushed
the
fix/registry-self-tests-report-empty
branch
from
September 1, 2026 12:28
e11ede8 to
36cf103
Compare
Both files carry a header advertising a command:
# python -m DeepDataMiningLearning.ngdet.detectors.base
# Expected: prints the registered detector backends (after importing adapters).
Run it and the answer is an empty list. Same for
ngperception/depth/estimators/base.py.
Under `python -m pkg.mod` the file executes as `__main__`; the
`from . import <adapters>` inside the block then imports the adapters,
which do `from .base import register, ...` -- loading this module a second
time under its real name. `@register` populates that copy's registry, and
`__main__` prints its own, still empty. CPython says as much:
RuntimeWarning: 'DeepDataMiningLearning.ngdet.detectors.base' found in
sys.modules after import of package 'DeepDataMiningLearning.ngdet.detectors',
but prior to execution of '...base'; this may result in unpredictable behaviour
Nothing outside the self-test is affected -- a normal `import` sees one
module object and the registry fills correctly (verified: importing
hf_detr takes DETECTOR_REGISTRY from [] to ['hf_detr']). The report is
what is wrong, not the registry.
The blocks now read the canonical module rather than their own globals:
ngdet.detectors.base [] -> ['hf_detr', 'yolo', 'locate_anything']
depth.estimators.base [] -> ['hf_depth']
Only the `if __name__ == "__main__":` block changes in each file. I checked
that the `Registered: {list(...)}` text inside build_detector /
build_estimator is untouched -- an earlier attempt of mine rewrote that
line by accident, which would have turned a helpful KeyError into a
NameError. Both still raise KeyError naming the registered backends.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
egeboy35
force-pushed
the
fix/registry-self-tests-report-empty
branch
from
September 1, 2026 12:43
36cf103 to
ee5d38d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both registry modules carry a header advertising a command to check the install:
Run it and you get an empty list. Same for
ngperception/depth/estimators/base.py.Why
Under
python -m pkg.modthe file executes as__main__. Thefrom . import <adapters>inside the block then imports the adapters, which dofrom .base import register, ...— loading this module a second time under its real name.@registerpopulates that copy's registry;__main__prints its own, still empty. CPython says as much:The registry itself is fine — this is a reporting bug, not a functional one. A normal import sees one module object and registration works: importing
hf_detrtakesDETECTOR_REGISTRYfrom[]to['hf_detr']. Only the self-test lies.The change
Each
if __name__ == "__main__":block now reads the canonical module instead of its own globals:Nothing outside those two blocks changes.
One thing I checked because I got it wrong first
My first attempt rewrote the
Registered: {list(...)}text insidebuild_detector/build_estimatorby accident, which would have turned a helpfulKeyErrorinto aNameErrorfor anyone asking for an unknown backend. The diff here touches only the__main__blocks, and I verified both builders still raiseKeyErrornaming the registered backends:🤖 Generated with Claude Code