fix(models): repair __all__ so from model_api.models import * works - #653
Open
Anai-Guo wants to merge 1 commit into
Open
fix(models): repair __all__ so from model_api.models import * works#653Anai-Guo wants to merge 1 commit into
from model_api.models import * works#653Anai-Guo wants to merge 1 commit into
Conversation
model_api.models.__all__ lists four names the module does not define,
so a star-import fails outright:
>>> from model_api.models import *
AttributeError: module 'model_api.models' has no attribute 'Label'
The four fall into two groups.
Label is real - result/__init__.py exports it and it is used across the
package (classification.py, action_classification.py) - it was just
never re-exported here. Added it to the `from .result import (...)`
block.
The other three are stale:
* YOLOv3ONNX / YOLOv4 are mis-cased copies of YoloV3ONNX / YoloV4,
the names yolo.py actually defines and which __all__ already lists
a few lines further down.
* SalientObjectDetectionModel appears nowhere else in the repository -
not in any module, test or doc - so it is a leftover from a class
that no longer exists.
Removed all three from __all__.
Verified against the tree: before the change `from model_api.models
import *` raises AttributeError; after it binds 47 names, every
__all__ entry resolves via hasattr, and __all__ has no duplicates.
ruff (v0.6.2, the pinned pre-commit revision, run from the package
root so it picks up model_api/pyproject.toml) reports the same three
pre-existing errors before and after, and `ruff format --check` is
clean.
+1/-3, single file.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Issue
model_api.models.__all__lists four names the module does not define, so a star-import fails outright:(reproduced on
masterate6252ecwithopenvinoinstalled)The four names, and why they differ
Labelmodels/result/__init__.pylists it in its own__all__, and it is used across the package (classification.py,action_classification.py)from .result import (...)blockYOLOv3ONNXYoloV3ONNX— the nameyolo.pyactually defines (L602) and which__all__already lists at L109__all__YOLOv4YoloV4(yolo.pyL371), already listed at L110__all__SalientObjectDetectionModel__all__So
Labelis a missing export, and the other three are stale entries. Note the two mis-cased YOLO names were pure duplication: the correctly-casedYoloV3ONNX/YoloV4are already exported, so dropping the typos removes nothing from the public surface.Verification
Against the working tree, with
openvinoinstalled:from model_api.models import *AttributeError: … has no attribute 'Label'[n for n in models.__all__ if not hasattr(models, n)]['Label', 'SalientObjectDetectionModel', 'YOLOv3ONNX', 'YOLOv4'][]__all__entries[]YoloV3ONNX/YoloV4still exportedLint: ruff
v0.6.2(the revision pinned in.pre-commit-config.yaml), run frommodel_api/so it picks upmodel_api/pyproject.toml, reports the same 3 pre-existing errors before and after;ruff format --checkreports the file already formatted.+1 / −3, single file.🤖 Generated with Claude Code