#Directory filters on constructor arguments

1 messages · Page 1 of 1 (latest)

left galleon
#

Is it supported to use filters on directories passed to a module as a constructor argument, rather than a function argument? It seems that if I do the following with the python SDK:

@object_type
class MyMod:
    source: Annotated[dagger.Directory, Ignore(["*.bin"])]
    @function
    async def test(self) -> str:
        ctr = dag.container().from_("alpine").with_mounted_directory("/src", self.source).with_exec(["ls", "/src"])
        return await ctr.stdout()

And then dagger call --source . test with some-huge-binary.bin in the directory, dagger seems to hang forever at "parsing command line arguments", implying it isn't skipping said file. Meanwhile if I run:

@object_type
class MyMod:
    @function
    async def test(self, source: Annotated[dagger.Directory, Ignore(["*.bin"])]) -> str:
       ctr = dag.container().from_("alpine").with_mounted_directory("/src", source).with_exec(["ls", "/src"])
       return await ctr.stdout()

with dagger call test --source ., it runs very quickly and shows the filtered directory has been uploaded.

Is this working as intended? Or am I not doing it correctly?

ornate reef
#

@left galleon you need to implement an explicit constructor, and annotate the argument to that with ignore. I don't think annotating the class field the way you're doing it will work

#

(only 99% sure because I'm less familiar with the Python SDK)