#publish container failing

1 messages · Page 1 of 1 (latest)

small mason
#

I'm trying to use the publish with the python sdk with this

import os
import sys
import anyio
import dagger


async def build():
    with dagger.Connection(dagger.Config(log_output=sys.stdout)) as client:

        dir = client.host().directory(
            ".", include=["src", "Cargo*", "Dockerfile"])

        build = client.container().build(dir, "Dockerfile")

        # image_ref = os.getenv("IMAGE_REF")
        # if image_ref is not None:
        #     str = await build.publish(image_ref)
        #     return

        # image_registry = os.getenv("IMAGE_REGISTRY")
        # image_name = os.getenv("IMAGE_NAME")
        # image_tag = os.getenv("IMAGE_TAG")
        # if image_name is not None and image_registry is not None and image_tag is not None:
        #     await build.publish(image_ref.format(
        #         "%s/%s:%s", image_registry, image_name, image_tag))
        #     return

        str = await build.publish("ghcr.io/laupse/ecowatt-twitter-bot:main")

        print("Image has not been published check if this is the behavior you were looking for")

if __name__ == "__main__":
    anyio.run(build)

But it ends with this error

TypeError: Cannot convert value to AST: <Directory instance>.

Full stack trace is joined

elfin kettle
#

Since the error complains about a Directory instance, I need to ask you what version of dagger-io you have installed because at one point you needed to pass an id instead to container().build().

small mason
#

Sure ! This is the version installed dagger-io 0.1.1

#

Oh thats it. Tough i had the right version (juste like the las go sdk i used)

small mason
#

Also i used to trigger the build of the image without pushing by passing an empty string to the publish method in go. But it seems that is not working in python

elfin kettle
small mason
#

Yes exactly !

elfin kettle
#

Do you have a small repro? Go SDK and Python SDK use the same API underneath, so it should work the same.

small mason
#

Aactually i looked at the error but it seems more a issue without timeout during my build. I guess between the client and the dagger engine. Do you know something any configurable timeout ?
Here the error : raise mapped_exc(message) from exc httpx.ReadTimeout: timed out

elfin kettle
#

You want dagger.Config(execute_timeout=xxx). Integer in seconds, defaults to 5 mins.

#

Can you confirm that it times out after 5 mins?

small mason
#

The whole command lasted 6m 4.185s⠀befor timeout

#

And yes second times it lasted 5min and 7sec

elfin kettle
#

Ok, did it fix it?

#

I wonder if 5 min is too low a default for dagger. Maybe 30 min is better.

small mason
#

i put at 10 it didn't work but it is also because it is a rust application it takes too much time to compile

#

i'lll try optimizing my build and ultimately set the timeout to 30

jaunty trellis
#

@small mason : Did that work?

small mason
#

To locally build, i now use export to create the image archive
And i did optimize the build, but still had to set a 10 minute timeout