Skip to content

Commit

Permalink
do not throw error on hail search startup when no data loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
hanars committed Oct 10, 2024
1 parent 80469a6 commit 3b6e2e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 4 additions & 1 deletion hail_search/queries/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions hail_search/search.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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

0 comments on commit 3b6e2e7

Please sign in to comment.