Skip to content

Commit 86cf4bc

Browse files
committed
Add caching for painted domains and warm-up queries in performance tests
1 parent 7eeded6 commit 86cf4bc

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/test/test_query_performance.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ def test_09_neuron_input_queries(self):
375375
print("="*80)
376376

377377
# NeuronInputsTo
378+
# Warm up cache with full results
379+
try:
380+
get_individual_neuron_inputs(self.test_terms['connected_neuron'], return_dataframe=False, limit=-1)
381+
except Exception:
382+
pass # Ignore warm-up failures
383+
378384
result, duration, success = self._time_query(
379385
"NeuronInputsTo",
380386
get_individual_neuron_inputs,
@@ -606,6 +612,12 @@ def test_13_dataset_template_queries(self):
606612
dataset_term = 'VFBc_00101384' # Example dataset
607613

608614
# PaintedDomains - Template painted anatomy domains
615+
# Warm up cache with full results
616+
try:
617+
get_painted_domains(template_term, return_dataframe=False, limit=-1)
618+
except Exception:
619+
pass # Ignore warm-up failures
620+
609621
result, duration, success = self._time_query(
610622
"PaintedDomains",
611623
get_painted_domains,

src/vfbquery/cached_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def get_related_anatomy_cached(template_short_form: str, limit: int = -1, return
309309
"""
310310
return _original_get_related_anatomy(template_short_form=template_short_form, limit=limit, return_dataframe=return_dataframe)
311311

312+
@with_solr_cache('painted_domains')
312313
def get_painted_domains_cached(template_short_form: str, return_dataframe=True, limit: int = -1, force_refresh: bool = False):
313314
"""
314315
Enhanced get_painted_domains with SOLR caching.

src/vfbquery/solr_result_cache.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ def wrapper(*args, **kwargs):
627627
'neurons_part_here', 'neurons_synaptic',
628628
'neurons_presynaptic', 'neurons_postsynaptic',
629629
'expression_overlaps_here', 'anatomy_scrnaseq', 'aligned_datasets', 'terms_for_pub',
630-
'individual_neuron_inputs', 'cluster_expression', 'expression_cluster', 'scrnaseq_dataset_data']
630+
'individual_neuron_inputs', 'cluster_expression', 'expression_cluster', 'scrnaseq_dataset_data',
631+
'painted_domains']
631632

632633
# For neuron_neuron_connectivity_query, only cache when all parameters are defaults
633634
if query_type == 'neuron_neuron_connectivity_query':
@@ -665,7 +666,7 @@ def wrapper(*args, **kwargs):
665666
'neuron_region_connectivity_query', 'instances', 'templates', 'images_neurons',
666667
'images_that_develop_from', 'expression_pattern_fragments', 'expression_overlaps_here',
667668
'anatomy_scrnaseq', 'aligned_datasets', 'terms_for_pub', 'individual_neuron_inputs',
668-
'cluster_expression', 'expression_cluster', 'scrnaseq_dataset_data']
669+
'cluster_expression', 'expression_cluster', 'scrnaseq_dataset_data', 'painted_domains']
669670
if query_type in dataframe_query_types:
670671
return_dataframe = kwargs.get('return_dataframe', True) # Default is True
671672
cache_term_id = f"{cache_term_id}_dataframe_{return_dataframe}"

0 commit comments

Comments
 (0)