#(Elixir SDK) Question about chaining

1 messages · Page 1 of 1 (latest)

wind valve
#

If I define my module like this using Elixir SDK (a contrived example):

defmodule Pdfium do
  use Dagger.Mod.Object, name: "Pdfium"

    defn precompile(platform_name: String.t(), abi: String.t(), c_src_dir: Dagger.Directory.t(), pdfium_tag: String.t()) :: Dagger.File.t() do

    # ...returns Dagger.File.t()
  end

  defn test(precompiled: Dagger.File.t(), platform_name: String.t(), abi: String.t()) :: Dagger.Container.t() do
    # ...should be able to accept a file from previous step
  end
end

I cannot seem to chain it like this:

dagger call precompile --abi glibc --c-src-dir c_src --platform-name linux/amd64 --pdfium-tag chromium/6886 test --abi glibc --platform-name linux/amd64

I get an output that contains error - "unknown command "test" for "dagger call precompile":

✔ connect 0.1s
✔ load module 1.8s
✘ parsing command line arguments 0.0s
! unknown command "test" for "dagger call precompile"
│ $ ModuleSource.resolveFromCaller: ModuleSource! 0.0s CACHED
│ $ .resolveDirectoryFromCaller(path: "c_src"): Directory! 0.0s CACHED

Full trace at https://dagger.cloud/gmile/traces/2ab59e7a9099b60b44aa8ce85c389bf8

A new release of dagger is available: v0.15.0 → v0.15.1
To upgrade, see https://docs.dagger.io/install
https://github.com/dagger/dagger/releases/tag/v0.15.1

Even those exporting the file works OK - I suspect export is no different to other functions, except that it's part of Dagger core SDK?

dagger call precompile --abi musl --c-src-dir c_src --platform-name linux/arm64 --pdfium-tag chromium/6886 export --path output/ --allowParentDirPath

What am I doing wrong?

#

@knotty urchin maybe you know?

wind valve
#

Hmm, I think I just realised it's not how this works. I can't simply return a file, and expect another function to pick it up via chaining like this. Gotta give it more thought 🤔

knotty urchin
#

It is requires the precompile function to return Pdfium type which is not support at the moment.

wind valve
#

Good to know, thanks!

function to return Pdfium type
Is this part supported in other SDKs? could you show me? just curious about this

knotty urchin
#

Yep. In Go you can do:

#
package main

import (
        "dagger/pdfium/internal/dagger"
)

type Pdfium struct{}

func (m *Pdfium) Precompile(platformName string, abi string, cSrcDir *dagger.Directory, tag string) *Pdfium {
        // TODO: store precompiled file in `m` object here.
        return m
}

func (m *Pdfium) Test(platformName string, abi string) error {
        return nil
}