Skip to content

fix: repair broken internal imports, CPU training, and config packaging (OpenAdapt#999)#63

Merged
abrichr merged 3 commits into
mainfrom
fix/issue-999-internal-imports
Jun 12, 2026
Merged

fix: repair broken internal imports, CPU training, and config packaging (OpenAdapt#999)#63
abrichr merged 3 commits into
mainfrom
fix/issue-999-internal-imports

Conversation

@abrichr

@abrichr abrichr commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the openadapt-ml side of OpenAdaptAI/OpenAdapt#999 (reported by @ultimus247), where several CLI commands failed with misleading "openadapt-ml not installed" errors caused by broken internal imports.

# (per issue) Bug Fix
2 cmd_serve imports non-existent update_current_symlink_to_latest Implemented in training/trainer.py: scans job dirs, atomically points current at the most recent (same temp-link + rename pattern as setup_job_directory). regenerate_local_dashboard already exists on main.
3 scripts/train.py calls capture_to_episode(capture_path, goal=goal) Renamed kwarg to instruction=goal, matching the actual signature
4 scripts/demo_policy.py imports non-existent generate_synthetic_sessions Switched to generate_synthetic_episodes (returns List[Episode] directly; removed the session flattening)
5 configs/ missing from the pip package; repo-relative paths fail when installed Wheel now bundles configs/ via hatch force-include, and new resolve_config_path() in cloud/local.py falls back to the packaged copies. cmd_train uses it.
7 CPU-only training raises ValueError: Your setup doesn't support bf16/gpu Non-Unsloth SFTConfig now sets use_cpu/bf16/fp16 based on torch.cuda.is_available() (Unsloth branch untouched — Unsloth requires GPU)

Bugs 1 (in OpenAdapt's cli.py), 6 (training extras — largely addressed on main already), and 8 (Qwen/Qwen2.5-VL-2B-Instruct — configs now reference Qwen/Qwen3-VL-2B-Instruct, which exists) are handled separately; a companion PR fixes the OpenAdapt CLI.

Verification

  • python -m py_compile on all changed files
  • Isolated functional test of update_current_symlink_to_latest: empty base → None, picks latest by mtime, creates/repoints the symlink atomically, idempotent re-run, nonexistent base → None
  • pyproject-build --wheel then inspected the wheel: 10 files now present under openadapt_ml/configs/

🤖 Generated with Claude Code

Fixes the openadapt-ml side of OpenAdaptAI/OpenAdapt#999:

- Add missing update_current_symlink_to_latest() to training/trainer.py;
  cmd_serve imported it but it never existed, so `openadapt serve`
  failed with a misleading "openadapt-ml not installed" error (bug 2)
- scripts/train.py: capture_to_episode(goal=) -> instruction=, matching
  the actual signature (bug 3)
- scripts/demo_policy.py: import generate_synthetic_episodes instead of
  the non-existent generate_synthetic_sessions (bug 4)
- Ship configs/ inside the wheel (hatch force-include) and add
  resolve_config_path() so installed packages find bundled configs
  instead of failing on repo-relative paths (bug 5)
- training/trl_trainer.py: pass use_cpu/bf16/fp16 to SFTConfig based on
  CUDA availability so CPU-only training no longer raises ValueError
  (bug 7)

Verified: py_compile on all changed files, isolated functional test of
the symlink helper, and wheel build confirming configs are included.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
abrichr and others added 2 commits June 12, 2026 11:10
- use_cpu now stays False on Apple Silicon (MPS) so the previous
  accelerated path isn't regressed; only true CPU-only setups get
  use_cpu=True
- update_current_symlink_to_latest prefers directories containing
  training_log.json or dashboard.html so a stray top-level
  "checkpoints" directory from the old flat layout can't win

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
These two files fail 'ruff format --check' on main as well; formatting
them here so the test matrix can actually run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@abrichr abrichr merged commit 9b8f3cd into main Jun 12, 2026
4 checks passed
abrichr added a commit to OpenAdaptAI/OpenAdapt that referenced this pull request Jun 12, 2026
…ds (#1001)

* fix: repair broken openadapt-ml imports in serve and train CLI commands

Fixes #999 (bug 1 and the train_start equivalent):

- `openadapt serve` imported non-existent `serve_dashboard` from
  openadapt_ml.cloud.local; the actual entry point is `cmd_serve`,
  which takes an argparse Namespace. Build the Namespace and open the
  browser from the CLI side (cmd_serve has no open option).
- `openadapt train start` imported non-existent `train_main` from
  openadapt_ml.scripts.train and called it with kwargs that don't
  exist; the actual entry point is `main(config_path, capture_path,
  output_dir, open_dashboard, ...)`. Select a device-appropriate
  default config when none is given (resolved against packaged configs
  when available).
- except ImportError blocks now print the underlying error and point
  at pip install "openadapt-ml[training]" instead of masking internal
  import failures as "openadapt-ml not installed" (the misleading
  error that prompted the issue).

Companion to OpenAdaptAI/openadapt-ml#63.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: honor --output in serve, clear error for unresolvable configs

- serve now points openadapt_ml.cloud.local.TRAINING_OUTPUT at the
  requested --output directory instead of silently ignoring the flag
- train start exits with a clear message when the config path can't
  be resolved (older openadapt-ml without bundled configs), instead
  of a FileNotFoundError traceback

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* style: ruff format cli.py

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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