Class: LLMExperiment::CLI::ShellCommand
- Inherits:
-
Command
- Object
- Command
- LLMExperiment::CLI::ShellCommand
show all
- Defined in:
- lib/llm_experiment/cli/shell_command.rb
Constant Summary
collapse
- NAME =
"shell"
- SUMMARY =
"interactive shell in a trial-shaped container, for debugging"
Instance Method Summary
collapse
Methods inherited from Command
#call, #initialize, summary
Instance Method Details
#add_options(parser) ⇒ Object
9
10
11
12
13
|
# File 'lib/llm_experiment/cli/shell_command.rb', line 9
def add_options(parser)
parser.banner = "Usage: llmx shell [APP] [options]\n" \
" APP open the app's image at /workspace/app; " \
"omit for the base image"
end
|
#run(argv) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/llm_experiment/cli/shell_command.rb', line 15
def run(argv)
app_key = argv.shift
image = app_key ? experiment.app(app_key).image : LLMExperiment.base_image
container.ensure_system!
raise Error, "image #{image} not found; build it first" unless container.image?(image)
exp = app_key ? experiment : nil
argv_out = container.run_argv(
image, "bash",
memory: exp ? exp.memory : LLMExperiment.default_memory,
cpus: exp ? exp.cpus : LLMExperiment.default_cpus,
interactive: true,
workdir: app_key ? "/workspace/app" : nil
)
Shell.interactive(*argv_out)
end
|