Import data_loader only under TYPE_CHECKING (annotation-only import) - #1020
Open
Xiao-buxiao wants to merge 1 commit into
Open
Import data_loader only under TYPE_CHECKING (annotation-only import)#1020Xiao-buxiao wants to merge 1 commit into
Xiao-buxiao wants to merge 1 commit into
Conversation
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.
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.
Related to #1019.
openpi/training/checkpoints.pyimportsopenpi.training.data_loaderat module top level, but the module already usesfrom __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
openpi.policies.policy+openpi.policies.policy_configpasses 20/20 on a clean environment (no workaround).ruff check/ruff formatpass 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.