Skip to content

Commit 46d408d

Browse files
abrichrclaude
andcommitted
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>
1 parent 344fb1a commit 46d408d

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

openadapt/cli.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ def train_start(
216216
except ImportError:
217217
# Older openadapt-ml without resolve_config_path; use as-is.
218218
pass
219+
220+
from pathlib import Path
221+
222+
if not Path(config).exists():
223+
click.echo(f"Error: config not found: {config}", err=True)
224+
click.echo(
225+
"Upgrade openadapt-ml so bundled configs resolve, or pass "
226+
"--config with a path to a training config YAML.",
227+
err=True,
228+
)
229+
sys.exit(1)
219230
click.echo(f" Config: {config}")
220231

221232
train_main(
@@ -423,8 +434,14 @@ def serve(port: int, output: str, open: bool):
423434
click.echo(f"Serving from: {output}")
424435

425436
import argparse
437+
from pathlib import Path
438+
439+
from openadapt_ml.cloud import local as oa_local
426440

427-
from openadapt_ml.cloud.local import cmd_serve
441+
# cmd_serve resolves the 'current' run against the module-level
442+
# TRAINING_OUTPUT constant; point it at the requested directory
443+
# so --output is honored.
444+
oa_local.TRAINING_OUTPUT = Path(output)
428445

429446
if open:
430447
import threading
@@ -434,10 +451,8 @@ def serve(port: int, output: str, open: bool):
434451
1.0, webbrowser.open, args=(f"http://localhost:{port}",)
435452
).start()
436453

437-
# cmd_serve serves the 'current' training run from the working
438-
# directory's training_output; it takes an argparse Namespace.
439454
sys.exit(
440-
cmd_serve(
455+
oa_local.cmd_serve(
441456
argparse.Namespace(
442457
port=port,
443458
benchmark=None,

0 commit comments

Comments
 (0)