From 356fb08b0378b6f98de38ef3cd2020f316f2455c Mon Sep 17 00:00:00 2001 From: Dan Saunders Date: Thu, 11 Dec 2025 12:03:05 -0500 Subject: [PATCH] add dry run --- cli.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cli.py b/cli.py index 14e5e8eb59..0772a4942e 100644 --- a/cli.py +++ b/cli.py @@ -8,6 +8,9 @@ import typer from cli.config import Config, load_config +# CLI args that should not be passed to cfg.apply_overrides() +_EXCLUDED_CLI_ARGS = ("config", "dry_run", "verbose", "hf_token", "cfg") + app = typer.Typer( help="Command-line interface for Unsloth training, chat, and export.", context_settings={"help_option_names": ["-h", "--help"]}, @@ -134,6 +137,11 @@ def train( "-c", help="Path to YAML/JSON config file. CLI flags override config values.", ), + dry_run: bool = typer.Option( + False, + "--dry-run", + help="Show resolved config and exit without training.", + ), verbose: bool = typer.Option(False, "--verbose/--quiet"), ): """ @@ -146,9 +154,17 @@ def train( raise typer.Exit(code=2) # Apply CLI overrides - cli_args = {k: v for k, v in locals().items() if k not in ("config", "verbose", "hf_token", "cfg")} + cli_args = {k: v for k, v in locals().items() if k not in _EXCLUDED_CLI_ARGS} cfg.apply_overrides(**cli_args) + # Dry run: show resolved config and exit + if dry_run: + import yaml + data = cfg.model_dump() + data["training"]["output_dir"] = str(data["training"]["output_dir"]) + typer.echo(yaml.dump(data, default_flow_style=False, sort_keys=False)) + raise typer.Exit(code=0) + # Validate required fields if not cfg.model: typer.echo("Error: provide --model or set model in --config", err=True)