def init_environment(self, test_dir=System.get_long_path(tempfile.mkdtemp()), curr_dir=None): self._test_dir = System.realpath(test_dir) self._proj_dir = 'proj' self._test_git_dir = os.path.join(self._test_dir, self._proj_dir) self._old_curr_dir_abs = System.realpath(os.curdir) if os.path.exists(self._test_dir): rmtree(self._test_dir) if curr_dir: self._curr_dir = System.realpath(curr_dir) else: self._curr_dir = self._test_git_dir if not os.path.exists(self._curr_dir): os.makedirs(self._curr_dir) if not os.path.isdir(self._test_git_dir): os.makedirs(self._test_git_dir) data_dir = os.path.join(self._test_git_dir, 'data') cache_dir = os.path.join(self._test_git_dir, ConfigI.CONFIG_DIR, ConfigI.CACHE_DIR) state_dir = os.path.join(self._test_git_dir, ConfigI.CONFIG_DIR, ConfigI.STATE_DIR) os.makedirs(data_dir) os.makedirs(cache_dir) os.makedirs(state_dir) os.chdir(self._curr_dir)
def get_cache_file_s3_name(self, cache_file): cache_prefix_file_name = os.path.relpath( System.realpath(cache_file), System.realpath(self.git.git_dir)) file_name = os.path.relpath(cache_prefix_file_name, self.config.cache_dir) dvc_file_path_trim = file_name.replace(os.sep, '/').strip('/') return self.config.aws_storage_prefix + '/' + dvc_file_path_trim
def abs_paths_to_relative(files): cur_dir = System.realpath(os.curdir) result = [] for file in files: result.append(os.path.relpath(System.realpath(file), cur_dir)) return result
def setUp(self): self.curr_dir = System.realpath('.') self.test_dir = System.realpath('/tmp/ntx_unit_test/dvc_path') self.tearDown() os.makedirs(os.path.join(self.test_dir, 'data')) os.makedirs(os.path.join(self.test_dir, 'code', 'lib')) os.makedirs( os.path.join(self.test_dir, 'd1', 'd2', 'dir3', 'd4', 'dir5')) self._git = GitWrapperI(self.test_dir)
def test(self): not_in_data_dir_file = 'file1.txt' self.create_file(not_in_data_dir_file) change = RepositoryChange(['echo', 'textsd'], self.settings, not_in_data_dir_file, None, shell=True) self.assertEqual([System.realpath(not_in_data_dir_file)], change.externally_created_files)
def setUp(self): self.test_dir = System.get_long_path(tempfile.mkdtemp()) self._old_curr_dir_abs = System.realpath(os.curdir) self.tearDown() os.mkdir(self.test_dir) os.chdir(self.test_dir) os.mkdir('data') self._devnull = open(os.devnull, 'w') subprocess.Popen(['git', 'init'], stdout=self._devnull, stderr=None).wait() self.git = GitWrapperI(self.test_dir) self.config = ConfigI() self.path_factory = PathFactory(self.git, self.config) self.settings = Settings([], self.git, self.config)
def setUp(self): self.test_dir = System.get_long_path(tempfile.mkdtemp()) self._old_curr_dir_abs = System.realpath(os.curdir) self.tearDown() os.mkdir(self.test_dir) os.chdir(self.test_dir) os.mkdir('data') os.mkdir('cache') os.mkdir('state') self.init_git_repo() self.git = GitWrapper() self.config = ConfigI('data', 'cache', 'state') self.path_factory = PathFactory(self.git, self.config) self.settings = Settings([], self.git, self.config) pass
def setUp(self): self.test_dir = System.get_long_path(tempfile.mkdtemp()) self._old_curr_dir_abs = System.realpath(os.curdir) self.tearDown() os.mkdir(self.test_dir) os.chdir(self.test_dir) os.mkdir('data') os.mkdir(ConfigI.CONFIG_DIR) os.mkdir(os.path.join(ConfigI.CONFIG_DIR, ConfigI.CACHE_DIR_NAME)) os.mkdir(os.path.join(ConfigI.CONFIG_DIR, ConfigI.STATE_DIR_NAME)) self.init_git_repo() self.git = GitWrapper() self.config = ConfigI('data') self.path_factory = PathFactory(self.git, self.config) self.settings = Settings('run cmd', self.git, self.config) pass
def git_dir_abs(self): return System.realpath(self.git_dir)
def conf_file_path(git_dir): return System.realpath(os.path.join(git_dir, Runtime.CONFIG))
def is_cache_exists(self): path = System.realpath(self._data_item.data.relative) return os.path.exists(path)
def __init__(self, git, config): self._git = git self._config = config self._curr_dir_abs = System.realpath(os.curdir)
def existing_data_item(self, file): if not System.islink(file): raise DataItemError(u'Data file "%s" must be a symbolic link' % file) resolved_symlink = System.realpath(file) return DataItem(file, self._git, self._config, resolved_symlink)
def _pushd(self, d): self._saved_dir = System.realpath(os.curdir) os.chdir(d)
def __init__(self, settings): self._git = settings.git self._config = settings.config self._settings = settings self._curr_dir_abs = System.realpath(os.curdir)