diff --git a/hail_search/queries/base.py b/hail_search/queries/base.py index 3e72eeed09..0b97aab59e 100644 --- a/hail_search/queries/base.py +++ b/hail_search/queries/base.py @@ -1,4 +1,4 @@ -from aiohttp.web import HTTPBadRequest, HTTPNotFound +from aiohttp.web import HTTPBadRequest, HTTPNotFound, HTTPInternalServerError from collections import defaultdict, namedtuple import hail as hl import logging @@ -231,6 +231,9 @@ def _enum_field(cls, field_name, value, enum, ht_globals=None, annotate_value=No def __init__(self, sample_data, sort=XPOS, sort_metadata=None, num_results=100, inheritance_mode=None, override_comp_het_alt=False, **kwargs): + if not self.LOADED_GLOBALS: + raise HTTPInternalServerError(reason=f'No loaded {self.DATA_TYPE} data found') + self.unfiltered_comp_het_ht = None self._sort = sort self._sort_metadata = sort_metadata diff --git a/hail_search/search.py b/hail_search/search.py index a9ec9bdd02..8f43137191 100644 --- a/hail_search/search.py +++ b/hail_search/search.py @@ -1,5 +1,3 @@ -from aiohttp.web import HTTPInternalServerError - from hail_search.queries.multi_data_types import QUERY_CLASS_MAP, SNV_INDEL_DATA_TYPE, MultiDataTypeHailTableQuery @@ -35,10 +33,7 @@ def lookup_variants(request): def load_globals(): - data_type_globals = { + return { str(k): v.load_globals() for k, v in QUERY_CLASS_MAP.items() } - if all(g is None for g in data_type_globals.values()): - raise HTTPInternalServerError(reason='No loaded data found') - return data_type_globals