def copy_factory_files(self) -> None: PESTO_LOG.info('********** copy factory files **********') if os.path.exists(self.workspace): shutil.rmtree(self.workspace) os.makedirs(self.workspace, exist_ok=True) PESTO_LOG.info('workspace created : {}'.format(self.workspace)) # copy pesto required resources (api_geo_process_v1.0.yaml) PESTO_LOG.debug('COPY pesto resources to workspace from: {}'.format( PROCESSING_FACTORY_PATH)) # shutil.copytree(os.path.join(PROCESSING_FACTORY_PATH, 'pesto/cli'), os.path.join(self.workspace, 'pesto/cli')) os.makedirs(os.path.join(self.workspace, "pesto"), exist_ok=True) shutil.copyfile( os.path.join(PROCESSING_FACTORY_PATH, 'pesto/cli/resources/doc/api_geo_process_v1.0.yaml'), os.path.join(self.workspace, 'pesto/api_geo_process_v1.0.yaml')) # copy algorithm target_path = os.path.join(self.workspace, self.build_config.name) PESTO_LOG.debug('COPY algorithm to workspace from: {} to: {}'.format( self.build_config.algorithm_path, target_path)) shutil.copytree(self.build_config.algorithm_path, target_path) # copy/update config files shutil.rmtree(os.path.join(target_path, 'pesto', 'api')) shutil.rmtree(os.path.join(target_path, 'pesto', 'build')) os.makedirs(os.path.join(target_path, 'pesto', 'api')) os.makedirs(os.path.join(target_path, 'pesto', 'build')) for item in self.configs: with open(os.path.join(target_path, 'pesto', item.value), 'w') as _: json.dump(self.configs[item], _, indent=4, sort_keys=True)
def search_build_config(args: Any) -> str: build_config_path = str(args.build_config) PESTO_LOG.debug('search build config ...') if ':' in build_config_path: PESTO_LOG.info('search {} in PESTO build repository : {}'.format(build_config_path, PESTO_WORKSPACE)) name, version = build_config_path.split(':') build_config_path = os.path.join(PESTO_WORKSPACE, name, version, name) if not build_config_path.endswith('.json'): PESTO_LOG.warning('build parameter {} is not a json ...'.format(build_config_path)) build_config_path = os.path.join(build_config_path, 'pesto', 'build', 'build.json') PESTO_LOG.warning('search for build.json in {}'.format(build_config_path)) if not os.path.exists(build_config_path): raise ValueError('build.json not found at {}'.format(build_config_path)) return build_config_path