Skip to content

Document Lazy DAG Model #3617

Closed
Closed

Description

@aluzzardi

Related #3555

There's been confusion over the "lazy" model, what is sync vs what is async (few discord threads, feedback forum, live YouTube video, ...)

Not only it's confusing, it's one of great advantages of dagger and it's not being understood: write "procedural" code (e.g. container1.Exec, container1.Exec, anotherGraph.mount(container1, container2) and have everything run in parallel, as fast as possible)

I think we should:

  • Document in the getting started (it's a major feature, not a "problem")
    • Examples should show the parallelization mechanism
    • Embrace the fact that things get lazily executed with maximum parallelism
  • Make it less confusing in the API
  • Enforce a standard (if it returns an error, it's synchronous)
  • Add an explicit "synchronous" function (e.g. container.Exec().Sync())
    • Right now we're forced to call a "dummy" synchronous function (e.g. Stdout().Contents()) and throw away the result to force something to be executed
  • Maybe: Force evaluation of "unsolved" nodes at .Close() time?
    • For instance: c.Container().From("alpine").Exec("echo", "hello world") will never be executed as it's not referenced anywhere
    • Perhaps query builder should track "pending" queries and "flush" them on client.Close()?
    • I've seen this happening on the YT video
      • call "go build", nothing happens, script returns immediately. Let's check Stdout(). Oh it's working now 🤔

/cc @sipsma @shykes @vito @helderco @vikram-dagger

Activity

  1. shykes commented on Oct 31, 2022

    @shykes
    Contributor

    I agree this is a high-priority DX item. So a general 👍to spending time on all this now.

    Embrace the laziness

    +1 it's a strength of our compute model. We should embrace it and educate people upfront about it. Of course that is work :)

    Handling of IDs

    This one feels like a special case, I would like to discuss it a bit more before we cross any one-way doors.

    My feeling so far:

    • Developers seem to find the ID handling part of our Go API confusing

    • Hiding it is probably a good idea, because from the Go point of view, it's an implementation detail related to the limitations of the underlying query language (graphql). My attempt at explaining this to @nicholasjackson:

      The ID thing is really an implementation detail of the underlying API transport (graphql). Some pipelines can be expressed as a single API request. Others need to be broken down into several calls: this is done by basically ending the first sub-pipeline with a "save" operation, and starting the second sub-pipeline with a "load" operation. The "ID" is really the serialized contents of the first pipeline, being saved then loaded back.

    • Even hidden, IDs need to have a clear purpose that we can explain. Given the above, I feel like maybe we should change the name from ID to something else. The name is rooted in the GraphQL best practice of giving every object its own ID. But we have slowly deviated from that best practice, both in implementation (content-addressed, no DB lookup) and in intent (domain-specific save/load of pipeline state). So I think we should at least consider looking for alternatives that are less confusing.

  2. dolanor commented on Nov 2, 2022

    @dolanor
    Contributor

    @slumbering was also thinking that for the TS SDK, where you can start typing functions, but if you just stop there, you're actually running nothing.
    I was thinking about maybe some linter that would analyze that and underline some code that would execute nothing.

    But I agree with the fact that this way of lazy evaluation is a strength and we should document it more no matter what we decide to do on the other hand.

  3. jpadams commented on Jan 13, 2023

    @jpadams
    Contributor

    image

  4. helderco commented on Apr 24, 2023

    @helderco
    Contributor

    @vikram-dagger, we need to move this forward. Can you help?

    Updated description of the problem in:

    For the last "Maybe: Force evaluation of "unsolved" nodes at .Close() time?" I have a separate proposal:

  5. added
    area/documentation
    on Apr 24, 2023
  6. helderco commented on Jul 18, 2023

    @helderco
    Contributor

    Update: Need to update the description here. It's currently outdated but it's still much needed.

  7. locked and limited conversation to collaborators on Mar 24, 2026
  8. converted this issue into a discussion #12083 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions