Exemple #1
0
 def cache(self):
     if self._cache_file:
         return Path(self._cache_file, self._git)
     else:
         cache_dir = os.path.join(self._git.git_dir_abs,
                                  self._config.cache_dir)
         cache_file_suffix = self.CACHE_FILE_SEP + self._git.curr_commit
         cache_file = os.path.join(cache_dir,
                                   self.data_dvc_short + cache_file_suffix)
         return Path(cache_file, self._git)
    def basic_test(self):
        os.chdir(self.test_dir)

        file = os.path.join('data', 'file.txt')
        path = Path(file, self._git)
        self._validate_dvc_path(path, file, file)
        pass
    def from_dir_test(self):
        os.chdir(os.path.join(self.test_dir, 'code'))

        file_dvc_path = os.path.join('data', 'file1.txt')
        file_relative_path = os.path.join('..', file_dvc_path)

        path = Path(file_relative_path, self._git)
        self._validate_dvc_path(path, file_dvc_path, file_relative_path)
        pass
Exemple #4
0
    def cache(self):
        cache_dir = os.path.join(self._git.git_dir_abs, self._config.cache_dir)

        if self._cache_file:
            file_name = os.path.relpath(os.path.realpath(self._cache_file), cache_dir)
        else:
            file_name = self.data_dvc_short + self.CACHE_FILE_SEP + self._git.curr_commit

        cache_file = os.path.join(cache_dir, file_name)
        return Path(cache_file, self._git)
    def from_deep_dirs_test(self):
        deep_dir = os.path.join('d1', 'd2', 'dir3')
        os.chdir(os.path.join(self.test_dir, deep_dir))

        file_dvc = os.path.join('code', 'lib', 'context_switcher_structs.asm')
        file_relative = os.path.join('..', '..', '..', file_dvc)

        path = Path(file_relative, self._git)
        self._validate_dvc_path(path, file_dvc, file_relative)
        pass
Exemple #6
0
    def cache(self):
        cache_dir = self.cache_dir_abs

        if self._cache_file:
            file_name = os.path.relpath(os.path.realpath(self._cache_file), cache_dir)
        else:
            file_name = str(StateFile.find_md5(self))

        cache_file = os.path.join(cache_dir, file_name)
        return Path(cache_file, self._git)
    def go_deeper_test(self):
        deep_dir = os.path.join('d1', 'd2', 'dir3')
        os.chdir(os.path.join(self.test_dir, deep_dir))

        file_relative_path = os.path.join(deep_dir, 'd4', 'dir5',
                                          'rawdata.tsv')
        file_dvc_path = os.path.join(deep_dir, file_relative_path)

        path = Path(file_relative_path, self._git)
        self._validate_dvc_path(path, file_dvc_path, file_relative_path)
        pass
Exemple #8
0
    def cache(self):
        cache_dir = self.cache_dir

        if self._cache_file:
            file_name = os.path.relpath(os.path.realpath(self._cache_file), cache_dir)
        else:
            from dvc.state_file import StateFile
            file_name = StateFile.load(self, self._git).md5

        cache_file = os.path.join(cache_dir, file_name)
        return Path(cache_file, self._git)
Exemple #9
0
    def __init__(self, data_file, git, config, cache_file=None):
        self._git = git
        self._config = config
        self._cache_file = cache_file

        self._data = Path(data_file, git)
        if not self._data.abs.startswith(self.data_dir_abs):
            raise NotInDataDirError(data_file, self._config.data_dir)

        if not self._data.dvc.startswith(self._config.data_dir):
            raise NotInDataDirError(data_file, self._config.data_dir)
        pass
Exemple #10
0
    def __init__(self, data_file, git, config, cache_file=None):
        self._git = git
        self._config = config
        self._cache_file = cache_file

        self._data = Path(data_file, git)

        if not self._data.abs.startswith(self._git.git_dir_abs):
            raise NotInGitDirError(data_file, self._git.git_dir_abs)

        if self._data.abs.startswith(os.path.join(self._git.git_dir_abs, self._config.CONFIG_DIR)):
            raise DataItemInConfigDirError(data_file)
Exemple #11
0
    def __init__(self, data_file, git, config, cache_file=None):
        self._git = git
        self._config = config
        self._cache_file = cache_file

        self._data = Path(data_file, git)

        if not self._data.abs.startswith(self._git.git_dir_abs):
            raise NotInGitDirError.build(data_file, self._git.git_dir_abs)

        if self._data.abs.startswith(self.state_dir_abs):
            raise DataItemInStatusDirError.build(data_file,
                                                 self._config.data_dir)

        if not self._data.abs.startswith(self.data_dir_abs):
            raise NotInDataDirError.build(data_file, self._config.data_dir)

        if not self._data.dvc.startswith(self._config.data_dir):
            raise NotInDataDirError.build(data_file, self._config.data_dir)
        pass
Exemple #12
0
 def state(self):
     state_dir = os.path.join(self._git.git_dir_abs, self._config.state_dir)
     state_file = os.path.join(state_dir, self.data_dvc_short + self.STATE_FILE_SUFFIX)
     return Path(state_file, self._git)
Exemple #13
0
 def resolved_cache(self):
     resolved_cache = os.path.realpath(self._data.relative)
     return Path(resolved_cache, self._git)
Exemple #14
0
 def path(self, relative_raw):
     return Path(relative_raw, self._git)
Exemple #15
0
 def state(self):
     return Path(StateFile.find(self).path, self._git)
Exemple #16
0
 def _state(self, prefix, suffix):
     state_file = os.path.join(self._git.git_dir_abs,
                               os.path.dirname(self.data.dvc),
                               prefix + os.path.basename(self.data.dvc) + suffix)
     return Path(state_file, self._git)