Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

feat(autopilot): prompt interactively for missing model, data, or goal (#1576) (#1577)

Salil M2360e7b83632
diff --git a/changelog.d/0.75.1/1577.added.md b/changelog.d/0.75.1/1577.added.md
new file mode 100644
index 00000000..607c129f
--- /dev/null
+++ b/changelog.d/0.75.1/1577.added.md
@@ -0,0 +1 @@
+- `soup autopilot` asks for a missing `--model`, `--data` or `--goal` when run in a terminal, and fails as before when it is not (#1577).
diff --git a/docs/commands.md b/docs/commands.md
index fd8ecbfb..0b0ae509 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -9,7 +9,7 @@
```
soup init [--template chat|code|...|audio] Create config
soup init --template hipaa|soc2|eu-ai-act|sr-11-7 Compliance-shaped starting config + the commands for that regime (v0.71.35)
-soup autopilot --model <id> --data d.jsonl --goal <g> Zero-config: pick task/quant/LR/epochs from data + model + goal
+soup autopilot [--model <id>] [--data d.jsonl] [--goal <g>] Zero-config: pick task/quant/LR/epochs (prompts when omitted)
soup advise <data> --goal "..." Pre-flight decision: PROMPT_ENG / RAG / SFT / DPO / GRPO — run BEFORE spending GPU hours
soup advise compare Show prior verdicts from advise history
soup advise explain Rubric + evidence trail of the last verdict
@@ -397,6 +397,20 @@ also covers `soup bench`, which loads through the `soup infer` path).
Values are case-insensitive. Any other value (`gpu`, `auto`, `cuda:0,1`, ...)
is refused with an error instead of being ignored.
+### Interactive Autopilot (`soup autopilot`)
+
+When standard input is an interactive terminal and any of `--model`, `--data`, or `--goal`
+are omitted, `soup autopilot` prompts for the missing values:
+
+- **Model**: Base model Hugging Face repository ID (or local path). Blank entries are refused.
+- **Data**: Local training dataset path (JSONL). Must exist under current working directory.
+- **Goal**: One of `chat`, `reasoning`, `code`, `classification`, `tool-calling`, `alignment`,
+ or `domain-adapt`.
+
+When run with all three options supplied, or when standard input is not a terminal (e.g. CI,
+scripts, or pipelines), `soup autopilot` never prompts: complete flags execute directly,
+and omitted required flags exit with code 2 and the standard `Missing option` error.
+
### Best-of-N recovery and publication
`soup data best-of-n` appends and synchronizes one checkpoint record after each
diff --git a/src/soup_cli/commands/autopilot.py b/src/soup_cli/commands/autopilot.py
index c6c0a220..63591548 100644
--- a/src/soup_cli/commands/autopilot.py
+++ b/src/soup_cli/commands/autopilot.py
@@ -3,11 +3,15 @@
from __future__ import annotations
import os
+import sys
from pathlib import Path
+from typing import Optional
+import click
import typer
from rich.console import Console
from rich.panel import Panel
+from rich.prompt import Prompt
from soup_cli.autopilot.analyzer import (
analyze_dataset,
@@ -61,11 +65,31 @@ def _kernel_display(enabled: bool, note: str | None) -> str:
return str(enabled)
+def _stdin_isatty() -> bool:
+ """True when standard input is an interactive terminal."""
+ return sys.stdin.isatty()
+
+
+def _param_by_name(ctx: typer.Context, name: str) -> click.Parameter | None:
+ """Find a Click Parameter on the command by its argument name."""
+ for param in ctx.command.params:
+ if param.name == name:
+ return param
+ return None
+
+
def autopilot_cmd(
- model: str = typer.Option(..., "--model", "-m", help="Base model (HF model id)"),
- data: str = typer.Option(..., "--data", "-d", help="Dataset path (JSONL)"),
- goal: str = typer.Option(
- ..., "--goal", "-g",
+ ctx: typer.Context,
+ model: Optional[str] = typer.Option(
+ None, "--model", "-m", help="Base model (HF model id)",
+ ),
+ data: Optional[str] = typer.Option(
+ None, "--data", "-d", help="Dataset path (JSONL)",
+ ),
+ goal: Optional[str] = typer.Option(
+ None,
+ "--goal",
+ "-g",
help=(
"Goal: chat | reasoning | code | classification | tool-calling | "
"alignment | domain-adapt"
@@ -85,6 +109,35 @@ def autopilot_cmd(
),
) -> None:
"""Autopilot: give model+data+goal, Soup picks optimal hyperparameters."""
+ if not _stdin_isatty():
+ if model is None:
+ raise click.MissingParameter(ctx=ctx, param=_param_by_name(ctx, "model"))
+ if data is None:
+ raise click.MissingParameter(ctx=ctx, param=_param_by_name(ctx, "data"))
+ if goal is None:
+ raise click.MissingParameter(ctx=ctx, param=_param_by_name(ctx, "goal"))
+
+ if model is None:
+ model = Prompt.ask("Base model (HF model id)")
+ if not model or not model.strip():
+ console.print("[red]Base model cannot be empty.[/]")
+ raise typer.Exit(1)
+ model = model.strip()
+
+ if data is None:
+ data = Prompt.ask("Dataset path (JSONL)")
+ if not data or not data.strip():
+ console.print("[red]Dataset path cannot be empty.[/]")
+ raise typer.Exit(1)
+ data = data.strip()
+
+ if goal is None:
+ goal = Prompt.ask(
+ "Goal",
+ choices=sorted(GOAL_TO_TASK.keys()),
+ default="chat",
+ )
+
if goal not in GOAL_TO_TASK:
console.print(
f"[red]Unknown goal '{goal}'. "
diff --git a/tests/test_autopilot.py b/tests/test_autopilot.py
index b6c63579..51d54657 100644
--- a/tests/test_autopilot.py
+++ b/tests/test_autopilot.py
@@ -1,6 +1,7 @@
"""Tests for Autopilot — zero-config fine-tuning (Part H of v0.25.0)."""
import json
+import re
import pytest
from typer.testing import CliRunner
@@ -8,6 +9,12 @@ from typer.testing import CliRunner
from soup_cli.cli import app
runner = CliRunner()
+_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")
+
+
+def _plain(text: str) -> str:
+ """ANSI-stripped, whitespace-collapsed CLI output, safe to substring-match."""
+ return " ".join(_ANSI_RE.sub("", text).split())
# ---------------------------------------------------------------------------
@@ -407,6 +414,112 @@ class TestAutopilotCLI:
])
assert result.exit_code != 0
+ def test_non_terminal_missing_model_exits_2(self):
+ result = runner.invoke(app, ["autopilot"])
+ assert result.exit_code == 2
+ assert "Missing option '--model' / '-m'." in _plain(result.output)
+
+ def test_non_terminal_missing_data_exits_2(self):
+ result = runner.invoke(
+ app, ["autopilot", "--model", "meta-llama/Llama-3.1-8B-Instruct"]
+ )
+ assert result.exit_code == 2
+ assert "Missing option '--data' / '-d'." in _plain(result.output)
+
+ def test_non_terminal_missing_goal_exits_2(self, tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ data_file = self._write_data(tmp_path)
+ result = runner.invoke(
+ app,
+ [
+ "autopilot",
+ "--model", "meta-llama/Llama-3.1-8B-Instruct",
+ "--data", str(data_file.name),
+ ],
+ )
+ assert result.exit_code == 2
+ assert "Missing option '--goal' / '-g'." in _plain(result.output)
+
+ def test_interactive_prompts_all_missing(self, tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ data_file = self._write_data(tmp_path)
+ monkeypatch.setattr("soup_cli.commands.autopilot._stdin_isatty", lambda: True)
+ inputs = [
+ "meta-llama/Llama-3.1-8B-Instruct",
+ str(data_file.name),
+ "reasoning",
+ ]
+ result = runner.invoke(
+ app,
+ ["autopilot", "--dry-run", "--gpu-budget", "24GB"],
+ input="\n".join(inputs) + "\n",
+ )
+ assert result.exit_code == 0, (result.output, repr(result.exception))
+ plain_out = _plain(result.output)
+ assert "Soup Autopilot" in plain_out
+ assert "meta-llama/Llama-3.1-8B-Instruct" in plain_out
+ assert "task: grpo" in plain_out
+
+ def test_interactive_prompts_missing_goal_only(self, tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ data_file = self._write_data(tmp_path)
+ monkeypatch.setattr("soup_cli.commands.autopilot._stdin_isatty", lambda: True)
+ result = runner.invoke(
+ app,
+ [
+ "autopilot",
+ "--model", "meta-llama/Llama-3.1-8B-Instruct",
+ "--data", str(data_file.name),
+ "--gpu-budget", "24GB",
+ "--dry-run",
+ ],
+ input="reasoning\n",
+ )
+ assert result.exit_code == 0, (result.output, repr(result.exception))
+ plain_out = _plain(result.output)
+ assert "task: grpo" in plain_out
+
+ def test_interactive_mode_does_not_prompt_when_all_flags_given(
+ self, tmp_path, monkeypatch
+ ):
+ monkeypatch.chdir(tmp_path)
+ data_file = self._write_data(tmp_path)
+ monkeypatch.setattr("soup_cli.commands.autopilot._stdin_isatty", lambda: True)
+
+ def _fail_on_prompt(*args, **kwargs):
+ pytest.fail(f"Prompt.ask called unexpectedly: {args}, {kwargs}")
+
+ monkeypatch.setattr("soup_cli.commands.autopilot.Prompt.ask", _fail_on_prompt)
+
+ result = runner.invoke(
+ app,
+ [
+ "autopilot",
+ "--model", "meta-llama/Llama-3.1-8B-Instruct",
+ "--data", str(data_file.name),
+ "--goal", "chat",
+ "--gpu-budget", "24GB",
+ "--dry-run",
+ ],
+ )
+ assert result.exit_code == 0, (result.output, repr(result.exception))
+
+ def test_interactive_empty_model_exits_1(self, monkeypatch):
+ monkeypatch.setattr("soup_cli.commands.autopilot._stdin_isatty", lambda: True)
+ result = runner.invoke(app, ["autopilot"], input="\n")
+ assert result.exit_code == 1
+ assert "Base model cannot be empty." in _plain(result.output)
+
+ def test_interactive_empty_data_exits_1(self, monkeypatch):
+ monkeypatch.setattr("soup_cli.commands.autopilot._stdin_isatty", lambda: True)
+ result = runner.invoke(
+ app,
+ ["autopilot", "--model", "meta-llama/Llama-3.1-8B-Instruct"],
+ input="\n",
+ )
+ assert result.exit_code == 1
+ assert "Dataset path cannot be empty." in _plain(result.output)
+
# ---------------------------------------------------------------------------
# GPU budget parsing