Class: LLMExperiment::CLI::RunCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/llm_experiment/cli/run_command.rb

Constant Summary collapse

NAME =
"run"
SUMMARY =
"run one trial, or the whole grid with --all"

Instance Method Summary collapse

Methods inherited from Command

#call, #initialize, summary

Constructor Details

This class inherits a constructor from LLMExperiment::CLI::Command

Instance Method Details

#add_options(parser) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/llm_experiment/cli/run_command.rb', line 9

def add_options(parser)
  parser.banner = <<~BANNER
    Usage: llmx run --task ID --agent NAME --condition NAME [options]
           llmx run --all [--app KEY] [--task ID] [--agent NAME] [options]

    One trial is one task, one agent, one condition, in a fresh container.
    --all runs the grid: sequentially, blocked by task, and resumable —
    a cell that already has results is skipped unless --redo is given.

  BANNER
  parser.on("--task ID", "task id from experiment.yml (a filter under --all)") { |v| @task = v }
  parser.on("--agent NAME", "agent to run (a filter under --all)") { |v| @agent = v }
  parser.on("--condition NAME", "condition to run") { |v| @condition = v }
  parser.on("--all", "run every remaining cell of the grid") { @all = true }
  parser.on("--app KEY", "with --all: only this app's tasks") { |v| @app = v }
  parser.on("--redo", "with --all: re-run cells that already have results") { @redo = true }
  parser.on("--timeout S", Integer, "wall-clock seconds for the agent") { |v| @timeout = v }
  parser.on("--dry-run", "show what would run, run nothing") { @dry_run = true }
end

#run(_argv) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/llm_experiment/cli/run_command.rb', line 29

def run(_argv)
  return run_grid if @all

  unless @task && @agent && @condition
    raise Error, "llmx run needs --task, --agent and --condition (or --all for the grid)"
  end

  Trial.new(experiment: experiment, task_id: @task, agent: @agent, condition: @condition,
            container: container, timeout: @timeout).run(dry_run: !!@dry_run)
end