E531 Add support for env variable `TACH_CACHE_DIR` by luukvhoudt · Pull Request #775 · tach-org/tach · GitHub
[go: up one dir, main page]

Skip to content

Add support for env variable TACH_CACHE_DIR#775

Open
luukvhoudt wants to merge 1 commit intotach-org:mainfrom
luukvhoudt:introduce-tach-cache-dir-env-var
Open

Add support for env variable TACH_CACHE_DIR#775
luukvhoudt wants to merge 1 commit intotach-org:mainfrom
luukvhoudt:introduce-tach-cache-dir-env-var

Conversation

@luukvhoudt
Copy link

Fallback is .tach in the project root. If the value of TACH_CACHE_DIR is a relative path, then it is relative to the project root.

Copy link
Collaborator
@DetachHead DetachHead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution

## Cache storage

The computation cache exists within the `.tach` directory in your project root. The directory is managed by Tach, and your cached results are stored on-disk on each machine where tasks are run.
The computation cache exists within the directory defined by the `TACH_CACHE_DIR` environment variable (default is `.tach`). The directory is managed by Tach, and your cached results are stored on-disk on each machine where tasks are run.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The computation cache exists within the directory defined by the `TACH_CACHE_DIR` environment variable (default is `.tach`). The directory is managed by Tach, and your cached results are stored on-disk on each machine where tasks are run.
The computation cache exists within the directory defined by the `TACH_CACHE_DIR` environment variable (default is `.tach` in your project root). The directory is managed by Tach, and your cached results are stored on-disk on each machine where tasks are run.

Comment on lines +17 to +18
path_is_not_absolute_re = compile(r'^(?![a-zA-Z]:[\\/]|\\\\|/|~[/\\])') if os_name == 'nt' else compile(r'^[^/~]')
if match(path_is_not_absolute_re, env_value):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use is_absolute from pathlib.Path here

@luukvhoudt luukvhoudt force-pushed the introduce-tach-cache-dir-env-var branch from 5e8b1fa to f54a1ab Compare December 4, 2025 10:38
@luukvhoudt luukvhoudt requested a review from DetachHead December 4, 2025 10:39
Fallback is `.tach` in the project root. If the value of `TACH_CACHE_DIR` is a relative path, then it is relative to the project root.
@luukvhoudt luukvhoudt force-pushed the introduce-tach-cache-dir-env-var branch from f54a1ab to b0e4aab Compare December 4, 2025 10:44
Comment on lines +52 to +57
.join(
match env::var(ENV_KEY_CACHE_DIR) {
Ok(env_value) => env_value,
Err() => DEFAULT_CACHE_DIR,
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can use unwrap_or_else here

Suggested change
.join(
match env::var(ENV_KEY_CACHE_DIR) {
Ok(env_value) => env_value,
Err() => DEFAULT_CACHE_DIR,
}
)
.join(
env::var(ENV_KEY_CACHE_DIR)
.unwrap_or_else(|_| DEFAULT_CACHE_DIR),
)

## Cache storage

The computation cache exists within the `.tach` directory in your project root. The directory is managed by Tach, and your cached results are stored on-disk on each machine where tasks are run.
The computation cache exists within the directory defined by the `TACH_CACHE_DIR` environment variable (default is `.tach` in your project root). The directory is managed by Tach, and your cached results are stored on-disk on each machine where tasks are run.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about this some more, would it be better to specify the cache dir in the config file and/or as a CLI argument? just wondering since i don't think tach has anything else configured via environment variables.

do you mind sharing a bit more info about your use case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I can recall the exact use case because it has been a while since I've worked on the project that uses tach. I guess it had something to do that I wanted to do with docker.

Copy link
Collaborator
@DetachHead DetachHead Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case i think i'll just leave this PR open for now and wait to see if anybody else has a use case for it

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

0