Skip to content

Commit

Permalink
skipping artifact paths
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed May 13, 2020
1 parent 7bf1d6b commit 9ca96b7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion jupyter_cache/cache/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,32 @@

CACHE_LIMIT_KEY = "cache_limit"
DEFAULT_CACHE_LIMIT = 1000
ARTIFACT_SKIP_PATTERNS = ["__pycache__"]


class NbArtifacts(NbArtifactsAbstract):
"""Container for artefacts of a notebook execution."""

def __init__(self, paths: List[str], in_folder, check_existence=True):
def __init__(
self,
paths: List[str],
in_folder,
check_existence=True,
skip_patterns=ARTIFACT_SKIP_PATTERNS,
):
"""Initiate NbArtifacts
:param paths: list of paths
:param check_existence: check the paths exist
:param in_folder: The folder that all paths should be in (or subfolder).
:param skip_patterns: Exclude paths that contain one of these patterns
:raises IOError: if check_existence and file does not exist
"""

def path_not_in_skip_artifacts(path):
return all(path != pattern for pattern in skip_patterns)

paths = list(path_not_in_skip_artifacts, paths)
self.paths = [Path(p).absolute() for p in paths]
self.in_folder = Path(in_folder).absolute()
to_relative_paths(self.paths, self.in_folder, check_existence=check_existence)
Expand Down

0 comments on commit 9ca96b7

Please sign in to comment.