Skip to content

Commit 82e3010

Browse files
committed
Add functionality to bypass cache
1 parent 990dd07 commit 82e3010

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

cohd/cohd_trapi_15.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ def _interpret_query(self):
259259
if not input_check[0]:
260260
return input_check
261261

262+
# Check if bypass_cache is desired
263+
self._bypass_cache = self._json_data.get('bypass_cache', False)
264+
262265
# Get options that don't fit into query_graph structure from query_options
263266
self._query_options = self._json_data.get('query_options')
264267
if self._query_options is None:
@@ -943,7 +946,8 @@ def operate(self):
943946
domain_id=domain_id,
944947
concept_class_id=concept_class_id,
945948
ln_ratio_sign=self._association_direction,
946-
confidence=self._confidence_interval)
949+
confidence=self._confidence_interval,
950+
bypass=self._bypass_cache)
947951
if json_results:
948952
new_cohd_results.extend(json_results['results'])
949953
else:
@@ -952,7 +956,8 @@ def operate(self):
952956
json_results = query_cohd_mysql.query_trapi(concept_id_1=concept_1_omop_id, concept_id_2=None,
953957
dataset_id=self._dataset_id, domain_id=None,
954958
ln_ratio_sign=self._association_direction,
955-
confidence=self._confidence_interval)
959+
confidence=self._confidence_interval,
960+
bypass=self._bypass_cache)
956961
if json_results:
957962
new_cohd_results.extend(json_results['results'])
958963

@@ -962,7 +967,8 @@ def operate(self):
962967
json_results = query_cohd_mysql.query_trapi(concept_id_1=concept_1_omop_id,
963968
concept_id_2=concept_2_id,
964969
dataset_id=self._dataset_id, domain_id=None,
965-
confidence=self._confidence_interval)
970+
confidence=self._confidence_interval,
971+
bypass=self._bypass_cache)
966972
if json_results:
967973
new_cohd_results.extend(json_results['results'])
968974

cohd/query_cohd_mysql.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,13 @@ def get_total_pair_counts(dataset_id: int) -> int:
14531453
get_total_pair_counts.total_pair_counts = None
14541454

14551455

1456-
@cache.memoize(timeout=86400)
1456+
def _bypass_cache(f, *args, **kwargs):
1457+
return kwargs.get('bypass', False)
1458+
1459+
1460+
@cache.memoize(timeout=86400, unless=_bypass_cache)
14571461
def query_trapi(concept_id_1, concept_id_2=None, dataset_id=None, domain_id=None, concept_class_id=None,
1458-
ln_ratio_sign=0, confidence=DEFAULT_CONFIDENCE):
1462+
ln_ratio_sign=0, confidence=DEFAULT_CONFIDENCE, bypass=False):
14591463
""" Query for TRAPI. Performs the calculations for all association methods
14601464
14611465
Parameters

0 commit comments

Comments
 (0)