def patch_map(workspace, mapname, task_options, start_at): # sync processing sources = get_sources() call_modules_fn(sources, 'patch_map', [workspace, mapname], kwargs=task_options) # async processing patch_tasks = tasks_util.get_task_methods(get_map_type_def(), workspace, mapname, task_options, start_at) patch_chain = tasks_util.get_chain_of_methods(workspace, mapname, patch_tasks, task_options, 'mapname') # res = patch_chain.apply_async() res = patch_chain() celery_util.set_publication_chain_info(workspace, MAP_TYPE, mapname, patch_tasks, res)
def get_metadata_comparison(workspace, mapname): layman_info = get_complete_map_info(cached=True) layman_props = map_info_to_metadata_properties(layman_info) all_props = { f"{layman_props['map_endpoint']}": layman_props, } sources = get_sources() partial_infos = call_modules_fn(sources, 'get_metadata_comparison', [workspace, mapname]) for partial_info in partial_infos.values(): if partial_info is not None: all_props.update(partial_info) map_json = get_map_file_json(workspace, mapname) if map_json: soap_operates_on = next(iter(partial_infos[csw].values()) )['operates_on'] if partial_infos[csw] else [] operates_on_muuids_filter = micka_util.operates_on_values_to_muuids( soap_operates_on) layman_file_props = map_file_to_metadata_properties( map_json, operates_on_muuids_filter) map_file_url = url_for('rest_workspace_map_file.get', mapname=mapname, workspace=workspace) all_props[map_file_url] = layman_file_props return metadata_common.transform_metadata_props_to_comparison(all_props)
def post_layer(workspace, layername, task_options, start_async_at): # sync processing sources = get_sources() call_modules_fn(sources, 'post_layer', [workspace, layername], kwargs=task_options) post_tasks = tasks_util.get_task_methods(get_layer_type_def(), workspace, layername, task_options, start_async_at) post_chain = tasks_util.get_chain_of_methods(workspace, layername, post_tasks, task_options, 'layername') # res = post_chain.apply_async() res = post_chain() celery_util.set_publication_chain_info(workspace, LAYER_TYPE, layername, post_tasks, res)
def decorated_function(*args, **kwargs): # current_app.logger.info(f"authenticate ARGS {args} KWARGS {kwargs}") authn_modules = get_authn_modules() results = list(call_modules_fn(authn_modules, 'authenticate', until=lambda r: r is not None).values()) authenticated = len(results) > 0 and results[-1] is not None if authenticated: authn_module = authn_modules[len(results) - 1] g.user['AUTHN_MODULE'] = authn_module.__name__ else: g.user = None return function(*args, **kwargs)
def get_metadata_comparison(workspace, layername): layman_info = get_complete_layer_info(cached=True) layman_props = layer_info_to_metadata_properties(layman_info) all_props = { f"{layman_props['layer_endpoint']}": layman_props, } sources = get_sources() partial_infos = call_modules_fn(sources, 'get_metadata_comparison', [workspace, layername]) for partial_info in partial_infos.values(): if partial_info is not None: all_props.update(partial_info) return metadata_common.transform_metadata_props_to_comparison(all_props)
def patch_layer(workspace, layername, task_options, stop_sync_at, start_async_at): # sync processing sources = get_sources() stop_idx = next( (idx for idx, s in enumerate(sources) if s.__name__ == stop_sync_at), len(sources)) sources = sources[:stop_idx] call_modules_fn(sources, 'patch_layer', [workspace, layername], kwargs=task_options) patch_tasks = tasks_util.get_task_methods(get_layer_type_def(), workspace, layername, task_options, start_async_at) patch_chain = tasks_util.get_chain_of_methods(workspace, layername, patch_tasks, task_options, 'layername') # res = patch_chain.apply_async() res = patch_chain() celery_util.set_publication_chain_info(workspace, LAYER_TYPE, layername, patch_tasks, res)
def delete_layer(workspace, layername, source=None, http_method='delete'): sources = get_sources() source_idx = next( (idx for idx, m in enumerate(sources) if m.__name__ == source), 0) end_idx = None if source_idx == 0 else source_idx - 1 sources = sources[:end_idx:-1] if http_method == common.REQUEST_METHOD_PATCH: sources = [ m for m in sources if m.PATCH_MODE == patch_mode.DELETE_IF_DEPENDANT ] # print(f"delete_layer {username}.{layername} using {len(sources)} sources: {[s.__name__ for s in sources]}") result = {} results = call_modules_fn(sources, 'delete_layer', [workspace, layername]) for partial_result in results.values(): if partial_result is not None: result.update(partial_result) celery_util.delete_publication(workspace, LAYER_TYPE, layername) return result
def same_value_of_key_in_all_sources(workspace, publ_type, name): with app.app_context(): sources = layman_util.get_internal_sources(publ_type) info = layman_util.get_publication_info(workspace, publ_type, name) info_method = { process_client.LAYER_TYPE: 'get_layer_info', process_client.MAP_TYPE: 'get_map_info', }[publ_type] with app.app_context(): partial_infos = layman_util.call_modules_fn(sources, info_method, [workspace, name]) for source, source_info in partial_infos.items(): for key, value in source_info.items(): if key in info: assert_util.assert_same_values_for_keys( expected=info[key], tested=value, missing_key_is_ok=True, path=f'[{source}]', )
def delete_map(workspace, mapname, kwargs=None): sources = get_sources() call_modules_fn(sources[::-1], 'delete_map', [workspace, mapname], kwargs=kwargs) celery_util.delete_publication(workspace, MAP_TYPE, mapname)
def pre_publication_action_check(workspace, mapname, task_options): # sync processing sources = get_sources() call_modules_fn(sources, 'pre_publication_action_check', [workspace, mapname], kwargs=task_options)
def check_new_layername(workspace, layername): check_layername(layername) providers = get_providers() call_modules_fn(providers, 'check_new_layername', [workspace, layername])