fix: add InferenceResult, ModelOutput, ModelRepository, FileUploadResult to __all__#199
fix: add InferenceResult, ModelOutput, ModelRepository, FileUploadResult to __all__#199amathxbt wants to merge 2 commits intoOpenGradient:mainfrom
Conversation
…ult to __all__ These four types are imported at the top of __init__.py and are part of the public API surface, but were missing from __all__. This means 'from opengradient import *' silently omits them, breaking any user code that relies on wildcard imports. It also misleads static analysis tools and IDE auto-completion into thinking these types are not publicly exported.
| @@ -1,141 +1 @@ | |||
| """ | |||
There was a problem hiding this comment.
what is the reason for removing this?
There was a problem hiding this comment.
Hey @adambalogh great catch, and I owe you a clear explanation because this diff looks alarming at first glance. Let me break down exactly what happened and what the correct state should be.
What this PR was supposed to do
The original intent was a minimal, additive fix: add four types to __all__ in src/opengradient/__init__.py that are already imported at the top level but were silently omitted from the public export list.
The original bug on main:
# src/opengradient/__init__.py (main branch, lines 97-113)
__all__ = [
"LLM",
"Alpha",
"ModelHub",
"Twins",
"TEE_LLM",
"InferenceMode",
"HistoricalInputQuery",
"SchedulerParams",
"CandleType",
"CandleOrder",
"TextGenerationOutput",
"TextGenerationStream",
"x402SettlementMode",
"agents",
"alphasense",
# ← InferenceResult, ModelOutput, ModelRepository, FileUploadResult MISSING
]All four types are imported at the top of the file (lines 84–95 on main) and are already present in __pdoc__ (lines 133–136), but they were never wired into __all__. That means:
| Scenario | Behaviour |
|---|---|
import opengradient as og; og.InferenceResult |
✅ Works (direct attribute access) |
from opengradient import InferenceResult |
✅ Works (explicit name import) |
from opengradient import * |
❌ Silently missing — wildcard consumers never see these types |
IDE auto-complete on import * |
❌ Types not surfaced |
opengradient.__all__ |
❌ Contract is incomplete |
The intended diff was literally 4 lines added to the __all__ list, nothing more.
What went wrong in this PR (the accidental deletion)
The branch fix/init-all-missing-type-exports was cut from an older snapshot of main where __init__.py was 188 lines long. The current main has a different, shorter version of the same file (142 lines) that was restructured in a later commit. When I branched and made my change, the branch diverged from main without a proper rebase.
The end result is that the diff compares:
- Base (main, current): 142-line
__init__.py - Head (this branch): 1-line blank
__init__.py(accidental full overwrite)
This is 100% my fault — the branch was not rebased onto the current main before the PR was opened, so instead of showing "+4 lines to __all__", it shows "-187 lines, +0". No content should have been removed. The full file — module docstring, imports, init(), __all__, __pdoc__ — must stay intact.
What the correct patch looks like
The only change that should land is this:
__all__ = [
"LLM",
"Alpha",
"ModelHub",
"Twins",
"TEE_LLM",
"InferenceMode",
"HistoricalInputQuery",
"SchedulerParams",
"CandleType",
"CandleOrder",
"TextGenerationOutput",
"TextGenerationStream",
"x402SettlementMode",
"agents",
"alphasense",
+ "InferenceResult",
+ "ModelOutput",
+ "ModelRepository",
+ "FileUploadResult",
]That's it. Four string additions. Everything else in the file stays exactly as it is on main.
Next steps
I'll force-push a rebased version of this branch onto the current main immediately so the diff reflects only the intended 4-line addition. Sorry for the noise this was a branching mistake, not an intentional restructure.
Thanks for catching it before it could have caused damage!
…eUploadResult to __all__ Previous commit accidentally wiped the entire file (branch was cut from an older 188-line snapshot; current main is 142 lines). This commit restores the file to its current main-branch state and applies only the intended 4-line change: adding the missing type names to __all__. All 4 types are already imported at the top of the file and present in __pdoc__; they were simply omitted from __all__, making them invisible to wildcard imports ().
Bug
Four types are imported at the top level of
src/opengradient/__init__.pybut are missing from__all__:InferenceResultModelOutputModelRepositoryFileUploadResultImpact
from opengradient import *__all__-based docshasattr(og, "InferenceResult")True(they ARE importable) — inconsistent with__all__Note: Direct imports still work (
from opengradient import InferenceResult) — this is a__all__correctness fix.Fix
Add the four missing types to
__all__: