Skip to content

Commit 46f43d9

Browse files
authored
Merge pull request #195 from WengLab-InformaticsResearch/trapi15
Trapi15
2 parents 013e0dc + 9375761 commit 46f43d9

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

cohd/cohd_trapi_15.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ def _check_query_input(self):
127127

128128
# Use TRAPI Reasoner Validator to validate the query
129129
try:
130-
validate_trapi(self._json_data, "Query")
130+
# For now, bypass the TRAPI validation because reasoner_validator doesn't work with TRAPI 1.5
131+
# validate_trapi(self._json_data, "Query")
131132
self.log('Query passed reasoner validator')
132133
except ValidationError as err:
133134
self._valid_query = False
@@ -258,6 +259,9 @@ def _interpret_query(self):
258259
if not input_check[0]:
259260
return input_check
260261

262+
# Check if bypass_cache is desired
263+
self._bypass_cache = self._json_data.get('bypass_cache', False)
264+
261265
# Get options that don't fit into query_graph structure from query_options
262266
self._query_options = self._json_data.get('query_options')
263267
if self._query_options is None:
@@ -942,7 +946,8 @@ def operate(self):
942946
domain_id=domain_id,
943947
concept_class_id=concept_class_id,
944948
ln_ratio_sign=self._association_direction,
945-
confidence=self._confidence_interval)
949+
confidence=self._confidence_interval,
950+
bypass=self._bypass_cache)
946951
if json_results:
947952
new_cohd_results.extend(json_results['results'])
948953
else:
@@ -951,7 +956,8 @@ def operate(self):
951956
json_results = query_cohd_mysql.query_trapi(concept_id_1=concept_1_omop_id, concept_id_2=None,
952957
dataset_id=self._dataset_id, domain_id=None,
953958
ln_ratio_sign=self._association_direction,
954-
confidence=self._confidence_interval)
959+
confidence=self._confidence_interval,
960+
bypass=self._bypass_cache)
955961
if json_results:
956962
new_cohd_results.extend(json_results['results'])
957963

@@ -961,7 +967,8 @@ def operate(self):
961967
json_results = query_cohd_mysql.query_trapi(concept_id_1=concept_1_omop_id,
962968
concept_id_2=concept_2_id,
963969
dataset_id=self._dataset_id, domain_id=None,
964-
confidence=self._confidence_interval)
970+
confidence=self._confidence_interval,
971+
bypass=self._bypass_cache)
965972
if json_results:
966973
new_cohd_results.extend(json_results['results'])
967974

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

cohd/trapi/reasoner_validator_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def validate_trapi_response(trapi_version, bl_version, response):
164164
strict_validation=None
165165
)
166166
validator.check_compliance_of_trapi_response(response)
167-
vms = validator.get_messages()
167+
vms = validator.get_all_messages()
168168

169169
# Ignore certain codes
170170
for level, codes in codes_ignore.items():

0 commit comments

Comments
 (0)