Skip to content

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

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

fix: repair broken openadapt-ml imports in serve and train CLI commands#1001
abrichr merged 3 commits into
mainfrom
fix/issue-999-cli-imports

Conversation

@abrichr

@abrichr abrichr commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the OpenAdapt-side bugs from #999 (reported by @ultimus247): openadapt serve and openadapt train start both failed with a misleading "openadapt-ml not installed" error because cli.py imported functions that don't exist in openadapt-ml, and the bare except ImportError blocks swallowed the real cause.

  • serve: serve_dashboardcmd_serve(argparse.Namespace(...)) (the actual API). Browser opening now happens CLI-side since cmd_serve has no open flag.
  • train start: train_mainscripts.train.main(config_path=..., capture_path=..., output_dir=..., open_dashboard=...) (the actual API and parameter names). When --config isn't given, selects the device-appropriate default and resolves it against the configs bundled in the openadapt-ml wheel (via the new resolve_config_path, with graceful fallback for older openadapt-ml).
  • error messages: ImportError handlers now print the underlying exception and suggest pip install "openadapt-ml[training]", addressing the "masked errors" complaint directly.

Companion to OpenAdaptAI/openadapt-ml#63, which fixes the internal-import, CPU-training, and config-packaging bugs on the openadapt-ml side. Full repro from the issue (openadapt serve, openadapt train start --capture ...) requires both PRs.

Verification

  • python -m py_compile openadapt/cli.py
  • AST cross-check against the openadapt-ml#63 branch confirming cmd_serve, detect_device, resolve_config_path, and scripts.train.main all exist with the parameters cli.py now uses

🤖 Generated with Claude Code

abrichr and others added 3 commits June 12, 2026 01:40
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>
- 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>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@abrichr abrichr merged commit 37db8d4 into main Jun 12, 2026
6 checks passed
@abrichr abrichr deleted the fix/issue-999-cli-imports branch June 12, 2026 15:18
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