#Is there a way to call dagger functions programatically?

1 messages · Page 1 of 1 (latest)

nimble flame
#

Let's say that i first developed my dagger function with it's dependencies and so on.

Later on I want to create a website that reuses that logic in the backend, is there a way to do something like:

import dagger
dagger.call(...)
#

I would like to avoid using exec alike functions 😅

rain basalt
nimble flame
rain basalt
#

Yeah, working with lower level GraphQL via the client sort of side-steps having functions/ using the dag object and being able to use their abstractions, which one would imagine should also be executable via consuming code. I still am not sure why this can't work. My main problem is, I'm new to Go too. So, I am uncertain of how to mix contexts between applications and if that is even possible or if that is even what is needed. LOL!

merry root
nimble flame
#

What I would like to do is:

  • Create a dagger module Foo made in Go that depends on a different Go module Bar
  • Create a website backend in typescript that can reuse this go modules so i have both the website and the CLI
#

The workaround atm is not possible because it seems like the graphql class is not available neither in python and ts

#

If it was possible doing grapqhl requests manually would not be that bad

#

I mean otherwise I just simply can do it the "old fashion" way with different microservices communicating with rpc for instance, just wondering if this was possible or planned at all

lone kindle
#

you can query the graphql directly

#

you just won't have generated client bindings

#

just exec dagger query -m MODULE and write the graphql query to its standard input

#

you will get the json-formatted output

#

Example:

dagger query -m github.com/shykes/daggerverse/hello  <<EOF
{
 hello {
  hello(greeting: "bonjour", name: "monde")
 }
}
EOF

Output should be:

{
    "hello": {
        "hello": "bonjour, monde!"
    }
}
#

You'll have to deal with IDs yourself, too

dreamy quartz
#

cc @austere tapir not sure if there's a less hacky way to get access to the underlying graphql client 🤔

nimble flame
austere tapir
#

No because I do not expose it but I can open a PR to add this change to our API, it's not a big deal.

#

Like await dag.getGQLClient() that returns you a connected client, this could work but I also need to take care of the closing

tender lava
nimble flame
#

@austere tapir is there any issue about that so i can keep track of that feature? 👀

austere tapir
#

I'm going to create it right now

nimble flame
#

ty very much ❤️

dusky wing
#

Coming back around to this thread. I see a GitHub issue to implement this in TypeScript but nothing for Python and Go. Is that because this is already supported the Go and Python SDKs or because we want to add the feature to TS? I want to make sure we're not causing feature drift between the SDKs. Also, is that the right way to implement it? Should we have a more generic method that is available to all the SDKs, such as the one Lev linked earlier?

cc @velvet wind @tender lava @trail lotus

tender lava
#

Go has it already.

austere tapir
#

/cc @tender lava @dreamy quartz

nimble flame
paper condor
#

Does this make it possible to call functions from the older dagger run ... style code?

dreamy quartz
paper condor
rain basalt
#

I believe, (and I'd love to be corrected, because I'm still not 100% clear if what I'm about to say is true), that this design discussion is about allowing programmatic control of Dagger from another program. Again, please anyone do correct me, if I am wrong. 🙂

GitHub

Problem There are two types of Dagger modules: those that are standalone software projects, and those that exist in the context of another software project. Let's call those standalone modules ...

paper condor
#

That's my understanding from skimming a bit of it the other day anyhow

rain basalt
#

Yeah, when they switched to the directory bit, I got even more confused. I thought the "context" being mentioned at the start of the discussion was about Go application context sharing. But, I'm very new to Go too, so I wasn't certain. And, I'm still confused. 😛

#

As I see how things work currently, I must run exec commands in my application, in order to run the Dagger CLI to run Dagger Modules/ functions and capture the results, parse them to determine success or failure and move on from there. Again, just learning, so if that sounds silly, please do correct me. 🙂

tender lava
#

So, it's unrelated to the topic in this thread as nothing changes from that POV with this proposal.