From 800bf2f5b00086aa1611ae0dcd0526df03dc39ae Mon Sep 17 00:00:00 2001 From: Gordon Krieger Date: Tue, 18 Jun 2024 19:51:08 +0000 Subject: [PATCH] handle variants queries gracefully when not using gohan --- bento_beacon/utils/search.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bento_beacon/utils/search.py b/bento_beacon/utils/search.py index 0bb5c66..c27d91d 100644 --- a/bento_beacon/utils/search.py +++ b/bento_beacon/utils/search.py @@ -1,6 +1,8 @@ +from flask import current_app from functools import reduce from .gohan_utils import query_gohan from .katsu_utils import katsu_filters_query, search_from_config, biosample_ids_for_individuals +from .beacon_response import add_info_to_response # TODO: search by linked field set elements instead of hardcoding @@ -11,6 +13,10 @@ def biosample_id_search(variants_query=None, phenopacket_filters=None, experimen return [] if variants_query: + if not current_app.config["BEACON_CONFIG"].get("useGohan"): + # variants query even though there are no variants in this beacon, this can happen in a network context + add_info_to_response("No variants available at this beacon, query by metadata values only") + return [] variant_sample_ids = query_gohan(variants_query, "count", ids_only=True) if not variant_sample_ids: return []