예제 #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
파일: data_item.py 프로젝트: guptam/dvc
    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
파일: data_item.py 프로젝트: xwc940512/dvc
    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
파일: factory.py 프로젝트: vjkumran/dvc
 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)