Skip to content

Commit 61c7216

Browse files
committed
session temp dir
1 parent 11ed7a8 commit 61c7216

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Fix bug in `compas_session.session.Session.record` due to unwritable tempdir.
15+
1416
### Removed
1517

1618

src/compas_session/session.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ def __init__(
7676
self.depth = 53
7777
self.history = []
7878
self.timestamp = int(datetime.datetime.timestamp(datetime.datetime.now()))
79-
self.basedir = pathlib.Path(basedir or os.getcwd())
79+
self.basedir = basedir
8080
self.split_files = split_files
8181
self._is_inited = True
8282

8383
@property
8484
def tempdir(self):
85-
tempdir = pathlib.Path(self.basedir) / "temp"
86-
tempdir.mkdir(exist_ok=True)
87-
return tempdir
85+
if self.basedir:
86+
tempdir = pathlib.Path(self.basedir) / "temp"
87+
tempdir.mkdir(exist_ok=True)
88+
return tempdir
8889

8990
def __contains__(self, key):
9091
return key in self.data
@@ -229,7 +230,7 @@ def load(self, filepath: Optional[Union[str, pathlib.Path]] = None, reset: bool
229230
if not filepath:
230231
if not self.basedir:
231232
raise ValueError("No base directory is set and no filepath is provided.")
232-
filepath = self.basedir / f"{self.name}.json"
233+
filepath = pathlib.Path(self.basedir) / f"{self.name}.json"
233234

234235
if reset:
235236
self.reset()
@@ -254,7 +255,7 @@ def dump(self, filepath: Optional[Union[str, pathlib.Path]] = None) -> None:
254255
if not filepath:
255256
if not self.basedir:
256257
raise ValueError("No base directory is set and no filepath is provided.")
257-
filepath = self.basedir / f"{self.name}.json"
258+
filepath = pathlib.Path(self.basedir) / f"{self.name}.json"
258259

259260
compas.json_dump(
260261
{

0 commit comments

Comments
 (0)