#Turn off TUI interactivity during CI

1 messages ยท Page 1 of 1 (latest)

scarlet tide
#

I am using the Python SDK dagger-io>=0.18.3 everything works perfectly. However, when using it non-interactively (such as in CI environments) it still prints the TUI footer and seems to try to be animating the progress etc. which causes the log output to be a bit weird and jump around a lot when in progress.

I'm using BuildKite but I suppose this question is more generic: Is there a way to turn off interactivity completely (no animations, no ^H etc.) via the SDK?

#

This is how I am using the SDK:

    config = dagger.Config(log_output=sys.stderr)
    async with dagger.Connection(config) as conn:
        async with anyio.create_task_group() as tg:
            while len(args) > 0:
                tg.start_soon(build, conn, args[0], publish_tag, export)
                args = args[1:]
paper basin
mystic summit
paper basin
mystic summit
paper basin
#

Yeah, that's not entirely clear to me either, I'm making assumptions ๐Ÿ™‚

scarlet tide
#

sorry, should've taken screenshots. you can see in the above โ˜๏ธ it's running in a buildkite agent and still animating/printing out that footer/toolbar thing.

scarlet tide
scarlet tide
#

I took a look at the sdk source code and seems we can set these https://rich.readthedocs.io/en/stable/console.html#interactive-mode

However I tried

config.console.force_terminal = True
config.console.force_interactive = False

this doesn't seem to have any effect.

For now I did at the bash level by piping it through cat (thanks chatgpt :p) and this seemed to do the trick, the output is back to this format:

$ uv run ./build.py 2>&1 | cat

2   : โ”‚ connect
3   : โ”‚ โ”‚ starting engine
4   : โ”‚ โ”‚ โ”‚ create
5   : โ”‚ โ”‚ โ”‚ โ”‚ exec docker ps -a --no-trunc --filter name=^dagger-engine-|^dagger-engine-v0\.18\.4$ --format {{.Names}}
5   : โ”‚ โ”‚ โ”‚ โ”‚ [0.0s] | dagger-engine-v0.18.4
5   : โ”‚ โ”‚ โ”‚ โ”‚ exec docker ps -a --no-trunc --filter name=^dagger-engine-|^dagger-engine-v0\.18\.4$ --format {{.Names}} DONE [0.0s]
6   : โ”‚ โ”‚ โ”‚ โ”‚ exec docker start dagger-engine-v0.18.4
6   : โ”‚ โ”‚ โ”‚ โ”‚ [0.0s] | dagger-engine-v0.18.4
6

However, seemed like it'd be better to be able to control that from the sdk itself.

mystic summit
#

IIRC the other SDK's don't run the dagger CLI in interactive mode when invoked directly

paper basin
# mystic summit this is strange <@768585883120173076>. Is the python SDK expected to be doing th...

Python doesn't run the dagger CLI in interactive mode. It has its own TUI for showing progress when not in a session already. That's the "Creating new Engine session" part of that output. If you run with dagger run uv run hello.py that shouldn't show anymore. As for the dagger CLI TUI output, I'm not sure if that's expected to show up or if it's from some conflict in tty detection or something. Will need to investigate further.

mystic summit
# paper basin Python doesn't run the `dagger` CLI in interactive mode. It has its own TUI for ...

by running the session in "interactive mode" I was referring to dagger session directly by piping the output to the caller's stdout which if it is a tty, will show the TUI.

In any case, I've skimmed the python SDK session provisioner code and everything seems good there. I think what's happening here is that buildkite has a fancy terminal-to-html wrapper (https://buildkite.com/docs/pipelines/configure/managing-log-output) which presents the build log stdout as a tty capable target. So the dagger session command shows the traces with the TUI pretty output.

In the case of the Go SDK this doesn't happen because the SDK doesn't pipe the dagger session subprocess to the parent's stdout but uses an internal buffer for something which makes the session command use the plain log output instread of the TUI's

paper basin