Skip to content

Commit 1b58dd1

Browse files
authored
Merge branch 'main' into test_cache_revival
2 parents 2bead9c + 491e616 commit 1b58dd1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

codeflash/code_utils/config_parser.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import tomlkit
77

8+
PYPROJECT_TOML_CACHE = {}
89
ALL_CONFIG_FILES = {} # map path to closest config file
910

1011

@@ -21,10 +22,15 @@ def find_pyproject_toml(config_file: Path | None = None) -> Path:
2122
raise ValueError(msg)
2223
return config_file
2324
dir_path = Path.cwd()
24-
25+
cur_path = dir_path
26+
# see if it was encountered before in search
27+
if cur_path in PYPROJECT_TOML_CACHE:
28+
return PYPROJECT_TOML_CACHE[cur_path]
29+
# map current path to closest file
2530
while dir_path != dir_path.parent:
2631
config_file = dir_path / "pyproject.toml"
2732
if config_file.exists():
33+
PYPROJECT_TOML_CACHE[cur_path] = config_file
2834
return config_file
2935
# Search for pyproject.toml in the parent directories
3036
dir_path = dir_path.parent

0 commit comments

Comments
 (0)