#Is this expected from using DefaultPath / Context directory ?

1 messages · Page 1 of 1 (latest)

alpine mortar
#

I have this code (v0.13.3).

@object_type
class Pipeline:

    @function
    async def run(self, source: Annotated[dagger.Directory, DefaultPath(".")]
        )  -> list[str]: 
            return await source.entries()

Running it by passing --source=. as argument returns the entries in the current project as expected.

dagger call -m ../pipeline run --source=.

Running it without any arguments returns the entries of the dagger module - but I would have expected to be same results. Any reasons for this design choice? I'm not sure the reason to access the content of the module.

dagger call -m ../pipeline run 

I've been reading through the docs at https://docs.dagger.io/manuals/developer/functions/#directories-and-files.

Dagger Functions are regular code, written in a supported programming language, and running in containers. Dagger Functions let you encapsulate common operations or workflows into discrete units with clear inputs and outputs.

plucky crescent
#

yes this is by design. the default path is relative to the module or if you start with a slash, to the context repository. This makes modules more reproducible - for example dagger call -m github.com/dagger/dagger dev will give you and me the same dev build of dagger

alpine mortar
#

I see. Is there a way to define a default path in the context of the caller? Most of the time I would default --source to '.'

alpine mortar