Skip to content

Commit

Permalink
fix: fix bug in postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Nov 21, 2023
1 parent 48a1fb4 commit 4df7893
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 9 additions & 4 deletions app/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4df7893

Please sign in to comment.