fix: lazy-import heavy deps in CLI so lightweight commands work without extras#571
Merged
Kovbo merged 1 commit intoOpenPipe:mainfrom Feb 19, 2026
Merged
Conversation
…ckend extras `art install-skills`, `art train-sft`, `art train-rl`, and `art migrate` all crash with ModuleNotFoundError when backend extras (torch, fastapi, uvicorn, numpy) are not installed, even though they don't need them. - Move fastapi, uvicorn, pydantic, LocalBackend, and other backend-only imports from top-level cli.py into the `run` command where they're actually used - Remove unused imports (Optional, Provider, TogetherDeploymentConfig, WandbDeploymentConfig) - Lazy-import calculate_step_std_dev in model.py to break the __init__ -> utils -> model -> numpy eager import chain Co-Authored-By: Claude Opus 4.6 <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.
Summary
CLI commands (
art install-skills,art train-sft,art train-rl,art migrate) crash withModuleNotFoundErrorwhen only base dependencies are installed, becausecli.pyeagerly importsfastapi,uvicorn,torch(viaLocalBackend), andnumpy(viamodel.py→calculate_step_metrics) at module load time — even though only theruncommand needs them.Moved all
run-only imports (fastapi,uvicorn,pydantic,LocalBackend,dev,ARTError,Model,TrainableModel,TrajectoryGroup,TrainConfig) from top-level into therun()function body.Made the
calculate_step_std_devimport inmodel.pylazy (moved into the method that calls it), breaking the__init__→utils→output_dirs→model→numpyeager import chain.Removed unused imports:
Optional,Provider,TogetherDeploymentConfig,WandbDeploymentConfig.Reproduction
Test plan
pip install openpipe-art && art install-skillsworks with base deps onlyart runstill works when backend extras are installedruff checkpasses (verified locally)🤖 Generated with Claude Code