Skip to content

Commit 87f09e6

Browse files
authored
Merge pull request #33 from VirtualFlyBrain/dev
Fix for testing and encoding
2 parents dec8e60 + 43a0849 commit 87f09e6

7 files changed

Lines changed: 185 additions & 81 deletions

File tree

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,34 @@ vfb.get_term_info('FBbt_00003748')
9797
"id": "VFB_00102107",
9898
"label": "[ME on JRC2018Unisex adult brain](VFB_00102107)",
9999
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
100-
"thumbnail": "[![ME on JRC2018Unisex adult brain aligned to JRC2018Unisex](http://www.virtualflybrain.org/data/VFB/i/0010/2107/VFB_00101567/thumbnail.png 'ME on JRC2018Unisex adult brain aligned to JRC2018Unisex')](VFB_00101567,VFB_00102107)"
100+
"thumbnail": "[![ME on JRC2018Unisex adult brain aligned to JRC2018U](http://www.virtualflybrain.org/data/VFB/i/0010/2107/VFB_00101567/thumbnail.png 'ME on JRC2018Unisex adult brain aligned to JRC2018U')](VFB_00101567,VFB_00102107)"
101101
},
102102
{
103103
"id": "VFB_00101385",
104-
"label": "[ME%28R%29 on JRC_FlyEM_Hemibrain](VFB_00101385)",
104+
"label": "[ME(R) on JRC_FlyEM_Hemibrain](VFB_00101385)",
105105
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
106-
"thumbnail": "[![ME(R) on JRC_FlyEM_Hemibrain aligned to JRC_FlyEM_Hemibrain](http://www.virtualflybrain.org/data/VFB/i/0010/1385/VFB_00101384/thumbnail.png 'ME(R) on JRC_FlyEM_Hemibrain aligned to JRC_FlyEM_Hemibrain')](VFB_00101384,VFB_00101385)"
106+
"thumbnail": "[![ME(R) on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum](http://www.virtualflybrain.org/data/VFB/i/0010/1385/VFB_00101384/thumbnail.png 'ME(R) on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum')](VFB_00101384,VFB_00101385)"
107107
},
108108
{
109109
"id": "VFB_00030810",
110110
"label": "[medulla on adult brain template Ito2014](VFB_00030810)",
111-
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
111+
"tags": "Nervous_system|Visual_system|Adult|Synaptic_neuropil_domain",
112112
"thumbnail": "[![medulla on adult brain template Ito2014 aligned to adult brain template Ito2014](http://www.virtualflybrain.org/data/VFB/i/0003/0810/VFB_00030786/thumbnail.png 'medulla on adult brain template Ito2014 aligned to adult brain template Ito2014')](VFB_00030786,VFB_00030810)"
113113
},
114114
{
115115
"id": "VFB_00030624",
116116
"label": "[medulla on adult brain template JFRC2](VFB_00030624)",
117-
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
118-
"thumbnail": "[![medulla on adult brain template JFRC2 aligned to adult brain template JFRC2](http://www.virtualflybrain.org/data/VFB/i/0003/0624/VFB_00017894/thumbnail.png 'medulla on adult brain template JFRC2 aligned to adult brain template JFRC2')](VFB_00017894,VFB_00030624)"
117+
"tags": "Nervous_system|Visual_system|Adult|Synaptic_neuropil_domain",
118+
"thumbnail": "[![medulla on adult brain template JFRC2 aligned to JFRC2](http://www.virtualflybrain.org/data/VFB/i/0003/0624/VFB_00017894/thumbnail.png 'medulla on adult brain template JFRC2 aligned to JFRC2')](VFB_00017894,VFB_00030624)"
119119
}
120120
]
121121
},
122122
"output_format": "table",
123123
"count": 4
124124
}
125125
],
126-
"IsIndividual": false,
127-
"IsClass": true,
126+
"IsIndividual": False,
127+
"IsClass": True,
128128
"Examples": {
129129
"VFB_00101384": [
130130
{
@@ -171,7 +171,7 @@ vfb.get_term_info('FBbt_00003748')
171171
}
172172
]
173173
},
174-
"IsTemplate": false,
174+
"IsTemplate": False,
175175
"Synonyms": [
176176
{
177177
"label": "ME",
@@ -1102,15 +1102,15 @@ vfb.get_instances('FBbt_00003748', return_dataframe=False)
11021102
},
11031103
{
11041104
"id": "VFB_00101385",
1105-
"label": "[ME%28R%29 on JRC_FlyEM_Hemibrain](VFB_00101385)",
1105+
"label": "[ME(R) on JRC_FlyEM_Hemibrain](VFB_00101385)",
11061106
"tags": "Nervous_system|Adult|Visual_system|Synaptic_neuropil_domain",
11071107
"parent": "[medulla](FBbt_00003748)",
11081108
"source": "",
11091109
"source_id": "",
11101110
"template": "[JRCFIB2018Fum](VFB_00101384)",
11111111
"dataset": "[JRC_FlyEM_Hemibrain painted domains](Xu2020roi)",
11121112
"license": "",
1113-
"thumbnail": "[![ME%28R%29 on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum](http://www.virtualflybrain.org/data/VFB/i/0010/1385/VFB_00101384/thumbnail.png 'ME(R) on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum')](VFB_00101384,VFB_00101385)"
1113+
"thumbnail": "[![ME(R) on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum](http://www.virtualflybrain.org/data/VFB/i/0010/1385/VFB_00101384/thumbnail.png 'ME(R) on JRC_FlyEM_Hemibrain aligned to JRCFIB2018Fum')](VFB_00101384,VFB_00101385)"
11141114
},
11151115
{
11161116
"id": "VFB_00030810",
@@ -1132,7 +1132,7 @@ vfb.get_instances('FBbt_00003748', return_dataframe=False)
11321132
"source": "",
11331133
"source_id": "",
11341134
"template": "[JFRC2](VFB_00017894)",
1135-
"dataset": "[BrainName neuropils on adult brain JFRC2 %28Jenett, Shinomya%29](JenettShinomya_BrainName)",
1135+
"dataset": "[BrainName neuropils on adult brain JFRC2 (Jenett, Shinomya)](JenettShinomya_BrainName)",
11361136
"license": "",
11371137
"thumbnail": "[![medulla on adult brain template JFRC2 aligned to JFRC2](http://www.virtualflybrain.org/data/VFB/i/0003/0624/VFB_00017894/thumbnail.png 'medulla on adult brain template JFRC2 aligned to JFRC2')](VFB_00017894,VFB_00030624)"
11381138
}
@@ -1214,7 +1214,7 @@ vfb.get_templates(return_dataframe=False)
12141214
"name": "[JFRC2](VFB_00017894)",
12151215
"tags": "Nervous_system|Adult",
12161216
"thumbnail": "[![JFRC2](http://www.virtualflybrain.org/data/VFB/i/0001/7894/VFB_00017894/thumbnail.png 'JFRC2')](VFB_00017894)",
1217-
"dataset": "[FlyLight - GMR GAL4 collection %28Jenett2012%29](Jenett2012)",
1217+
"dataset": "[FlyLight - GMR GAL4 collection (Jenett2012)](Jenett2012)",
12181218
"license": "[CC-BY-NC-SA](VFBlicense_CC_BY_NC_SA_4_0)"
12191219
},
12201220
{
@@ -1232,7 +1232,7 @@ vfb.get_templates(return_dataframe=False)
12321232
"name": "[L1 larval CNS ssTEM - Cardona/Janelia](VFB_00050000)",
12331233
"tags": "Nervous_system|Larva",
12341234
"thumbnail": "[![L1 larval CNS ssTEM - Cardona/Janelia](http://www.virtualflybrain.org/data/VFB/i/0005/0000/VFB_00050000/thumbnail.png 'L1 larval CNS ssTEM - Cardona/Janelia')](VFB_00050000)",
1235-
"dataset": "[Neurons involved in larval fast escape response - EM %28Ohyama2016%29](Ohyama2015)",
1235+
"dataset": "[Neurons involved in larval fast escape response - EM (Ohyama2016)](Ohyama2015)",
12361236
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
12371237
},
12381238
{
@@ -1241,7 +1241,7 @@ vfb.get_templates(return_dataframe=False)
12411241
"name": "[L1 larval CNS ssTEM - Cardona/Janelia](VFB_00050000)",
12421242
"tags": "Nervous_system|Larva",
12431243
"thumbnail": "[![L1 larval CNS ssTEM - Cardona/Janelia](http://www.virtualflybrain.org/data/VFB/i/0005/0000/VFB_00050000/thumbnail.png 'L1 larval CNS ssTEM - Cardona/Janelia')](VFB_00050000)",
1244-
"dataset": "[larval hugin neurons - EM %28Schlegel2016%29](Schlegel2016)",
1244+
"dataset": "[larval hugin neurons - EM (Schlegel2016)](Schlegel2016)",
12451245
"license": "[CC_BY](VFBlicense_CC_BY_4_0)"
12461246
},
12471247
{
@@ -1250,7 +1250,7 @@ vfb.get_templates(return_dataframe=False)
12501250
"name": "[L3 CNS template - Wood2018](VFB_00049000)",
12511251
"tags": "Nervous_system|Larva",
12521252
"thumbnail": "[![L3 CNS template - Wood2018](http://www.virtualflybrain.org/data/VFB/i/0004/9000/VFB_00049000/thumbnail.png 'L3 CNS template - Wood2018')](VFB_00049000)",
1253-
"dataset": "[L3 Larval CNS Template %28Truman2016%29](Truman2016)",
1253+
"dataset": "[L3 Larval CNS Template (Truman2016)](Truman2016)",
12541254
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
12551255
},
12561256
{
@@ -1259,7 +1259,7 @@ vfb.get_templates(return_dataframe=False)
12591259
"name": "[COURT2018VNS](VFB_00100000)",
12601260
"tags": "Nervous_system|Adult|Ganglion",
12611261
"thumbnail": "[![COURT2018VNS](http://www.virtualflybrain.org/data/VFB/i/0010/0000/VFB_00100000/thumbnail.png 'COURT2018VNS')](VFB_00100000)",
1262-
"dataset": "[Adult VNS neuropils %28Court2017%29](Court2017)",
1262+
"dataset": "[Adult VNS neuropils (Court2017)](Court2017)",
12631263
"license": "[CC_BY_SA](VFBlicense_CC_BY_SA_4_0)"
12641264
},
12651265
{
@@ -1274,7 +1274,7 @@ vfb.get_templates(return_dataframe=False)
12741274
{
12751275
"id": "VFB_00110000",
12761276
"order": 9,
1277-
"name": "[Adult Head %28McKellar2020%29](VFB_00110000)",
1277+
"name": "[Adult Head (McKellar2020)](VFB_00110000)",
12781278
"tags": "Adult|Anatomy",
12791279
"thumbnail": "[![Adult Head (McKellar2020)](http://www.virtualflybrain.org/data/VFB/i/0011/0000/VFB_00110000/thumbnail.png 'Adult Head (McKellar2020)')](VFB_00110000)",
12801280
"dataset": "[GAL4 lines from McKellar et al., 2020](McKellar2020)",
@@ -1283,7 +1283,7 @@ vfb.get_templates(return_dataframe=False)
12831283
{
12841284
"id": "VFB_00120000",
12851285
"order": 10,
1286-
"name": "[Adult T1 Leg %28Kuan2020%29](VFB_00120000)",
1286+
"name": "[Adult T1 Leg (Kuan2020)](VFB_00120000)",
12871287
"tags": "Adult|Anatomy",
12881288
"thumbnail": "[![Adult T1 Leg (Kuan2020)](http://www.virtualflybrain.org/data/VFB/i/0012/0000/VFB_00120000/thumbnail.png 'Adult T1 Leg (Kuan2020)')](VFB_00120000)",
12891289
"dataset": "[Millimeter-scale imaging of a Drosophila leg at single-neuron resolution](Kuan2020)",

performance.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# VFBquery Performance Test Results
22

3-
**Test Date:** 2025-10-21 18:57:26 UTC
4-
**Git Commit:** 164cbe98e3ae2151937e3c73a0d12d751e91ec8c
5-
**Branch:** main
6-
**Workflow Run:** 18694523268
3+
**Test Date:** 2025-10-21 20:47:06 UTC
4+
**Git Commit:** e46b76948e36c2eb4fdebcd64af12bef03300382
5+
**Branch:** dev
6+
**Workflow Run:** 18697165949
77

88
## Test Overview
99

@@ -25,11 +25,11 @@ This performance test measures the execution time of VFB term info queries for s
2525

2626
**Test Status**: Performance test completed
2727

28-
- **FBbt_00003748 Query Time**: 0.8842 seconds
29-
- **VFB_00101567 Query Time**: 0.7123 seconds
30-
- **Total Query Time**: 1.5965 seconds
28+
- **FBbt_00003748 Query Time**: 1.5526 seconds
29+
- **VFB_00101567 Query Time**: 1.1230 seconds
30+
- **Total Query Time**: 2.6756 seconds
3131

3232
🎉 **Result**: All performance thresholds met!
3333

3434
---
35-
*Last updated: 2025-10-21 18:57:26 UTC*
35+
*Last updated: 2025-10-21 20:47:06 UTC*

src/test/readme_parser.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,35 @@ def extract_code_blocks(readme_path):
2727
# Look for vfb.* calls and extract them
2828
vfb_calls = re.findall(r'(vfb\.[^)]*\))', block)
2929
if vfb_calls:
30-
processed_python_blocks.extend(vfb_calls)
30+
# Add force_refresh=True to each call to ensure fresh data in tests
31+
# Exceptions:
32+
# - get_templates() doesn't support force_refresh (no SOLR cache)
33+
# - Performance test terms (FBbt_00003748, VFB_00101567) should use cache
34+
for call in vfb_calls:
35+
# Check if this is get_templates() - if so, don't add force_refresh
36+
if 'get_templates' in call:
37+
processed_python_blocks.append(call)
38+
continue
39+
40+
# Check if this call uses performance test terms - skip force_refresh for those
41+
if 'FBbt_00003748' in call or 'VFB_00101567' in call:
42+
processed_python_blocks.append(call)
43+
continue
44+
45+
# Check if the call already has parameters
46+
if '(' in call and ')' in call:
47+
# Insert force_refresh=True before the closing parenthesis
48+
# Handle both cases: with and without existing parameters
49+
if call.rstrip(')').endswith('('):
50+
# No parameters: vfb.function()
51+
modified_call = call[:-1] + 'force_refresh=True)'
52+
else:
53+
# Has parameters: vfb.function(param1, param2)
54+
modified_call = call[:-1] + ', force_refresh=True)'
55+
processed_python_blocks.append(modified_call)
56+
else:
57+
# Shouldn't happen, but include original call if no parentheses
58+
processed_python_blocks.append(call)
3159

3260
# Process JSON blocks
3361
processed_json_blocks = []

src/test/term_info_queries_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@ def test_term_info_performance(self):
551551

552552
# Performance categories
553553
total_time = duration_1 + duration_2
554-
if total_time < 1.0:
555-
performance_level = "🟢 Excellent (< 1 second)"
556-
elif total_time < 2.0:
557-
performance_level = "🟡 Good (1-2 seconds)"
558-
elif total_time < 4.0:
559-
performance_level = "🟠 Acceptable (2-4 seconds)"
554+
if total_time < 1.5:
555+
performance_level = "🟢 Excellent (< 1.5 seconds)"
556+
elif total_time < 3.0:
557+
performance_level = "🟡 Good (1.5-3 seconds)"
558+
elif total_time < 6.0:
559+
performance_level = "🟠 Acceptable (3-6 seconds)"
560560
else:
561-
performance_level = "🔴 Slow (> 4 seconds)"
561+
performance_level = "🔴 Slow (> 6 seconds)"
562562

563563
print(f"Performance Level: {performance_level}")
564564
print(f"="*50)
@@ -569,8 +569,8 @@ def test_term_info_performance(self):
569569

570570
# Performance assertions - fail if queries take too long
571571
# These thresholds are based on observed performance characteristics
572-
max_single_query_time = 2.0 # seconds
573-
max_total_time = 4.0 # seconds (2 queries * 2 seconds each)
572+
max_single_query_time = 3.0 # seconds (increased from 2.0 to account for SOLR cache overhead)
573+
max_total_time = 6.0 # seconds (2 queries * 3 seconds each)
574574

575575
self.assertLess(duration_1, max_single_query_time,
576576
f"FBbt_00003748 query took {duration_1:.4f}s, exceeding {max_single_query_time}s threshold")

src/vfbquery/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .vfb_queries import *
2+
from .solr_result_cache import get_solr_cache
23

34
# Caching enhancements (optional import - don't break if dependencies missing)
45
try:
@@ -48,6 +49,26 @@
4849
__caching_available__ = False
4950
print("VFBquery: Caching not available (dependencies missing)")
5051

52+
# Convenience function for clearing SOLR cache entries
53+
def clear_solr_cache(query_type: str, term_id: str) -> bool:
54+
"""
55+
Clear a specific SOLR cache entry to force refresh
56+
57+
Args:
58+
query_type: Type of query ('term_info', 'instances', etc.)
59+
term_id: Term identifier (e.g., 'FBbt_00003748')
60+
61+
Returns:
62+
True if successfully cleared, False otherwise
63+
64+
Example:
65+
>>> import vfbquery as vfb
66+
>>> vfb.clear_solr_cache('term_info', 'FBbt_00003748')
67+
>>> result = vfb.get_term_info('FBbt_00003748') # Will fetch fresh data
68+
"""
69+
cache = get_solr_cache()
70+
return cache.clear_cache_entry(query_type, term_id)
71+
5172
# SOLR-based result caching (experimental - for cold start optimization)
5273
try:
5374
from .solr_cache_integration import (

0 commit comments

Comments
 (0)