Skip to content

Attach compute pipelines to a value with #compute rather than #dagger.compute - #118

Merged
shykes merged 1 commit into
mainfrom
poundrun
Mar 7, 2021
Merged

shykes merged 1 commit into
mainfrom
poundrun

Conversation

@shykes

@shykes shykes commented Feb 12, 2021 •

Copy link
Copy Markdown
Contributor

Summary

This pull request changes the path to use when attaching a compute pipeline to a configuration value.

  • Before this PR: compute pipelines are specified at the relative path #dagger.compute
  • After this PR: compute pipelines are specified at the relative path #compute

Rationale

It has come up a few times that #dagger: compute is not ideal as a path for attaching compute pipelines to config values.

Among other issues:

  • It’s unnecessarily long
  • It mixes a key with # and a key without; potentially confusing users and causing frustrating typos (eg. dagger: #compute )
  • There is already a cue package called dagger which contains definitions. So users will see this:
foo: dagger.#Foo & {
  #dagger: compute: [ ... ]

This further increases confusion between “pound” and “no pound”.

Possible alternatives

Several alternatives have been discussed:

  • #compute (this proposal)
  • #run (my previous favorite, but I now think #compute is better)
  • #apply
  • #onChange
  • #onchange

Thank you @dubo-dubon-duponey and @tiborvass for their feedback.

@dubo-dubon-duponey

Copy link
Copy Markdown
Contributor

Personal preference would be for:

import (
  "dagger.cloud/dagger"
)

dagger.#run

Understood that this is more of a mouthful than just #run - on the other hand it makes it seem less "black magic", it points to the package it's "coming from", alongside the other definitions, and feels a bit easier to reason about.

Either way, #run is definitely better than the current #dagger.compute, that's for sure. :-)

@shykes

shykes commented Feb 12, 2021 via email

Copy link
Copy Markdown
Contributor Author

@dubo-dubon-duponey

Copy link
Copy Markdown
Contributor

Ok.

"What is needed is a standard path which users can use to place annotations."

I do not understand what that means ^.

The point I was trying to make (very badly) above was that:

It feels a little bit weird to have part of dagger SDK being imported with the natural cue mechanism, under their own namespace (import, then call dagger.#Bla), while some other parts (#dagger.compute) are just there, magically, in the global namespace.

(and understood that under the hood #dagger.compute is substantially different from dagger.#Exec - but still, it feels weird :-))

@shykes

shykes commented Feb 13, 2021 via email

Copy link
Copy Markdown
Contributor Author

@shykes shykes changed the title For discussion: #run in stead of #dagger:compute For discussion: #run instead of #dagger:compute Feb 13, 2021
@verdverm

verdverm commented Feb 15, 2021 •

Copy link
Copy Markdown
Contributor

A possible alternative is to use @attribute markers. There are tradeoffs that we could explore and talk about. They are intended for tools to use (not part of unification) and we'll still probably want the #def's for schema purposes.

@aluzzardi

Copy link
Copy Markdown
Contributor

Personal preference would be for:

import (
  "dagger.cloud/dagger"
)

dagger.#run

It feels a little bit weird to have part of dagger SDK being imported with the natural cue mechanism, under their own namespace (import, then call dagger.#Bla), while some other parts (#dagger.compute) are just there, magically, in the global namespace.

Perhaps something along the lines of:

import (
  "dagger.cloud/dagger"
)

dashboard: {
  url: string

  dagger.#Run & {
    compute: [
      dagger.#FetchContainer & { ... }
    ]
  }
}

dagger.#Component would perhaps even make more sense, like so:

dagger.#Component & {
  run: [
    dagger.#FetchContainer & { ... }
  ]
}

That way we keep it consistent: imports all the way, everything uses the SDK, no magic markers

@shykes
shykes force-pushed the poundrun branch 3 times, most recently from ff9d127 to 67f0c9b Compare March 4, 2021 01:10
@shykes shykes changed the title For discussion: #run instead of #dagger:compute Specify computed values in #compute rather than #dagger.compute Mar 4, 2021
@shykes shykes changed the title Specify computed values in #compute rather than #dagger.compute Attach compute pipelines to a value with #compute rather than #dagger.compute Mar 4, 2021
@shykes

shykes commented Mar 4, 2021

Copy link
Copy Markdown
Contributor Author

Update: I have rebased the PR, and made an important change: I am now proposing #compute instead of #run (see updated PR title and summary).

The advantages I ses for #compute are 1) it’s a smaller change from #dagger.compute, 2) it better describes what actually happens: a buildkit graph is loaded from a declarative config, and solved. Each operation in the graph may or may not be run, depending on cache state and previous config states. So the pipelines may be solved with nothing actually being run, making the #run key misleading. #solve would be the most technically accurate term, but it is buildkit jargon with no obvious meaning for the non initiated. #compute seems like a good synonym for “solve” that is more intuitive to people.

@aluzzardi aluzzardi 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.

Looks good!

@shykes
shykes merged commit 7a77466 into main Mar 7, 2021
@shykes
shykes deleted the poundrun branch March 7, 2021 03:39
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.

4 participants