Skip to content

Commit ccf3873

Browse files
authored
Invalidate cache to check whether remote files exist. (#591)
1 parent 5df5fa1 commit ccf3873

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/source/changes.md

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
3030
- {pull}`587` improves typing of `capture.py`.
3131
- {pull}`588` resets class variables of `ExecutionReport` and `Traceback`.
3232
- {pull}`590` fixes an error introduced in {pull}`588`.
33+
- {pull}`591` invalidates the cache of fsspec when checking whether a remote file
34+
exists. Otherwise, a remote file might be reported as missing although it was just
35+
created. See https://github.com/fsspec/s3fs/issues/851 for more info.
3336

3437
## 0.4.6 - 2024-03-13
3538

src/_pytask/nodes.py

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from attrs import define
1616
from attrs import field
17+
from upath import UPath
1718
from upath._stat import UPathStatResult
1819

1920
from _pytask._hashlib import hash_value
@@ -376,6 +377,12 @@ def _get_state(path: Path) -> str | None:
376377
A simple function to handle local and remote files.
377378
378379
"""
380+
# Invalidate the cache of the path if it is a UPath because it might have changed in
381+
# a different process with pytask-parallel and the main process does not know about
382+
# it and relies on the cache.
383+
if isinstance(path, UPath):
384+
path.fs.invalidate_cache()
385+
379386
try:
380387
stat = path.stat()
381388
except FileNotFoundError:

0 commit comments

Comments
 (0)