#I’m having a hard time understanding DAG building

1 messages · Page 1 of 1 (latest)

marble silo
#

Hi!

I just started working with Dagger today.

I am calling other functions from a top-level “orchestrating” function. My intuition tells me lower-level functions should be executed concurrently.

But it doesn’t matter if I use anyio.create_task_group or asyncio.gather - my Dagger function is always executed sequentially, even if there are independent paths to evaluate inside it.

Also, I noticed Dagger is squashing all the functions into a single function call. Basically, my lower-level functions lose their Dagger context and just become normal Python async functions. Is this supposed to work this way? Is this a limitation of the local executor?

~~I couldn’t find find examples for building non-sequential pipelines. I hope that’s supported 🙂

Example code (simplified):

@object_type
class MyDaggerModule:
    @function
    async def build_uv_project(
        self,
        source: Annotated[dagger.Directory, DefaultPath("."), IGNORE],
       params: …,
    ) -> Container:
        """Builds a uv project with docker"""
        return await build_uv_project(
            source=source,
            params=params
        )

    @function
    async def build_all_uv_projects(self, root_dir: RootDir) -> list[Container]:
        """Build all the uv projects in the monorepo"""
        containers = []

        for project, config in PROJECTS.items():
            containers.append(
                # I would like to defer this await for later 
                # so that multiple containers are built in parallel
                await build_uv_project(
                    source=root_dir.directory(config["path"]),
params=config[“params”]
                )
            )

        return containers

I’m trying to make the second function to build all the containers in parallel. I tried running asyncio.gather on them instead. I’ve also tried calling the other function directly (self.build_uv_project).

Thanks for the help in advance!
Daniel~~