Skip to content

Commit

Permalink
call cache: ignore URIs when checking File coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Nov 1, 2020
1 parent 7c1a466 commit a1556f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 11 additions & 3 deletions WDL/runtime/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get(
from .. import values_from_json

file_path = os.path.join(self.call_cache_dir, f"{key}.json")
file_coherence_checker = FileCoherence(self._logger)
file_coherence_checker = FileCoherence(self._cfg, self._logger)

if not self._cfg["call_cache"].get_bool("get"):
return None
Expand Down Expand Up @@ -379,18 +379,26 @@ class FileCoherence(abc.ABC):
for cache and referenced files) for files stored locally.
"""

_cfg: config.Loader
_logger: logging.Logger

def __init__(self, logger):
def __init__(self, cfg: config.Loader, logger: logging.Logger):
self._cfg = cfg
self._logger = logger
self.cache_file_modification_time = 0.0

# working around circular import
from .download import able as downloadable

self._downloadable = downloadable

def check_files(self, cache_file_path: str, files: list) -> bool:
if self.cache_file_modification_time == 0.0:
self.cache_file_modification_time = self.get_last_modified_time(cache_file_path)
for file_path in files:
try:
self.check_cache_younger_than_file(output_file_path=file_path)
if not self._downloadable(self._cfg, file_path):
self.check_cache_younger_than_file(output_file_path=file_path)
except (FileNotFoundError, CacheOutputFileAgeError):
self._logger.warning(
_(
Expand Down
9 changes: 8 additions & 1 deletion tests/runner.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source tests/bash-tap/bash-tap-bootstrap
export PYTHONPATH="$SOURCE_DIR:$PYTHONPATH"
miniwdl="python3 -m WDL"

plan tests 69
plan tests 72

$miniwdl run_self_test
is "$?" "0" "run_self_test"
Expand Down Expand Up @@ -372,3 +372,10 @@ test -d _LAST/call-t1/work
is "$?" "0" "call-t1 ran"
test -d _LAST/call-t2/work
is "$?" "0" "call-t2 ran"
# check cache works with URI
$miniwdl run call_cache.wdl file_in=https://raw.githubusercontent.com/chanzuckerberg/miniwdl/main/tests/alyssa_ben.txt denom1=1 denom2=1 --verbose
is "$?" 0
$miniwdl run call_cache.wdl file_in=https://raw.githubusercontent.com/chanzuckerberg/miniwdl/main/tests/alyssa_ben.txt denom1=1 denom2=1 --verbose
is "$?" 0
test -d _LAST/call-t1/work
is "$?" "1" "call-t1 ran"

0 comments on commit a1556f0

Please sign in to comment.