diff --git a/app/api.py b/app/api.py index ded8dae0..86b41df1 100644 --- a/app/api.py +++ b/app/api.py @@ -35,7 +35,7 @@ else: # we cache query builder and result processor here for faster processing FILTER_QUERY_BUILDER = build_elasticsearch_query_builder(config.CONFIG) - RESULT_PROCESSOR = load_result_processor(config.CONFIG.result_processor) + RESULT_PROCESSOR = load_result_processor(config.CONFIG) app = FastAPI( diff --git a/app/postprocessing.py b/app/postprocessing.py index 08b2b07e..38da8280 100644 --- a/app/postprocessing.py +++ b/app/postprocessing.py @@ -46,13 +46,18 @@ def process_after(self, result: JSONType) -> JSONType: return result -def load_result_processor(result_processor: str | None) -> BaseResultProcessor | None: +def load_result_processor(config: Config) -> BaseResultProcessor | None: + """Load the result processor class from the config. + + :param config: the config object + :return: the initialized result processor + """ result_processor_cls = ( - load_class_object_from_string(result_processor) - if result_processor is not None + load_class_object_from_string(config.result_processor) + if config.result_processor is not None else BaseResultProcessor ) - return result_processor_cls(result_processor) + return result_processor_cls(config) def process_taxonomy_completion_response(response: Response) -> JSONType: