Skip to content

Commit

Permalink
bug fixes in persistentcache location init
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 26, 2023
1 parent 5376a86 commit 96dcc48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pydra/utils/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def location_converter(path: ty.Union[Path, str, None]) -> Path:
if path is None:
path = PersistentCache.location_default()
path = Path(path)
path.mkdir(parents=True, exist_ok=True)
if not path.exists():
path.mkdir(parents=True)
return path


Expand Down
6 changes: 2 additions & 4 deletions pydra/utils/tests/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,9 @@ def test_persistent_hash_cache(cache_path, text_file):
assert hash_object(text_file, persistent_cache=cache_path) == modified_hash

# Test that changes to the text file result in new hash
time.sleep(2) # Need to ensure that the mtimes will be different
text_file.fspath.write_text("bar")
# Ensure that the mtime will be incremented by mocking time.time
with mock.patch("time.time") as t:
t.return_value = time.time() + 10
assert hash_object(text_file, persistent_cache=cache_path) != modified_hash
assert hash_object(text_file, persistent_cache=cache_path) != modified_hash
assert len(list(cache_path.iterdir())) == 2


Expand Down

0 comments on commit 96dcc48

Please sign in to comment.