Repository navigation
Group API - #4248
Group API#4248
Conversation
|
First: wow! This will take our DX and OX to the next level. Second: my biggest question is on expected consumption model.
|
Yes, absolutely. This PR is "write only" at this time. Tentative plan is as follows:
|
vito
left a comment
There was a problem hiding this comment.
API looks great! Just some minor comments.
There was a problem hiding this comment.
nit: the name made me think this might return a *pb.Definition
| func (g Group) LLB() llb.ConstraintsOpt { | |
| func (g Group) LLBOpt() llb.ConstraintsOpt { |
There was a problem hiding this comment.
Fixed!
Also renamed PG() to ProgressGroup()
There was a problem hiding this comment.
Makes sense, just curious: does something (perhaps your CLI demo) parse this out? Don't see any other reference to dagger.group in this PR.
There was a problem hiding this comment.
On this note, if it's straightforward I think we should update our current plain progress code to strip this out when present, otherwise the output looks like: #3 [dagger.group:["from alpine:3.16.2"]] resolve image config for docker.io/library/alpine:3.16.2 which is kind of confusing.
There was a problem hiding this comment.
Looks like this supports taking a progress group, so in this case the CustomName is just to make it clearer in the UI that this is an internal thing?
There was a problem hiding this comment.
Yes -- this appears as a random mkdir /meta and it's not obvious what it stands for (the user requested an exec and this randomly appears)
creating dagger metadatais to make it more obvious thanmkdir /meta[dagger.internal]is to hide it altogether from the UI
See comment below for an alternative
There was a problem hiding this comment.
On this note, if it's straightforward I think we should update our current plain progress code to strip this out when present, otherwise the output looks like: #3 [dagger.group:["from alpine:3.16.2"]] resolve image config for docker.io/library/alpine:3.16.2 which is kind of confusing.
|
@sipsma @vito: Answering to both related comments, with a question/proposal:
So there's 2 "special" naming conventions:
It's simple enough, however parsing this out is a bit hacky with edge cases, and we'd have to replicate the logic for every consumer. What do you think of using JSON as vertex names? With {"name": "go build"}
{"name": "docker.io/library/alpine:3.16.2", "group": ["from alpine:3.16.2"]}
{"name": "mkdir /meta", "internal": true}In the future, we could actually make this fully structured: {"op": "exec", "args": ["go", "build"], "env": {"GOOS": "linux"}}This would give a lot of liberty to the UI for rendering (e.g. color code file ops and execs differently) and observability (e.g. filter pipeline timers by execs, show me the slowest image pulls, ...) |
There was a problem hiding this comment.
side note: @sipsma if we ever want to, we could use this same mechanism for a query.WithDefaultPlatform()
e2dfd88 to
a0f4920
Compare
In Python dagger/sdk/python/src/dagger/codegen.py Line 495 in c5a9cdb |
Add support for `_EXPERIMENTAL_DAGGER_JOURNAL`. This will dump raw events to a log file, useful for post analysis. Currently this will only be used internally and is subject to removal. Related: dagger#4248 Signed-off-by: Andrea Luzzardi <[email protected]>
e632eee to
2b0ab02
Compare
|
@vito @sipsma So there's a bug that prevents query fields from returning a query within an extend (e.g. Seems like it's a bug deep down in graphql-go-tools. I gave up debugging and instead added groups as part of the Thoughts? |
vito
left a comment
There was a problem hiding this comment.
Sounds fine to me. 👍
The .graphqls just needs some tidying up, otherwise LGTM!
There was a problem hiding this comment.
Dupe?
| group(name: String!): Container! |
Also needs a doc string
|
My first reaction to this is just that I also don't like long names, but in the name of clarity, we could use: |
|
I love where this is going! I like |
|
Pipeline SGTM too! We're already calling the entire outer query a "pipeline" colloquially, and this API call effectively forms a sub-pipeline or branch of the pipeline, so it feels consistent. |
* journal file Add support for `_EXPERIMENTAL_DAGGER_JOURNAL`. This will dump raw events to a log file, useful for post analysis. Currently this will only be used internally and is subject to removal. Related: #4248 Signed-off-by: Andrea Luzzardi <[email protected]> * journal: append to file Signed-off-by: Andrea Luzzardi <[email protected]> Signed-off-by: Andrea Luzzardi <[email protected]>
|
@sipsma re: your earlier comment:
Just implemented that (engine.go). A bit nasty but does the trick (channel "proxying" for Dealing with one last test then this is good to go |
|
@vito I think I'm hitting the same issue you described here: #4130 (comment) I've changed if args.ID != "" {
return &core.Directory{
ID: args.ID,
}, nil
}
return core.NewDirectory(ctx, llb.Scratch(), "", pipeline, platform)
}I believe the |
There was a problem hiding this comment.
@vito PTAL, I think this fixes #4130 (as well as this PR) -- see last commit
- Copied the original check logic for
llb.Scratch()above, however check forres.SingleRef()returningnil(rather than checkingpayload.LLB == nil). AFAIKgw.Solve() + SingleRef()will always returnnilfor ascratchresult - Removed the original scratch check above for repetition. Solving
llb.Scratch()(ornil) will result to a scratch result, so the edge case is already captured (the only downside is we lose a bit of time trying to Solve() scratch, but that's ok) - Not sure what edge cases
path.Clean(src) == "."is supposed to catch, but that didn't work forDirectory(""). So I added an explicit/check to make this work forscratch.Directory(""),scratch.Directory("/") - Added dir Mode to
Statof scratch.container.Directory()has aif !info.IsDir() { return nil, fmt.Errorf("path %s is a file, not a directory", dirPath) }check, which was failing
/cc @sipsma
There was a problem hiding this comment.
Nice, if ref == nil feels a lot more sturdy. LGTM!
Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
…mbed it Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
0bed142 to
86f071e
Compare
Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
The group API allows to programmatically group related operations together for status reporting and visualization purposes (e.g. logs).
Groups are hierarchical and can contain any number of sub-groups.
TODO / Open Questions
client.Group()currently returns a*dagger.Query*dagger.Queryin a*dagger.Client, so it can be transparently passed around to unsuspectingdagger.Clientreceivers? (e.g. control grouping from the caller)custom attributesto groups/vertices?namestringENVfor anexec)extend type Query { group(...): Query! }doesn't work (complains aboutQuerybeing undefinedgroupfield not found inQuery)Example Usage
Taking this repository as an example, we perform hundreds of operations (e.g. exec, copies) which all get reported back as a single flat stream, with all operations mixed together.
This repository's CI is organized in 20 or so logical "parts": 3 SDKs with a build/lint/test/generate target each, an engine with a few targets, etc.
Using this API, each "logical part" would be grouped programmatically. The group hierarchy could look like this (simplified for illustration purposes):
sdksdk/gosdk/go/lintengineengine/buildAPI Usage
Query API
Schema
Usage
Example
Container/Directory API
API
Usage
Example
Built-in Groups
Some high-level operations in the API map to multiple low-level API calls, resulting in an incomprehensible mismatch. As in, executing a single operation can result in multiple "statuses" being sent back, without any way to correlate them.
The problem is even worse because of caching -- the number of low-level API calls might be different each run.
The API now creates a child-group automatically when performing multiple low-level operations, resulting in a 1:1 mapping for high-level calls to statuses.
Changes:
c.Host().Directory()
local://<path>copy / /host.directory <path>uploadcopycopy / /, not the upload part.c.Container().From()
resolve image config for docker.io/library/node:18-alpinefrom alpinefrom alpineresolve image configpull alpineresolve image configshows up every time whereas the pulling part only if the image digest has changed from cache. Without sub-groups, every singleFrom()maps back to 1 or 2 statuses, depending on cache. With sub-groups, there's always going to be a singlefromgroup for eachFrom()call in a predictable way.c.Container().Build()
[1/12] FROM docker.io/...[2/12] RUN apk add curldocker build[1/12] FROM docker.io/...[2/12] RUN apk add curl[2/12] RUN apk add curlwith no idea which build it belongs to/cc @sipsma @vito @shykes @helderco @dolanor