Skip to content

Comments

fix: lazy-import heavy deps in CLI so lightweight commands work without extras#571

Merged
Kovbo merged 1 commit intoOpenPipe:mainfrom
Kovbo:fix/lazy-imports-cli
Feb 19, 2026
Merged

fix: lazy-import heavy deps in CLI so lightweight commands work without extras#571
Kovbo merged 1 commit intoOpenPipe:mainfrom
Kovbo:fix/lazy-imports-cli

Conversation

@Kovbo
Copy link
Collaborator

@Kovbo Kovbo commented Feb 19, 2026

Summary

  • CLI commands (art install-skills, art train-sft, art train-rl, art migrate) crash with ModuleNotFoundError when only base dependencies are installed, because cli.py eagerly imports fastapi, uvicorn, torch (via LocalBackend), and numpy (via model.pycalculate_step_metrics) at module load time — even though only the run command needs them.

  • Moved all run-only imports (fastapi, uvicorn, pydantic, LocalBackend, dev, ARTError, Model, TrainableModel, TrajectoryGroup, TrainConfig) from top-level into the run() function body.

  • Made the calculate_step_std_dev import in model.py lazy (moved into the method that calls it), breaking the __init__utilsoutput_dirsmodelnumpy eager import chain.

  • Removed unused imports: Optional, Provider, TogetherDeploymentConfig, WandbDeploymentConfig.

Reproduction

pip install openpipe-art
art install-skills
# ModuleNotFoundError: No module named 'numpy'
# (after installing numpy) ModuleNotFoundError: No module named 'fastapi'
# (after installing fastapi) ModuleNotFoundError: No module named 'torch'

Test plan

  • pip install openpipe-art && art install-skills works with base deps only
  • art run still works when backend extras are installed
  • ruff check passes (verified locally)

🤖 Generated with Claude Code

…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>
@Kovbo Kovbo requested a review from bradhilton February 19, 2026 04:23
@Kovbo Kovbo merged commit ca47d07 into OpenPipe:main Feb 19, 2026
1 check passed
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