Beispiel #1
0
    def test_import_files(self):
        path_obj = os.path.join(self.tmp_dir, 'objects')

        c = yaml_load('hdata/config.yaml')

        r = LocalRepository(c, path_obj)
        r.change_config_store(testprofile, testbucketname, 's3', region=None, endpoint_url=None)
        r.import_files(None, None, self.tmp_dir, 2, '{}://{}'.format('s3', testbucketname))

        for h in hs:
            file_path = os.path.join(self.tmp_dir, h)
            dir_file = os.path.join('hdata', h)
            self.assertTrue(os.path.exists(file_path))
            self.assertTrue(filecmp.cmp(dir_file, file_path))
Beispiel #2
0
    def import_files(self, object, path, directory, retry, bucket):
        err_msg = 'Invalid ml-git project!'

        try:
            root = get_root_path()
            root_dir = os.path.join(root, directory)
        except Exception:
            log.error(err_msg, class_name=REPOSITORY_CLASS_NAME)
            return

        local = LocalRepository(
            self.__config, get_objects_path(self.__config, self.__repo_type),
            self.__repo_type)
        bucket_name = bucket['bucket_name']
        store_type = bucket['store_type']
        local.change_config_store(bucket['profile'],
                                  bucket_name,
                                  store_type,
                                  region=bucket['region'],
                                  endpoint_url=bucket['endpoint_url'])
        local.import_files(object, path, root_dir, retry,
                           '{}://{}'.format(store_type, bucket_name))