#Why does DefaultPath trigger uploading the directory the file is in?

1 messages · Page 1 of 1 (latest)

mossy orbit
#

I found that using DefaultPath causes the whole folder the file is in to be uploaded. This is unexpected and, in my opinion, a bug.

Here is a demonstration. Screenshots demonstrating the expected behavior, without DefaultPath, and unexpected behavior, with it:

GitHub

This repo was created to demonstrate unexpected and undesired behavior in DefaultPath - esafak/dagger-defaultpath

#

The expected and desired behavior, without DefaultPath:

light edge
#

having said that, I agree the UX is confusing when specifying a file when using a Directory. If you have the time to open an issue that'd be much appreciated. Otherwise, I'll try to open that later today 🙏

light edge
#

let me check

#

@mossy orbit k, I see what you're seeing now

#

the upload happens as part of the module initialization. You can filter that as mentioned here: https://docs.dagger.io/configuration/modules/#file-and-directory-filters

Modules can be configured by editing their dagger.json file. The configuration in there contains all module metadata - from the name of the module and the SDK it uses, to the dependencies it requires. An initial configuration is automatically generated when using dagger init or dagger develop for the first time, and is kept up-to-date with dagge...

mossy orbit
#

but it does not happen without the Annotated[DefaultPath], plus Ignore filters don't work with Files (I tried). Instead of this what should I do?

file: Annotated[File, DefaultPath("big_folder/README.txt")]

light edge
#

@mossy orbit so, I see the whole folder gets uploaded in your example regardless of which function I use ^

#

that's part of the behavior I was mentioning before

#

if you check the include pattern that uploads everything in the project directory

#

as part of the module initialization phase

#

if I add an exclude property in the dagger.json that gets me what I need

  "name": "dagger-defaultpath",
  "engineVersion": "v0.18.16",
  "sdk": {
    "source": "python"
  },
  "exclude": [
    "big_folder/large_file.txt"
  ]
}
#

in my case I created a large_file.txt file inside the big_folder path

#

and dagger ignores that file basically

mossy orbit
#

In my case I don't want to ignore it; I want to select ONLY it, without pulling in its directory. I think anybody would expect that when using File.

light edge
#

when you do have a source folder, we only upload that as part of your module init

#

if you do dagger init --sdk python --soruce .dagger, that should avoid uploading unnecessary stuff

light edge
mossy orbit
#

dagger is actually in a subdirectory ci/ in the real case. Let me try moving it in the example.

light edge
mossy orbit
cerulean oyster
#

so basically the desired behavior is instead of Host.Directory(dir).File(file) we should either do Host.File(file) or if we absolutely must load the directory first, Host.Directory(dir, include:file).File(file)

light edge
#

and never got to validate the e2e function call 🙏