Skip to content

Commit 555973d

Browse files
committed
Do not run with --tty when not in interactive mode
I have found that when running with nvidia the -t (--tty) option in podman is covering up certain errors. When we are not running ramalama interactively, we do not need this flag set, and this would make it easier to diagnose what is going on with users systems. Don't add -i unless necessary Server should not need to be run with --interactive or --tty. Signed-off-by: Daniel J Walsh <[email protected]>
1 parent 7550fd3 commit 555973d

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

ramalama/engine.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ def add_env_option(self):
9999
self.exec_args += ["--env", env]
100100

101101
def add_tty_option(self):
102-
if sys.stdout.isatty() or sys.stdin.isatty():
103-
self.exec_args += ["-t"]
102+
if self.args.subcommand != "run" or (hasattr(self.args, "ARGS") and self.args.ARGS) or not sys.stdin.isatty():
103+
return
104+
self.exec_args += ["-t"]
104105

105106
def add_detach_option(self):
106107
if hasattr(self.args, "detach") and self.args.detach is True:

ramalama/model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,11 @@ def base(self, args, name):
209209
args.image = args.image.split(":")[0]
210210
args.image = accel_image(CONFIG, args)
211211
self.engine = Engine(args)
212+
if args.subcommand == "run" and not (hasattr(args, "ARGS") and args.ARGS) and sys.stdin.isatty():
213+
self.engine.add(["-i"])
214+
212215
self.engine.add(
213216
[
214-
"-i",
215217
"--label",
216218
"ai.ramalama",
217219
"--name",

test/system/030-run.bats

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ EOF
2323
is "$output" ".*${MODEL}" "verify model name"
2424
is "$output" ".*-c 2048" "verify model name"
2525
assert "$output" !~ ".*--seed" "assert seed does not show by default"
26+
if is_tty; then
27+
is "$output" ".*-t -i " "run with terminal and interactive"
28+
else
29+
assert "$output" !~ ".*-t -i" "assert -t -i not present without tty"
30+
fi
31+
run_ramalama -q --dryrun run ${MODEL} "what's up doc?"
32+
is "$output" "${verify_begin}.*"
33+
assert "$output" !~ ".*-t -i" "run without terminal"
34+
35+
run_ramalama -q --dryrun run ${MODEL} <<< "Test"
36+
is "$output" "${verify_begin}.*"
37+
assert "$output" !~ ".*-t -i" "run without terminal"
2638

2739
run_ramalama -q --dryrun run --env a=b --env test=success --name foobar ${MODEL}
2840
is "$output" ".*--env a=b --env test=success" "dryrun correct with --env"

test/system/040-serve.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ verify_begin=".*run --rm"
3131
assert "$output" =~ "--network bridge.*--host 127.1.2.3" "verify --host is modified when run within container"
3232
is "$output" ".*${model}" "verify model name"
3333
is "$output" ".*--temp 0.8" "verify temp is set"
34+
assert "$output" !~ ".*-t " "assert -t not present"
35+
assert "$output" !~ ".*-i " "assert -t not present"
3436

3537
run_ramalama -q --dryrun serve --temp 0.1 ${model}
3638
is "$output" ".*--temp 0.1" "verify temp is set"

test/system/helpers.bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ function is_darwin() {
248248
[ "$(uname)" == "Darwin" ]
249249
}
250250

251+
function is_tty() {
252+
tty -s
253+
}
254+
251255
function skip_if_darwin() {
252256
if [[ "$(uname)" == "Darwin" ]]; then
253257
skip "Not supported on darwin"

0 commit comments

Comments
 (0)