Skip to content

Import data_loader only under TYPE_CHECKING (annotation-only import) - #1020

Open
Xiao-buxiao wants to merge 1 commit into
Physical-Intelligence:mainfrom
Xiao-buxiao:patch-1
Open

Import data_loader only under TYPE_CHECKING (annotation-only import)#1020
Xiao-buxiao wants to merge 1 commit into
Physical-Intelligence:mainfrom
Xiao-buxiao:patch-1

Conversation

@Xiao-buxiao

Copy link
Copy Markdown

Related to #1019.

openpi/training/checkpoints.py imports openpi.training.data_loader at module top level, but the module already uses from __future__ import annotations, so the import is never evaluated at runtime — it exists only for two type annotations and unnecessarily pulls TF-related native libraries at import time.

This PR moves it under if TYPE_CHECKING:, a common practice for annotation-only imports.

Verification

  • Import of openpi.policies.policy + openpi.policies.policy_config passes 20/20 on a clean environment (no workaround).
  • ruff check / ruff format pass on the changed file.

Note: the segfault reported in #1019 could not be reliably reproduced later on clean 535/580 environments; this PR is a defensive hygiene improvement rather than a claimed fix.

Related to Physical-Intelligence#1019.

`openpi/training/checkpoints.py` imports `openpi.training.data_loader` at module top level, but the module already uses `from __future__ import annotations`, so the import is never evaluated at runtime — it exists only for two type annotations and unnecessarily pulls TF-related native libraries at import time.

This PR moves it under `if TYPE_CHECKING:`, a common practice for annotation-only imports.

## Verification
- Import of `openpi.policies.policy` + `openpi.policies.policy_config` passes 20/20 on a clean environment (no workaround).
- `ruff check` / `ruff format` pass on the changed file.

Note: the segfault reported in Physical-Intelligence#1019 could not be reliably reproduced later on clean 535/580 environments; this PR is a defensive hygiene improvement rather than a claimed fix.
@Xiao-buxiao
Xiao-buxiao requested a review from kvablack as a code owner August 20, 2026 14:46
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.

1 participant