Skip to content

fix: add InferenceResult, ModelOutput, ModelRepository, FileUploadResult to __all__#199

Open
amathxbt wants to merge 2 commits intoOpenGradient:mainfrom
amathxbt:fix/init-all-missing-type-exports
Open

fix: add InferenceResult, ModelOutput, ModelRepository, FileUploadResult to __all__#199
amathxbt wants to merge 2 commits intoOpenGradient:mainfrom
amathxbt:fix/init-all-missing-type-exports

Conversation

@amathxbt
Copy link
Copy Markdown
Contributor

Bug

Four types are imported at the top level of src/opengradient/__init__.py but are missing from __all__:

  • InferenceResult
  • ModelOutput
  • ModelRepository
  • FileUploadResult
# They ARE imported (visible via direct import)
from .types import (
    ...
    FileUploadResult,
    InferenceResult,
    ModelOutput,
    ModelRepository,
    ...
)

# But NOT in __all__ (invisible via wildcard import)
__all__ = [
    "LLM", "Alpha", ...
    # InferenceResult, ModelOutput, ModelRepository, FileUploadResult MISSING
]

Impact

Problem Description
from opengradient import * Silently omits these 4 types — wildcard imports break
IDE auto-completion Types not suggested as publicly exported
Type stubs / docs Missing from generated __all__-based docs
hasattr(og, "InferenceResult") Returns 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__:

__all__ = [
    "LLM", "Alpha", "ModelHub", "Twins",
    "TEE_LLM", "InferenceMode",
    "InferenceResult",    # added
    "ModelOutput",        # added
    "ModelRepository",    # added
    "FileUploadResult",   # added
    ...
]

…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.
@amathxbt
Copy link
Copy Markdown
Contributor Author

@adambalogh

@@ -1,141 +1 @@
"""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason for removing this?

Copy link
Copy Markdown
Contributor Author

@amathxbt amathxbt Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants