Skip to content

Commit 7d57ed7

Browse files
authored
Fix get_model_dir (#3009)
Fix parenthesis error and double version in path.
1 parent cf9d349 commit 7d57ed7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

python/sdist/amici/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def _imported_from_setup() -> bool:
7979
def get_model_root_dir() -> Path:
8080
"""Get the default root directory for AMICI models.
8181
82+
Get the default root directory for AMICI models for the current AMICI
83+
version.
84+
8285
:return:
8386
The model root directory.
8487
This defaults to `{base_dir}/{amici_version}`.
@@ -116,11 +119,11 @@ def get_model_dir(model_id: str | None = None, jax: bool = False) -> Path:
116119
if model_id is None:
117120
import tempfile
118121

119-
return Path(
120-
tempfile.mkdtemp(dir=base_dir / __version__), suffix=suffix
121-
)
122+
# mkdtemp requires the parent directory to exist
123+
base_dir.mkdir(parents=True, exist_ok=True)
124+
return Path(tempfile.mkdtemp(dir=base_dir, suffix=suffix))
122125

123-
return base_dir / __version__ / (model_id + suffix)
126+
return base_dir / (model_id + suffix)
124127

125128

126129
# Initialize AMICI paths

0 commit comments

Comments
 (0)