Пример #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)
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
    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
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
0
    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
Пример #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._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)
Пример #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.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
Пример #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
Пример #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)
Пример #13
0
 def resolved_cache(self):
     resolved_cache = os.path.realpath(self._data.relative)
     return Path(resolved_cache, self._git)
Пример #14
0
 def path(self, relative_raw):
     return Path(relative_raw, self._git)
Пример #15
0
 def state(self):
     return Path(StateFile.find(self).path, self._git)
Пример #16
0
 def existing_data_item_from_dvc_path(self, dvc_path):
     path = Path.from_dvc_path(dvc_path, self._git)
     return self.existing_data_item(path.relative)
Пример #17
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)
Пример #18
0
 def data_item_from_dvc_path(self, dvc_path, existing=True):
     path = Path.from_dvc_path(dvc_path, self._git)
     if existing:
         return self.existing_data_item(path.relative)
     else:
         return self.data_item(path.relative)