Beispiel #1
0
 def cache(self) -> RunCache:
     if self._cache is None:
         cp = self.cache_path or (self.base_path / self.LOCAL_RUN_CACHE)
         self._cache = RunCache(cache_dir=cp, file_ignore=self.file_ignores)
     return self._cache
Beispiel #2
0
 def cache(self) -> RunCache:
     if self._cache is None:
         cp = self.cache_path or (self.resource_path / constants.CACHE_PATH)
         self._cache = RunCache(cache_dir=cp)
     return self._cache
Beispiel #3
0
def __hash(tmp_file: Path) -> str:
    with tempfile.TemporaryDirectory() as cache_dir:
        return RunCache(cache_dir)._modified_hash([tmp_file])
Beispiel #4
0
def test_get(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
    _, file = __setup_test_dir(tmp_path)

    paths = [file]

    with tempfile.TemporaryDirectory() as tmpdir:
        cache_path = Path(tmpdir)

        # Check cache is retrievable
        cache = RunCache(cache_path)
        assert cache.get(TOOL_ID, paths) is None
        cache.put(TOOL_ID, paths, TOOL_OUTPUT)

        cache = RunCache(cache_path)
        assert cache.get(TOOL_ID, paths) == TOOL_OUTPUT

        # Check that modifying file invalidates cache
        __ensure_ubuntu_mtime_change()
        file.touch()

        cache = RunCache(cache_path)
        assert cache.get(TOOL_ID, paths) is None
Beispiel #5
0
def __cache(cache_path: Path, run_path: Path) -> RunCache:
    context = BaseContext(base_path=run_path)
    ignore = context.file_ignores
    return RunCache(ignore, cache_path)