Skip to content

Allow specifying custom tempdir for files.download#1366

Merged
Fizzadar merged 2 commits intopyinfra-dev:3.xfrom
scy:download-tempdir
Jun 9, 2025
Merged

Allow specifying custom tempdir for files.download#1366
Fizzadar merged 2 commits intopyinfra-dev:3.xfrom
scy:download-tempdir

Conversation

@scy
Copy link
Contributor

@scy scy commented Jun 2, 2025

This introduces a new argument to the files.download operation: temp_dir, which allows the user to specify a custom temporary directory for downloading into.

I know that TEMP_DIR exists as an (undocumented) config option, but since Host._get_temp_directory is memoized, it's not feasible to set this option only for certain operations.

My use case is downloading very large files (> 100 GB) into specific volumes on the server, which are backed by different filesystems and have some constraints regarding free space. The default of downloading everything into /tmp (or whatever) doesn't work because it would fill up the root partition before the download even finishes, but setting TEMP_DIR to different directories throughout a single deploy is also not really possible without resorting to hacks, afaics.

To allow customizing the temporary directory, Host.get_temp_filename also gained a (keyword-only, optional) new argument temp_directory.

@scy
Copy link
Contributor Author

scy commented Jun 2, 2025

The failing tests are unrelated to my changes.

@Fizzadar Fizzadar force-pushed the download-tempdir branch from c43638d to ed8550d Compare June 6, 2025 08:33
@Fizzadar Fizzadar force-pushed the download-tempdir branch from ed8550d to 6803928 Compare June 8, 2025 12:29
@Fizzadar Fizzadar merged commit b87c780 into pyinfra-dev:3.x Jun 9, 2025
78 of 92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants