#Unknown command "publish" for "dagger call"

1 messages · Page 1 of 1 (latest)

sick furnace
#

I'm just starting with dagger and was trying the first example here:
https://docs.dagger.io/quickstart/#write-custom-functions

With the Python example:

async def publish(self) -> str:
    return await (
        dag.container()
        .from_("alpine:latest")
        .with_new_file("/hi.txt", "Hello from Dagger!")
        .with_entrypoint(["cat", "/hi.txt"])
        .publish("ttl.sh/hello")
    )```

I put this into a simple `main.py` file which I made executable (although I get the same error without).

At first when running the command `dagger call build` I got `module not found` but after adding a dagger.json
```{
    "name": "publish",
    "engineVersion": "v0.18.12"
}```

I get the error
`Unknown command "publish" for "dagger call"`

I've tried turning the function into a full module by adding
```@object_type
class Publish:```

With the same result. I've also tried putting it in `src/publish/` with an `__init.py__` but that gives other errors and based on the example it looks like this should work without all that.

dagger version is v0.18.12 and the Python SDK is installed. Any help is appreciated, Thank you!

Welcome to Dagger, a general-purpose composition engine for containerized workflows.

grave sleet
#

?

sick furnace
#

I get

> connect 0.2s
> load module: . 0.3s

Name Description```
#

with nothing under the Name or Description.

I should mention I'm on MacOS with dagger installed via brew. And I'm using python 3.13.5 in a venv that I made sure was active.

grave sleet
#

The func annotation is imported from the dagger package

sick furnace
#

I tried using func but got the same results. If I just run dagger call with no arguments it might load ok, but nothing happens:

> connect 0.2s
> load module: . 0.3s
- parsing command line arguments 0.0s

- publish: Publish! 0.0s```
grave sleet
grave sleet
sick furnace
#

Using func unfortunately doesn't change the results. Is there some additional debugging that I can do to see why it is reading the module but not finding the function?

sick furnace
#

I was able to get a working module by starting a new directory and first running dagger init --sdk=python then adding the publish function to it. Now I can run dagger call publish successfully and dagger functions returns the expected results. Thanks for the help! The documentation didn't mention this step in the cookbook or quick start so I didn't realize it was necessary. Looks like it is mentioned on other pages but I thought, a simple "main" and dagger.json was all that was needed to get started.

grave sleet