Repository navigation
add DagQL subtree - #6405
add DagQL subtree#6405
Conversation
Signed-off-by: Alex Suraci <[email protected]>
* start using github.com/vektah/gqlparser/v2 and adopting its types
* build up a schema as types are installed
* start introducing Class/Object terminology
* throw abstractions around until things fall into place
* think I may have gone overboard with generics, but committing for now
* start establishing boundaries
* new Typed interface for keeping track of a value's type
* including Builtins (int -> Int, TODO Boolean/String/etc.)
* Node is Typed
* Server queries a Node Field and returns a tree of Typed values
* no more returning primitives
* we'll handle marhsaling back to JSON somewhere else
* switch to gotest.tools/v3/assert since it has nice equality helpers
with cmp (and protocmp)
up next:
* meta and pure/cache-mode should be schema directives, figure out how
functions indicate this
* speaking of directives, support deprecated fields
* instead of Install + ObjectFields + Func helper, consider just
installing a type and crawling its public methods.
* write GraphQL queries in tests, start testing more things once that
high-level API exists
* support descriptions on everything
* figure out how scalars actually work, may need to relate to ast.Value
Signed-off-by: Alex Suraci <[email protected]>
this isn't perfect, but feels like a good boundary for implementation. Signed-off-by: Alex Suraci <[email protected]>
we're skipping over the nicely abstracted Server boundary here, but it's worth it for the brevity Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
* ID selectors may now specify an *nth* field (1 indexed) to return an
object from an array return value.
* This approach builds on the fact that array results should also be
deterministic, so that we can safely refer to any value.
* refactor Typed to return full *ast.Type
* Resolver > Node rather than Node > Resolver
* ObjectNode -> Object
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
* Server installs introspection types + fields * implement Nullable resolver semantics need to go on a detour to implement fragments Signed-off-by: Alex Suraci <[email protected]>
* support fragment spreads * fix subtle nil vs [] behavior * fix FooID type not actually being installed into schema * Resolver -> Selectable, idk, wanted to avoid clash with Server but then ended up adding Select there too, needs another look * move introspection code to introspection/ package * implement more JSON marshalers Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
got a little ahead of myself Signed-off-by: Alex Suraci <[email protected]>
this is a fundamental building block, otherwise even loadFooFromID would return the right value but with an ID that referring to loadFooFromID itself Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
* get rid of nonsensical TypeResolver interface in favor of distinct Scalar and Class interfaces * get rid of Literal Marshaler/Unmarshaler interface * Literal type is gone; Typed and Scalar take its place Signed-off-by: Alex Suraci <[email protected]>
Instead of requiring all Scalar types to implement Kind, we use the Literate interface, and define how to translate this bounded domain to an ast.Value Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
TODO test Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
not really fully baked yet, haven't tried passing them as inputs Signed-off-by: Alex Suraci <[email protected]>
* allows you to pre-define var values instead of using strings everywhere * allows you to defer Scalar implementation to a single common implementation (Enum[T]) * split ScalarClass out of Scalar * Instantiator -> ObjectClass for symmetry Signed-off-by: Alex Suraci <[email protected]>
* Scalar has Class() instead of always implementing it * builtins just return their zero value * enums define this to return their class, which is defined separately * possible refactors here now that an Enum can just get its Class. * ScalarClass.New is now used to parse defaults, which just makes so much more sense, and removes the coupling to JSON * bad ArgSpec is now a runtime error, which means you'll hit the error later, but that seems OK since you should really have tests for all this anyway. * test builtin defaults, which is currently surfacing a lot of verbosity, could be worth refactoring Signed-off-by: Alex Suraci <[email protected]>
* add a toSelectable helper so ObjectClass.New never has to deal with other types (in keeping with the custom around Nullable values) * move some code around to better homes 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]>
* use github.com/sourcegraph/conc which also handles panics for us * test parallelism, and test returning all errors instead of first * misc refactors Signed-off-by: Alex Suraci <[email protected]>
GraphQL schemas make more sense when the fields are returned in the order intended by the schema designer, so this type must preserve it. As a positive side effect, funcs and FieldSpecs know their own name now, which could be helpful for error messages. Signed-off-by: Alex Suraci <[email protected]>
* types can now bring their own Definition() or Description() * Scheme() now builds the *ast.Scheme on-the-fly * dependence on gqlparser prelude is gone * TODO: make schema-building + installing thread-safe * TODO: cache schema-building between installs * TODO: stable field order Signed-off-by: Alex Suraci <[email protected]>
need for this was removed and amended into commit Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
just about every SDK was blowing up if a null value was present here, so let's just enforce empty string instead Signed-off-by: Alex Suraci <[email protected]>
also fix pesky slog import Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
out of date, we can decide whether to switch later Signed-off-by: Alex Suraci <[email protected]>
There was a problem hiding this comment.
I think we'll want to change this pretty soon to be more compact. It's really easy to have arguments or parents that depend on the same ID by carrying it around wholesale, inflating the ID payload through repetition. This is especially common now that IDs contain a reference to their originating module.
We should probably restructure this using a flat map[digest.Digest]ID and have embedded IDs reference digests instead.
There was a problem hiding this comment.
There's some low-hanging-fruit optimizations possible here, e.g. when we're loading an ID we could do a direct cache lookup for the final ID instead of re-evaluating it and going through N cache hits for the depth of the ID. Just kept it simple for now.
|
(Gonna leave comments one by one so you can get back as I continue to review, so sorry if there's a lot of notification noise) |
There was a problem hiding this comment.
This includes IDs with local dir blobs, in memory secrets, etc.? If so, then I guess while it can be loaded on a server, that doesn't mean it necessarily works right? Just checking
There was a problem hiding this comment.
This is only used for pipes and the demo right? Just checking whether it's purely that or if you think this has more general utility
There was a problem hiding this comment.
I think there's general utility, but nothing important hinges on it at the moment. We can use this in Dagger to allow a resolver to write arbitrary logs to telemetry. As an alternative we could put the full *progrock.Vertex in context.Context and access its .Stdout and .Stderr instead, but reducing that down to stdout/stderr streams felt slightly better/more future-proof.
There was a problem hiding this comment.
nit: having looked at this for ~5 seconds it's not clear to me what it's purpose is, which is my approximate threshold for a comment on it being helpful :-)
There was a problem hiding this comment.
To clarify, this is saying that Query itself isn't id-able right?
There was a problem hiding this comment.
I'm guessing this is for the SetSecret case? And there's no problems with the value here not being part of the ID? It can still make its way to the actual implementation that stores the secret in the store even when not in the ID?
There was a problem hiding this comment.
Yep exactly.
So for SetSecret there's a particular dance you have to do to get it all to work.
- User calls
SetSecretwith spooky plaintext credentials. DagQL avoids putting those into an ID, so we can be sure it never ends up being sent over the wire or busting cache keys. - The
SetSecretfield is markedImpure(), so we don't have to worry about that "redacted" ID resulting in a cache hit if you callSetSecrettwice with different credentials. - But that also means any IDs depending on
SetSecretwould become impure. So instead theSetSecretresolver performs its side-effect (installing the secret) and then returns the result of queryingsecret(name:...)instead. So this is a case of an impure resolver returning a pure result.
There was a problem hiding this comment.
I think the comment is cut off here maybe? Which left me waiting in anticipation because I was wondering about whether Enumerable values were indexed starting at 1 or 0 😄
There was a problem hiding this comment.
lol, yes unfortunately they are indexed starting with 1. 😂 I regret that decision, we should probably undo it.
sipsma
left a comment
There was a problem hiding this comment.
Very far from thorough review but got enough of a gist, all super cool and extremely glad we have more control on this level of things now (rather than fighting an eternal war against the other graphql server implementation). Seems like it will unlock all sorts of cool things in the long term besides the immediate benefits 😎
Signed-off-by: Alex Suraci <[email protected]>
| // Definition returns the schema definition of the class. | ||
| // | ||
| // The definition is derived from the type name, description, and fields. The | ||
| // type may implement Definitive or Descriptive to provide more information. | ||
| // | ||
| // Each currently defined field is installed on the returned definition. | ||
| func (cls Class[T]) TypeDefinition() *ast.Definition { |
There was a problem hiding this comment.
nit: here, and quite a few other places in this file the doc-string refers to the wrong method name. Definition => TypeDefinition.
There was a problem hiding this comment.
woops, will patch that up - thanks!
There was a problem hiding this comment.
How is this file different to the one in core/cachemap.go?
Can we deduplicate them somehow into one common set of utils?
There was a problem hiding this comment.
Oh yeah these can be deduped. Only issue is that we'd have a circular dependency between core/ and dagql/ so we'd need to move it elsewhere.
This PR merges in the full DagQL repository as a toplevel
dagql/subdirectory, keeping its history intact.I know we usually do squashed commits for PRs but this feels like a bit of a special case where I'd prefer to keep the
git blamesince some of the commits have a lot of explanation. In total it's 💯 commits which is pretty nice.prerequisite for #6297