Skip to content

Commit

Permalink
fix[next]: use current working directory as default cache folder root (
Browse files Browse the repository at this point in the history
…#1744)

Change the root folder of the gt4py cache directory from the system temp
folder to the current working directory, which is more visible and also
avoids polluting shared filesystems in hpc clusters.

---------

Co-authored-by: Hannes Vogt <[email protected]>
  • Loading branch information
egparedes and havogt authored Nov 29, 2024
1 parent 791f67d commit 04513ba
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/gt4py/next/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import enum
import os
import pathlib
import tempfile
from typing import Final


Expand Down Expand Up @@ -51,37 +50,34 @@ def env_flag_to_bool(name: str, default: bool) -> bool:
)


_PREFIX: Final[str] = "GT4PY"

#: Master debug flag
#: Changes defaults for all the other options to be as helpful for debugging as possible.
#: Does not override values set in environment variables.
DEBUG: Final[bool] = env_flag_to_bool(f"{_PREFIX}_DEBUG", default=False)
DEBUG: Final[bool] = env_flag_to_bool("GT4PY_DEBUG", default=False)


#: Verbose flag for DSL compilation errors
VERBOSE_EXCEPTIONS: bool = env_flag_to_bool(
f"{_PREFIX}_VERBOSE_EXCEPTIONS", default=True if DEBUG else False
"GT4PY_VERBOSE_EXCEPTIONS", default=True if DEBUG else False
)


#: Where generated code projects should be persisted.
#: Only active if BUILD_CACHE_LIFETIME is set to PERSISTENT
BUILD_CACHE_DIR: pathlib.Path = (
pathlib.Path(os.environ.get(f"{_PREFIX}_BUILD_CACHE_DIR", tempfile.gettempdir()))
/ "gt4py_cache"
pathlib.Path(os.environ.get("GT4PY_BUILD_CACHE_DIR", pathlib.Path.cwd())) / ".gt4py_cache"
)


#: Whether generated code projects should be kept around between runs.
#: - SESSION: generated code projects get destroyed when the interpreter shuts down
#: - PERSISTENT: generated code projects are written to BUILD_CACHE_DIR and persist between runs
BUILD_CACHE_LIFETIME: BuildCacheLifetime = BuildCacheLifetime[
os.environ.get(f"{_PREFIX}_BUILD_CACHE_LIFETIME", "persistent" if DEBUG else "session").upper()
os.environ.get("GT4PY_BUILD_CACHE_LIFETIME", "persistent" if DEBUG else "session").upper()
]

#: Build type to be used when CMake is used to compile generated code.
#: Might have no effect when CMake is not used as part of the toolchain.
CMAKE_BUILD_TYPE: CMakeBuildType = CMakeBuildType[
os.environ.get(f"{_PREFIX}_CMAKE_BUILD_TYPE", "debug" if DEBUG else "release").upper()
os.environ.get("GT4PY_CMAKE_BUILD_TYPE", "debug" if DEBUG else "release").upper()
]

0 comments on commit 04513ba

Please sign in to comment.