Class: LLMExperiment::CLI::CleanCommand
- Inherits:
-
Command
- Object
- Command
- LLMExperiment::CLI::CleanCommand
show all
- Defined in:
- lib/llm_experiment/cli/clean_command.rb
Constant Summary
collapse
- NAME =
"clean"
- SUMMARY =
"reclaim disk: app images and the BuildKit cache, verified by observation"
Instance Method Summary
collapse
Methods inherited from Command
#call, #initialize, summary
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
28
|
# File 'lib/llm_experiment/cli/clean_command.rb', line 9
def add_options(parser)
parser.banner = <<~BANNER
Usage: llmx clean [--images] [--builder] [--base] [--dry-run]
With no flags this reports and deletes nothing.
The report measures the unpacked snapshot on disk, because that is what
an image costs: `container image inspect` sums layers and reports about
a third of it.
`--builder` verifies afterwards with `container ls -a` and prints the
kill-the-VM recovery if the builder is still there, because `container
builder stop` can exit 0 and do nothing.
BANNER
parser.on("--images", "delete every llmx-app-* image") { @images = true }
parser.on("--base", "also delete llmx-base (implies --images; 20-40 min to rebuild)") { @base = true }
parser.on("--builder", "stop the BuildKit builder and delete its cache") { @builder = true }
parser.on("--dry-run", "print what would go, delete nothing") { @dry_run = true }
end
|
#run(_argv) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/llm_experiment/cli/clean_command.rb', line 30
def run(_argv)
cleaner = Cleaner.new(container: container)
images = @images || @base
return cleaner.report unless images || @builder
cleaner.clean_images(dry_run: !@dry_run.nil?, base: !@base.nil?) if images
cleaner.clean_builder(dry_run: !!@dry_run) if @builder
end
|