Skip to content

Commit 3c650da

Browse files
committed
align default cache and config directories under TIDY3D_BASE_DIR if set
1 parent feb0ba4 commit 3c650da

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

tests/config/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def mock_config_dir(tmp_path, monkeypatch):
4242

4343
base_dir = tmp_path / "config_home"
4444
monkeypatch.setenv("TIDY3D_BASE_DIR", str(base_dir))
45-
return base_dir / ".tidy3d"
45+
return base_dir / "config"
4646

4747

4848
@pytest.fixture

tests/test_cli/test_migrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def temp_config_dir(monkeypatch, tmp_path) -> Path:
1818
original_base = os.environ.get("TIDY3D_BASE_DIR")
1919
monkeypatch.setenv("TIDY3D_BASE_DIR", str(tmp_path))
2020
reload_config(profile="default")
21-
config_dir = Path(tmp_path) / ".tidy3d"
21+
config_dir = Path(tmp_path) / "config"
2222
config_dir.mkdir(parents=True, exist_ok=True)
2323
yield config_dir
2424
if original_base is None:

tidy3d/config/loader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ def resolve_config_directory() -> Path:
247247

248248
base_override = os.getenv("TIDY3D_BASE_DIR")
249249
if base_override:
250-
path = Path(base_override).expanduser().resolve() / ".tidy3d"
250+
base_path = Path(base_override).expanduser().resolve()
251+
path = base_path / "config"
251252
if _is_writable(path.parent):
252253
return path
253254
log.warning(
@@ -281,7 +282,7 @@ def _xdg_config_home() -> Path:
281282
def _temporary_config_dir() -> Path:
282283
base = Path(tempfile.gettempdir()) / "tidy3d"
283284
base.mkdir(mode=0o700, exist_ok=True)
284-
return base / ".tidy3d"
285+
return base / "config"
285286

286287

287288
def _is_writable(path: Path) -> bool:

tidy3d/config/sections.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ def _default_cache_directory() -> Path:
391391

392392
base_override = os.getenv("TIDY3D_BASE_DIR")
393393
if base_override:
394-
base = Path(base_override).expanduser().resolve() / ".cache"
394+
base = Path(base_override).expanduser().resolve()
395+
return (base / "cache" / "simulations").resolve()
395396
else:
396397
xdg_cache = os.getenv("XDG_CACHE_HOME")
397398
if xdg_cache:

0 commit comments

Comments
 (0)