#Various Errors With Dagger Functions Getting Started

1 messages · Page 1 of 1 (latest)

lavish orbit
#

I tried following the instructions for the python-sdk on this page https://docs.dagger.io/quickstart/428201/custom-function

but I get the following errors:

  1. I expected dagger/src/main.py to be generated on the call to dagger develop but it was not.
  2. I created that file myself, but the command to try to the build module also didn't work as expected: dagger call build-and-publish \ --build-src=. \ --build-args="-C","./hello"

Instead producing the error

✘ initialize 3.3s
  ✔ ModuleSource.asModule: Module! 1.4s
  ✘ Module.initialize: Module! 0.0s
Error: input: module.withSource.initialize module name and SDK must be set

Write your first function

#

I can confirm that a dagger engine is running with the version that matches the cli

#

It also doesn't work with the Go sdk either. (I tried deleting everything and starting over but no luck).

#

Ok, if I run dagger init first, then I at least get a source directory with the gosdk, but then I get the following compile error:

❯ dagger -m . functions
✘ initialize 1.5s
  ✔ ModuleSource.asModule: Module! 0.7s
  ✘ Module.initialize: Module! 0.7s
    ✘ exec go build -o /runtime . 0.7s
    ┃ # dagger/windows                                                                                                                                      
    ┃ ./main.go:17:3: dag.Golang undefined (type *dagger.Client has no field or method Golang)                                                              
    ┃ ./main.go:18:18: undefined: GolangBuildContainerOpts                                                                                                  
Error: input: module.withSource.initialize failed to initialize module: failed to call module "windows" to get functions: call constructor: process "go build -o /runtime ." did not complete successfully: exit code: 1

which I assume is a code gen error.

#

Various Errors With Dagger Functions Getting Started

#

Ok, here another issue: (back on the python sdk this time)

The example code that I copied pasted uses a class Example , but the directory I created the module in was called Windows so I renamed the class from the example to match that. Maybe there should be a flag used to name the module that is used in the getting started guide to ensure this matches?

#

Once you fix that you have another error:

✘ Windows.buildAndPublish(
    buildArgs: ["-C", "./hello"]
    buildSrc: ✔ Host.directory(path: "/home/runderwood/git/robertu94_daggerverse/windows"): Directory! 0.0s
  ): String! 1.8s
  ✘ exec /runtime 1.8s
  ┃ ╭─ Error ──────────────────────────────────────────────────────────────────────╮                                                                        
  ┃ │ Function execution error: 'Client' object has no attribute 'golang'          │                                                                        
  ┃ ╰──────────────────────────────────────────────────────────────────────────────╯                                                                        

Error: response from query: input: windows.buildAndPublish call function "build_and_publish": process "/runtime" did not complete successfully: exit code: 1

Stderr:
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Function execution error: 'Client' object has no attribute 'golang'          │
╰──────────────────────────────────────────────────────────────────────────────╯
#

Which I assume is the same error that I saw last time with golang's sdk. Is there a dependency or api change that I am missing?

#

This leaves me with the impression that the code examples in the docs are not ci-tested which may be a useful improvement.

#

Ah, I think there is a missing dependency on: dagger install github.com/kpenfound/dagger-modules/golang@8d662e001caf8c16253226d0d456f2f0f374f009

#

Maybe not, after installing that, I get the error:

  ┃ ╭─ Error ──────────────────────────────────────────────────────────────────────╮                                                                        
  ┃ │ Function execution error: call function "BuildContainer": process "/runtime" │                                                                        
  ┃ │ did not complete successfully: exit code: 2                                  │                                                                        
  ┃ │ Stdout:                                                                      │                                                                        
  ┃ │ json: error calling MarshalJSON for type *dagger.Container: input:           │                                                                        
  ┃ │ container.from.withMountedCache.withMountedCache.withDirectory.withWorkdir.w │                                                                        
  ┃ │ ithEnvVariable.withEnvVariable.withExec.directory process "go build -C       │                                                                        
  ┃ │ ./hello -o /src/build-output/" did not complete successfully: exit code: 1   │                                                                        
  ┃ │ Stderr:                                                                      │                                                                        
  ┃ │ go: chdir ./hello: no such file or directory                                 │                                                                        
  ┃ │ Stderr:                                                                      │                                                                        
#

Which I assume is because the API changed on the module or Golang refered to something else with a very similar API.

#

New issue: there isn't a good way to "uninstall" a dagger module. It seems that you can end up with a bunch of code gen errors if you try to switch between two modules of the same name.

#

Ok. Deleting everything and starting over with the Python SDK.

dagger init
dagger develop --sdk=python
dagger install github.com/shykes/daggerverse/wolfi@v0.1.2
dagger install github.com/quartz-technology/daggerverse/golang@8812a090cd9096df1e4c3d1d9402b36b091304cb

I still can't get quartz-technologies golang package to install. Maybe it uses an old API, but the error here isn't enough for me to figure it out

● ModuleSource.asModule: Module! 1.2s

Error: failed to generate code: input: moduleSource.withContextDirectory.withDependencies.asModule failed to create module: failed to update module dependencies: failed to initialize dependency modules: failed to initialize dependency module: failed to create module: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module-context /src --module-name golang --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1

Stderr:
Error: generate code: template: alias.go.tmpl:56:3: executing "_dagger.gen.go/alias.go.tmpl" at <ModuleMainSrc>: error calling ModuleMainSrc: failed to parse method Build: failed to parse type reference: invalid type: invalid type
#

There should be some indication on the daggerverse site of what is expected to "just work" or "has been tested with" a particular dagger version.

glossy lagoon
#

you can use dagger init --sdk instead of dagger develop for this

lavish orbit
#

Thanks, but I was trying to follow what was in the docs (at least at first).

#

I still can't figure out where dag.Golang() mentioned in the example code is supposed to come from. Any suggestions?

warm shadow
lavish orbit
#

Thanks @warm shadow I jumped to the end b/c I was familier with the Zenith work and wanted to try writing a function

warm shadow
warm shadow
lavish orbit
#

Yep 🙂 ahead of yo by about 3 minutes.

warm shadow
#

Great, please comment here if you're still seeing the same or other problems... and thank you for the feedback!

lavish orbit
#

In the python sdk, I still hit the issues I described above regarding the class name since I named the repo differently on my filesystem (but that's an easy fix).

#

Other than that one small error, everything looks like it worked.

#

Also I think this has been said before, but 4-6 seconds to call dagger functions is really slow.

#

It's closer to 30 on the first call (but that's not a problem with the tutorial per-se)

warm shadow
lavish orbit
#

Yes I do, or maybe make it the copy pastable part, and mention that it can be omitted by default

#

Likewise you could have a default closed “shelf” element with the 3 commands you actually need from the previous page so the tutorial could be more independent

warm shadow