Skip to content

Introduce Progrock and inline progress UI - #5078

Merged
vito merged 29 commits into
dagger:mainfrom
vito:progrock
May 10, 2023
Merged

vito merged 29 commits into
dagger:mainfrom
vito:progrock

Conversation

@vito

@vito vito commented May 2, 2023 •

Copy link
Copy Markdown
Contributor

This PR introduces Progrock to the codebase, in a backwards-compatible way.

The main user-facing feature here is the addition of an alternative inline style TUI.

export _EXPERIMENTAL_DAGGER_TUI=inline to enable

asciicast

Comparing & contrasting inline and interactive (aka tree-style) TUIs:

  • The inline TUI is designed to show progress within your shell session with minimal disruption.
    • The interactive TUI displays an interactive explorer for the run and gives you more controls for troubleshooting/etc.
  • The inline TUI exits as soon as the command finishes.
    • The interactive TUI stays open when the command finishes, so that you can go over all the output to your heart's content.
  • Both inline and interactive TUI require a TTY. Neither of them are appropriate for e.g. printing logs within a CI system like GitHub actions.
    • A third output format will have to be introduced. For now the existing dagger.WithLogOutput format is used if a TTY is not detected on stdout/stderr.
  • Technically the inline TUI is also interactive while it's running, so "inline" vs "interactive" is a bit of a misnomer.
    • However inline doesn't require interaction, while interactive TUI requires interaction in order to exit, which is an important distinction for e.g. shell scripting.
  • The inline TUI renders output as a graph in a style similar to git log --graph.
    • The interactive TUI renders output as a tree which is a bit easier to grok at a high level, with expanding/collapsing/etc.

I prefer the inline UI for quick local iteration, since it keeps you in the terminal, but I don't intend to replace the current "interactive debugger" style UI. They both have different strengths and weaknesses, and I expect to support both as long as they are useful to people.

Besides the shiny new UI, this change gives us full control of the progress stream, meaning we can now display whatever progress items we want to the user. Some places where it should help:

  • Showing service health checks
  • Running services via the Buildkit frontend gateway rather than a solve() API
  • Showing progress for the slow part of Container { import } that's invisible to Buildkit
  • Showing the GraphQL API calls to the user, revealed with --debug

This progress protocol is largely based on Buildkit's *client.SolveStatus, with some refinements:

  • Vertexes can now be marked "internal" and hidden from the UI by default (as with GraphQL query vertexes)
  • Vertexes now have a distinct "canceled" state to distinguish from regular errors
  • Groups now exist as their own object, so vertexes can just point to a group ID instead of hoisting around a huge bag of JSON
  • Groups now send a "completed" when the Dagger session ends, which should help us determine whether a build is completed or just in-between steps
  • The protocol is defined in protobuf, so it's ready to be sent over gRPC if anyone ever needs to do that

Comment thread cmd/client-gen/main.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this by-value because there was a place I wanted to assign defaults to the given config, but didn't want to mutate the input.

Comment thread cmd/client-gen/main.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: you'll be seeing this a lot.

Progrock provides FromContext and ToContext but I'm not sure if we want to commit to that. I started with it, but then there was one place the recorder was dropped because we intentionally create a context.Background(), and that spooked me into making it explicit in a later commit. But it is everywhere and now I'm seeing the value in context.Context again. 😅

Let me know what you prefer! I'm really on the fence.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for context.Context

Comment thread core/container.go Resolved
Comment thread router/router.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shimmies the recorder through context.Context so ToResolver can use it.

Comment thread engine/engine.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this to truncate instead of appending, per conversation w/ @marcosnils and @aluzzardi

Comment thread engine/engine.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sipsma Moved this from internal/engine/client.go so it can use LogOutput; we need to be careful about printing to os.Stderr now since it messes with the inline TUI. I remember this was tied to a certain use case though, so not sure if this change is OK.

In the future we could add a Progrock vertex for internal logs (and maybe mark it "internal"), but this tweak is a smaller lift.

@sipsma sipsma May 10, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this is good. The current use case was just to do a quick unblock of the desire to know which engine an SDK is connected to when looking at plain progress output directly (e.g. in GHA logs).

As long as it's still viewable in that context this is all good. What we should actually be doing here is emitting an event so that it shows up in the cloud UX (and presumably all the local TUIs too then?), but not needed now

@vito
vito marked this pull request as ready for review May 3, 2023 01:31
@vito
vito requested review from aluzzardi, jlongtine and sipsma May 3, 2023 01:31
@gerhard

gerhard commented May 4, 2023 •

Copy link
Copy Markdown
Contributor

This is looking mighty fine! 💪

A few things that I think would make it even better - each suggestion is separated by a horizontal rule:


Once a timer goes over 60s, it would be more human friendly to show it with minutes, e.g. 3m 42s instead of 222.3s


When an operation is cached, it should have a slightly greyed colour. Using the CACHED styling for the timer, and the timer style for the entire CACHED exec ... line would make more sense to me:

image

Note I am using https://github.com/morhetz/gruvbox


When the pipeline run ends, I think that we should show the total execution at the bottom. Case in point: this pipeline is too long to fit on one screen:

image

When I scroll to the beginning of this pipeline, I see █ [222.3s] go run main.go ci:

image


Lastly, I am wondering how to make the various stages more obvious. Seeing where one stage starts and another one ends, as well as how long each stage took, is something that I am missing. I like the white bold colour used in several places, but I am not sure whether it's highlighting the right thing. I am also unable to see the duration of each stage. This could be a potential follow-up. It's also OK to not do it if it's too hard or only make sense to me.

@gerhard

gerhard commented May 4, 2023

Copy link
Copy Markdown
Contributor

I have a few more improvement suggestions (e.g. rave, etc.), but don't want to make this too big. Leaving it for another time.

@gerhard

gerhard commented May 4, 2023 •

Copy link
Copy Markdown
Contributor

--debug is sweet 🍭

_EXPERIMENTAL_DAGGER_TUI=inline ~/github.com/dagger/dagger/bin/dagger run \
  --workdir ../ \
  --debug \
  go run main.go ci

image

Comment thread internal/mage/util/util.go Outdated
Comment on lines 56 to 57

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to delete these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I'm not sure if anyone is using this, or if it's a leftover from when we were still figuring out how to bootstrap our CI stack. I had to remove these because my go.work points to ../foo which doesn't get picked up and causes all the builds to fail.

For me the fastest feedback loop is doing dev/test with native go test etc., and then using ./hack/make test as the final "about to push" run, where ignoring go.work and go.work.sum gives me a valuable reminder to actually bump the dependencies in go.mod.

cc @sipsma @marcosnils @jlongtine @helderco @aluzzardi to see if anyone's depending on this and whether I can remove it. 🙏

@gerhard gerhard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes read very well to me. Excited to see this in the hands of users! 🤘

vito added 13 commits May 6, 2023 15:13
so this can be reused for benchmarks too

Signed-off-by: Alex Suraci <[email protected]>
to be honest, this kind of demonstrates the value of using context, but
I'm committing this anyway so we can decide which flavor we want

Signed-off-by: Alex Suraci <[email protected]>
rather than converting pipeline paths to progrock groups in core/,
convert them while converting from buildkit events to progrock.

we may want to unroll this later if/when we decide to switch to progrock
everywhere, better to prioritize compatibility for now.

Signed-off-by: Alex Suraci <[email protected]>
otherwise this collides with the inline TUI

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
out with multi-group vertexes, in with separate vertex instances

Signed-off-by: Alex Suraci <[email protected]>
seems worth it, at least one other person thought so too, also allows
for passing into our GatewayClient

This reverts commit 6af33b0526c3815a85920c403b6d4f1677e3ea96.

Signed-off-by: Alex Suraci <[email protected]>
vito added 2 commits May 6, 2023 15:14
also remove ctx argument from LLBOpt and ProgressGroup, unlikely that
we'll need it there now that we can emit groups in GatewayClient

Signed-off-by: Alex Suraci <[email protected]>
vito added 3 commits May 6, 2023 15:18
in a lot of cases we already have one, plus this allows us to record
*pb.Definition vertex membership before creating a Directory/File

Signed-off-by: Alex Suraci <[email protected]>
key points:

* the Progrock code paths are now completely independent from
  ProgressGroups, which are only preserved for compatibility with Dagger
  Cloud
* the gateway client now automatically records memberships for all
  inputs to Solve
* implicit Dagger pipeline groups must manually emit membership for LLB
  that they build, in lieu of setting a ProgressGroup.
  - applies to the following:
    * from <image>
    * host.directory <path>
    * docker build
    * service <hostname>

Signed-off-by: Alex Suraci <[email protected]>
vito added 2 commits May 6, 2023 16:27
Signed-off-by: Alex Suraci <[email protected]>
vito added 9 commits May 6, 2023 16:51
Signed-off-by: Alex Suraci <[email protected]>
used for collecting events into a journal file for comparing
side-by-side with old journal format

Signed-off-by: Alex Suraci <[email protected]>
* record any Digestible params as inputs to the --debug vertex
* display digests instead of giant FooID values

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
The inline TUI works better for fast feedback loops and scripting, since
it doesn't take over the screen and it doesn't require an extra
interaction to quit back to the terminal.

+ fix --debug --interactive deadlock
+ propagate command error from inline TUI

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on a quick skim, one comment about the engine name print.

Also, super cool to see how this all sets up possibly caching by query like you mentioned here.

Comment thread router/schema.go
return nil, err
}

if edible, ok := any(res).(Digestible); ok {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍽️

@vito
vito merged commit 44cde95 into dagger:main May 10, 2023
@vito
vito deleted the progrock branch May 10, 2023 18:47
@gerhard

gerhard commented May 10, 2023

Copy link
Copy Markdown
Contributor

I did another pass with the latest changes yesterday. This is what the final output looks like:

Screen.Recording.2023-05-10.at.20.28.24.mp4

While some of my earlier points are still outstanding, I don't see any merge blockers 🚀

@vito

vito commented May 10, 2023

Copy link
Copy Markdown
Contributor Author

@gerhard Sorry, had a comment drafted but must have closed the tab. Thanks for all the feedback, agree with most of it, biasing towards getting more feedback and data points once it's in the patch release. :)

Also those giant IDs in --debug should be fixed by 9735fc4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants