Repository navigation
integrate DagQL - #6297
integrate DagQL#6297
Conversation
|
One immediate high-level thing: can we just put dagql in this repo too? It can be a separate package and all that, but it's easier to maintain in the long run when changes that require modifications to both this repo and dagql can be done in a single PR relative to splitting up, updating dependencies, etc. |
|
@sipsma Sure thing - I just don't want to lose the commit history from the other repo. Once we're closer to the finish line I'll figure out all that bookkeeping. (Either a separate PR with DagQL + history, or pulling it into this PR with everything currently here squashed into a single commit on top, but merging un-squashed to preserve the DagQL history.) |
19c6d03 to
7ad4d5a
Compare
3471460 to
32d3332
Compare
5ba9ae0 to
914a089
Compare
832fc7e to
ed6d791
Compare
|
Marked ready + requested reviews mostly as a "hey check this out if you have time + desire" - not trying to multiply the cost of reviewing such a huge PR, but you're more than welcome to obviously. 😅 |
There was a problem hiding this comment.
I guess this whole doc string can be updated now since it's only ever a name thanks to the other changes
There was a problem hiding this comment.
if possible would be better as an error just so we can avoid taking down everything, though admittedly it's hard to imagine this case getting hit, so not a big deal if changing to return an error is some huge wrench in everything.
There was a problem hiding this comment.
I'd like to leave this as a panic for the sake code readability. We do these conversions in a few places and IMO it's nice for it to feel like this is a routine operation in a fully defined system, i.e. there's always a 1:1 conversion available from core.TypeDef to dagql.Typed/dagql.Input.
As a compromise I added a unit test that will run for every TypeDefKind and fail if a new Kind isn't handled. This should really only happen during dev/test time when we add a new Kind but haven't added integration test coverage yet, but covering everything at an integration level can be tricky, so these unit tests should be a decent safety net.
There was a problem hiding this comment.
same as prev comment about avoiding panic if feasible
There was a problem hiding this comment.
guessing this is just temporary, but in case not then probably want to prefix it with DAGGER_ and such
There was a problem hiding this comment.
Haven't heard of this before, sounds neat 😄
There was a problem hiding this comment.
What's the need for both of these? The order previously was irrelevant (at least, I thought it was) so curious if something changed
There was a problem hiding this comment.
It might not actually matter - but I noticed we were sometimes appending and sometimes prepending and assumed it might be significant, so I just did a quick refactor so I could identify it more easily while figuring out how everything worked.
This kinda sorta feels like a delegation hierarchy to me, and usually those are in some kind of precedence order, but yeah given how everything is namespaced without any overlap it really shouldn't matter.
There was a problem hiding this comment.
That's implemented now right?
There was a problem hiding this comment.
Kind of - there's a prospective (*ID).Canonical() implementation but none of the fields set Meta() yet so nothing's impacted either way. I've also noticed Canonical() is pretty slow, so I'm wondering if we need a faster way to calculate it. Which also ties into whether/when we make IDs smaller by deduping them into a map[digest]ID where ID refers to its parent/arg/module IDs by digest instead of by embedding them, and the trade-offs involved. So it's a bit of a rabbit hole. 😅
More broadly I think there's a bit more to figure out with the whole 'canonicalizing IDs' mechanism - like whether/when it even makes sense to use a non-canonicalized ID, and whether loading an ID should attempt a cache store lookup against the canonicalized digest instead of just evaluating it and letting each selection hit the cache. (Pros: faster cache hits, cons: some of those "meta" fields work by installing state into the object, such as the current pipeline and focused state, so fields marked 'meta' are actually significant in a query cache, which makes me think they're actually more relevant when thinking about blobstore cache keys and such.)
I've been punting on this for now since the scope is pretty big already and the only immediate implication is busting the query cache, and right now they're not cached at all. Would definitely want to address all this sooner rather than later though.
There was a problem hiding this comment.
We previously allowed codegen and moduleRuntime to actually be cached (set Cache: true in CallOpts). IIUC that's probably not happening anymore because we now model this as a real module function call (which is great in and of itself, super cool we can do that now), but those are never cached (https://github.com/vito/dagger/blob/ce640898f4510fb82ece3c6a3f4ca33b8cbb268a/core/object.go#L337-L337)
I don't think this a huge blocking deal, but if I'm following everything correctly then it's probably somewhat of a performance hit. If it's possible to make these cached again would be nice.
There was a problem hiding this comment.
Ahh good catch, will take a look at this!
I also noticed the container.import call from the Go SDK is pretty slow, but I think it was slow before for the same reason - it's cached (previously in our one-off import cache, now in the query cache), but only locally to a session, and our integration tests use a bunch of different sessions so it's importing a ton of times. Would be pretty nice if we could somehow do that once on startup and base future calls on it. Or find a way to speed up the import when the content is already in the store. (I think we're mostly just paying a .tar streaming penalty.)
There was a problem hiding this comment.
I'm not totally grok-ing what's going on here and it's usage, comment would be helpful.
e.g. the usage in ModuleObjectType.ConvertToSDKInput, you set baseDeps to the module deps + itself, then you provide this id and append all of it's modules too (plus including the core mod via default deps). Are you duplicating modules in the list? Or are they non-overlapping sets of modules?
There was a problem hiding this comment.
Turns out we don't need the baseDeps arg anymore! 🎉 It always felt fishy that it needed effort on both sides of the call.
In a nutshell, this is the secret sauce that allows IDs to bring-their-own-dependencies, so you can take an ID returned by a module and pass it to any other module where it'll be loaded using a throw-away *dagql.Server with all of the ID's dependencies installed.
This must have been fixed when I moved the dependency-tracking Module *idproto.ID field from dagql.Class[T] to dagql.FieldSpec, which allows fields like impl - which come from a different module than the class it's being installed onto - to correctly declare its dependent module.
There was a problem hiding this comment.
should be args.Uncompressed right?
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
The bang for your buck here, documentation wise, seems pretty good. Would also help prevent copy-pasta. 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]>
Signed-off-by: Alex Suraci <[email protected]>
sipsma
left a comment
There was a problem hiding this comment.
Gonna preliminarily approve since everything left is either minor or do-able as follow ups. Want to get this out sooner than later so we can get the rebasing of everything else out of the way :-)
And as a general comment that really goes without saying, everything here is just incredibly cool and useful, amazing job. Getting control+specialization for our use case on this level of the stack up cleans up so much and sets us up for so much great stuff down the line 🚀
|
@sipsma Thanks so much for the thorough review despite the PR size - it definitely surfaced some valuable topics. 🙏 Since we just shipped yesterday, I'll go ahead and merge this so we can start the joyous process of rebasing other work in flight. For continuity, here the high-level follow-ups I can gleam from the discussion so far:
|
| SSHKnownHosts dagql.Optional[dagql.String] `name:"sshKnownHosts" deprecated:"This option should be passed to git() instead."` | ||
| SSHAuthSocket dagql.Optional[core.SocketID] `name:"sshAuthSocket" deprecated:"This option should be passed to git() instead."` |
There was a problem hiding this comment.
Somehow these deprecated options don't end up propagating into dagger.gen.go. These two fields also don't have docs in Install, so there's no information on them.
There was a problem hiding this comment.
good catch, taking a look!
There was a problem hiding this comment.
Looks like this wasn't making it to the client before, either; the introspection query it uses doesn't select the isDeprecated or deprecationReason fields.
Weirdly enough neither does the Apollo GraphQL sandbox explorer (left is v0.9.6, right is local dev):
(Placeholder docs added on the right just to suss out any "maybe it only shows directives if there are docs" nonsense)
Seems like we need to either update SDK codegen to look for @deprecated or manually set a description. The latter seems like less work for everyone in the grand scheme of things. Maybe setting something to deprecated could default its description to DEPRECATED: <deprecation reason>?
* integrate DagQL
* all schemas now execute using a dagql.Server, which replaces the
previous GraphQL stack (built upon two forks)
* all objects are now ID-able, and all objects now have loadFooFromID
* a single query cache is shared between all dagql.Servers within a
session
* most dependencies have now moved to Query, which is embedded by all
objects and dramatically improves code quality
* Objects are now self-contained; no more passing around millions of
arguments (s.bk, s.svcs)
* Query effectively represents the "root" of the Dagger session.
* use a connection URL for Buildkit socket IDs
* Untying this knot lets us move socket code back into the regular
core package.
* core API schema is fully derived from runtime definitions
* the generated schema SDL is still commit for documentation purposes.
each PR that changes the API must update it with docs:generate for
the docs:lint to pass.
* wire up experimental ID-based telemetry
* run CLI with IDS=true to see it
* telemetry is skipped for introspection resolvers (__schema,
current*) because they're too expensive (many, many paths). a test
actually failed because of the perf hit here. obviously worth
optimizing to the point where it's not a concern.
* add blob() API, used by host.directory() and host.file()
* Previously host.directory would return a core.Directory that embeds
a blob:// LLB reference. This made sense before because the
core.Directory's content was used as a key.
* In DagQL, IDs no longer embed the content itself, so this no longer
works. The solution here is to have an impure API that returns a
pure ID blob (host.directory(path:...) => blob(digest:...)).
* rework Zenith module initialization flow
* Previously the module entrypoint would be executed with
currentModule() set to a ModuleID that embeds the
partially-instantiated core.Module.
* Same as before, this no longer works because IDs are now recipes,
not content.
* The fix here is to split module initialization into two steps:
* Module.withSource which loads the module config, sets up metadata
(name, description, sourceDirectory, etc) and assigns the
generatedCode and runtime.
* Module.initialize which executes the module's entrypoint with the
previous result available as currentModule(), since it has a
proper ID.
* dagger mod sync now fetches the generated code from the result of
Module.withSource; Module.initialize is allowed to simplfy fail if
code doesn't compile.
* fixed a few tests that seemed to be testing modules that take list of
strings, but were passing a single string in GraphQL.
* This seems like it was a bug, where our query parsing was way too
permissive, but our tests were consistently written this way, so I'm
not 100% sure.
* reimplement Go SDK in terms of external API
* Previously the Go SDK was implemented by directly calling internal
core/ APIs. Now it strings together APIs from the "outside" using
dagql.Select.
* This allows us to leverage caching, at least locally to each server,
but it still isn't quite a silver bullet; the container image still
gets imported for each Dagger server, which seems slow, but I think
it's just as slow as before, since each container import cache was
also per-server.
* renames the TypeDefKinds to use SHOUTY_ENUM syntax.
* we should do this for all of our enums, but that'd be breaking, not
worth doing now
* sdk/rust: use PascalCase enums that serialize to their original enum
value.
* prevents secret values from ending up in IDs, using ArgSecret()
* sdk/nodejs: don't bother using ID type
* this doesn't exist in DagQL, but it might someday. but we can just
use a string here anyway.
* sdk/elixir: handle lists of objects, loadFoorFromID
* sdk/elixir: stop using deprecated secret API.
* sdk/java: avoid second-order exception when failing to parse fields.
* allow object fields to be optional
* added more tests for interfaces.
Signed-off-by: Alex Suraci <[email protected]>
* mark Container.export impure
Signed-off-by: Alex Suraci <[email protected]>
* fmt imports
Signed-off-by: Alex Suraci <[email protected]>
* wire slog up to logrus
Signed-off-by: Alex Suraci <[email protected]>
* add ID-centric progrock frontend
Signed-off-by: Alex Suraci <[email protected]>
* fix Java SDK handling of list of objects
and update README to make generated code easier to find
Signed-off-by: Alex Suraci <[email protected]>
* clarify labels.LabelUncompressed usage
Co-authored-by: Erik Sipsma <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
* nix extra clones
Signed-off-by: Alex Suraci <[email protected]>
* blob(): validate digests
Signed-off-by: Alex Suraci <[email protected]>
* setSecretFile is impure, returns pure Secret
Signed-off-by: Alex Suraci <[email protected]>
* dagql: Impure() requires a reason
The bang for your buck here, documentation wise, seems pretty good.
Would also help prevent copy-pasta.
Signed-off-by: Alex Suraci <[email protected]>
* add basic test to catch TypeDef conversion panics
Signed-off-by: Alex Suraci <[email protected]>
* rename NullableType fields for clarity
Signed-off-by: Alex Suraci <[email protected]>
* simplify/clarify SourceMod checks
Signed-off-by: Alex Suraci <[email protected]>
* update GetSecret doc string
Signed-off-by: Alex Suraci <[email protected]>
* document + clean up IDDeps
Signed-off-by: Alex Suraci <[email protected]>
---------
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>

This PR swaps out our GraphQL server infrastructure for DagQL.
notable changes
FooIDscalar type and aloadFooFromIDroot-level field.container.importandcontainer.build- instead we use IDs as query cache keys. 🎉.Impure().core/schema/*.gocode at runtime. We no longer need to maintain*.graphqlsfiles..graphqlsfile for our GraphQL schema docs, generated by./hack/make docs:generate.docs:linttarget ensures this is up-to-date, just like the SDK codegen lints.Module.withSource(source: Directory!, subpath: String): Module!installs the source directory and runs codegenModule.initialize: Module!evaluates the entrypoint, which is where all thewithObjectand such are installedModuleIDthat literally contained the partially instantiated module content, but now we need an ID that refers to that intermediate state in order to run the entrypoint, so we pass the result ofwithSourcealong.withSource.generatedCode.log/slogin new code. Seems like we could switch to this instead of piggybacking on Buildkit's logging infra. Not sure though since we'll have to coexist with Buildkit's logs either way. Can be talked out of this.goals
cleanups along the way
unix://andtcp://instead of using a SocketIDSHOUTY_GRAPHQL_STYLEpanics on error instead offmt.Println+os.Exitso we can tell which line erroredlinkDependencyBlobs- not fixed here, opened an issue: 🐞 Blobs referenced by private fields in a module object can disappear #6406replaces #6158