Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
c4e7163
Refactor caching implementation to use SOLR-based caching throughout …
Robbie1977 Nov 17, 2025
e23afb0
Update performance test results [skip ci]
actions-user Nov 17, 2025
b3410fd
Add caching support for similarity queries in VFBquery functions
Robbie1977 Nov 17, 2025
cf913fe
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 17, 2025
e43c708
Update performance test results [skip ci]
actions-user Nov 17, 2025
fa69df8
Enhance caching support for similarity queries and update README with…
Robbie1977 Nov 17, 2025
0a7a06f
Update performance test results [skip ci]
actions-user Nov 17, 2025
026d4cc
Add caching support for new neuron-related queries and enhance existi…
Robbie1977 Nov 18, 2025
79b5637
Enhance caching support by adding new cached functions for templates,…
Robbie1977 Nov 18, 2025
9b11ad2
Update performance test results [skip ci]
actions-user Nov 18, 2025
e779d6b
Refactor neuron region connectivity queries to use 'region' instead o…
Robbie1977 Nov 18, 2025
1ddf8f6
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
ac196c6
Update performance test results [skip ci]
actions-user Nov 18, 2025
51c49f9
Add caching support to get_term_info_cached function with force refre…
Robbie1977 Nov 18, 2025
ea93fe2
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
74dd137
Update performance test results [skip ci]
actions-user Nov 18, 2025
7da1df7
Add SOLR caching to get_similar_neurons_cached function with force re…
Robbie1977 Nov 18, 2025
b977516
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
54cdfde
Update performance test results [skip ci]
actions-user Nov 18, 2025
c763500
Add force refresh option to caching functions for bypassing cache
Robbie1977 Nov 18, 2025
eefbc56
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
7c411c1
Update performance test results [skip ci]
actions-user Nov 18, 2025
359f40e
Enhance cached result handling to support slicing for dict types with…
Robbie1977 Nov 18, 2025
d4a84c4
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
beb095b
Update performance test results [skip ci]
actions-user Nov 18, 2025
abf5d3e
Add helper method to skip tests if SOLR server is unavailable
Robbie1977 Nov 18, 2025
f575d2a
Update performance test results [skip ci]
actions-user Nov 18, 2025
348e958
Add SOLR availability check to GitHub Actions workflow
Robbie1977 Nov 18, 2025
a2b3f27
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
945cd90
Update performance test results [skip ci]
actions-user Nov 18, 2025
ef76739
Fix SOLR availability check to correctly write status to GITHUB_ENV
Robbie1977 Nov 18, 2025
9c73fa9
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
8305bc2
Update performance test results [skip ci]
actions-user Nov 18, 2025
9520f3f
Fix SOLR availability check to correctly handle exceptions and update…
Robbie1977 Nov 18, 2025
0d8bf96
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
b4a177e
Remove duplicate condition for SOLR availability in examples workflow
Robbie1977 Nov 18, 2025
ac3279a
Update performance test results [skip ci]
actions-user Nov 18, 2025
0810895
Reorder dependency installation step in examples workflow
Robbie1977 Nov 18, 2025
d4c5015
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
db84026
Update performance test results [skip ci]
actions-user Nov 18, 2025
b1955f6
Fix example execution in workflow by restoring original print stateme…
Robbie1977 Nov 18, 2025
3754c2f
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
992cda6
Update performance test results [skip ci]
actions-user Nov 18, 2025
e5f0894
Update README and test scripts for improved clarity and functionality
Robbie1977 Nov 18, 2025
d1fed0c
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
0aaac17
Update performance test results [skip ci]
actions-user Nov 18, 2025
f86e750
Skip processing of Python code blocks that contain import statements …
Robbie1977 Nov 18, 2025
1bffca5
Update performance test results [skip ci]
actions-user Nov 18, 2025
c9a84f0
Add regex test for parsing Markdown image links
Robbie1977 Nov 18, 2025
1cf3308
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
2e8da90
Update performance test results [skip ci]
actions-user Nov 18, 2025
a3df469
Refactor code structure for improved readability and maintainability
Robbie1977 Nov 18, 2025
b0bf5f3
Update performance test results [skip ci]
actions-user Nov 18, 2025
25cb1c8
Add import for os and update sys.path in main function
Robbie1977 Nov 18, 2025
a593f40
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
c067df7
Update performance test results [skip ci]
actions-user Nov 18, 2025
cc85ff5
Refactor import statements in main function to use relative paths
Robbie1977 Nov 18, 2025
8a61c2f
Update performance test results [skip ci]
actions-user Nov 18, 2025
820f248
Update medulla example in README with detailed metadata and queries
Robbie1977 Nov 18, 2025
494e4bf
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
81adba2
Update performance test results [skip ci]
actions-user Nov 18, 2025
457eabd
Refactor medulla metadata structure in README for improved clarity an…
Robbie1977 Nov 18, 2025
3ba7c93
Update performance test results [skip ci]
actions-user Nov 18, 2025
53ec429
Remove detailed metadata and image information for JRC2018Unisex brai…
Robbie1977 Nov 18, 2025
50f751e
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
28f5ff8
Update performance test results [skip ci]
actions-user Nov 18, 2025
4225c9c
Refactor README thumbnails for consistent escaping and add sorting fu…
Robbie1977 Nov 18, 2025
a744412
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
8f19052
Update performance test results [skip ci]
actions-user Nov 18, 2025
9dff8c5
Add detailed metadata and example queries for JRC2018Unisex brain tem…
Robbie1977 Nov 18, 2025
5adb36b
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
b19bc31
Update performance test results [skip ci]
actions-user Nov 18, 2025
01cc1d9
Update URLs in term info serialization tests to use HTTPS
Robbie1977 Nov 18, 2025
2f8c023
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
5b3c4af
Update performance test results [skip ci]
actions-user Nov 18, 2025
01f47fb
Fix license icon URL to use HTTP in term info serialization test
Robbie1977 Nov 18, 2025
4b4b425
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 18, 2025
df83af7
Update performance test results [skip ci]
actions-user Nov 18, 2025
74074fb
Refactor readme_parser to remove regex for boolean conversion and add…
Robbie1977 Nov 19, 2025
7455709
Update performance test results [skip ci]
actions-user Nov 19, 2025
9ab5fef
Implement background caching for expensive queries in SolrResultCache
Robbie1977 Nov 19, 2025
57e5b72
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
fa6a806
Update performance test results [skip ci]
actions-user Nov 19, 2025
b6ee6ad
Refactor neuron part tests to set minimum expected count and improve …
Robbie1977 Nov 19, 2025
878751a
Update performance test results [skip ci]
actions-user Nov 19, 2025
5aa23f6
updating results
Robbie1977 Nov 19, 2025
b7ec9c1
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
ab8da1b
Update performance test results [skip ci]
actions-user Nov 19, 2025
1365829
Add step to update test results in GitHub Actions workflow
Robbie1977 Nov 19, 2025
2592854
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
6041b69
Update performance test results [skip ci]
actions-user Nov 19, 2025
7bb8f0c
Fix path for updating test results in GitHub Actions workflow
Robbie1977 Nov 19, 2025
3f09175
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
1f65dba
Update performance test results [skip ci]
actions-user Nov 19, 2025
05bfb07
Fix update logic for old_results by appending new template
Robbie1977 Nov 19, 2025
985205e
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
cbf052e
Update performance test results [skip ci]
actions-user Nov 19, 2025
42188ad
Refactor test results update to use JSON for better data handling
Robbie1977 Nov 19, 2025
9746e5a
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
c20af7a
Update performance test results [skip ci]
actions-user Nov 19, 2025
f2d6b16
Add initial test cases for VFB term and instance retrieval functions
Robbie1977 Nov 19, 2025
87a6820
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
ba4a54d
Update performance test results [skip ci]
actions-user Nov 19, 2025
ebf5be4
Remove debug print statements from cached functions and Owlery client
Robbie1977 Nov 19, 2025
2bb27ab
Merge branch 'dev' of https://github.com/VirtualFlyBrain/VFBquery int…
Robbie1977 Nov 19, 2025
984cc89
Update performance test results [skip ci]
actions-user Nov 19, 2025
a9d4593
Merge branch 'main' into dev
Robbie1977 Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,25 @@ jobs:
pip install -r requirements.txt
pip install deepdiff colorama
pip install .
- name: Check SOLR availability
run: |
python -c "
import os
try:
import vfbquery as vfb
result = vfb.get_term_info('FBbt_00003748')
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write('SOLR_AVAILABLE=true\n')
print('SOLR is available')
except Exception as e:
print('SOLR not available:', e)
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write('SOLR_AVAILABLE=false\n')
exit(1)
"
- name: Run examples from README.md
run: |
cat README.md | grep -e '```python' -e '```' -e '^[^`]*$' | sed -e '/^```python/,/^```/!d' -e '/^```/d' -e 's/\(vfb.[^)]*)\)/print(\1)/g' > test_examples.py
cat README.md | grep -e '```python' -e '```' -e '^[^`]*$' | sed -e '/^```python/,/^```/!d' -e '/^```/d' -e 's/\(vfb\.[^(]*([^)]*)\)/print(\1)/g' > test_examples.py
cat test_examples.py
export VFBQUERY_CACHE_ENABLED=false
python test_examples.py
Expand All @@ -33,8 +49,10 @@ jobs:
python -m src.test.readme_parser
env:
PYTHONPATH: ${{ github.workspace }}
- name: Run examples from README.md and compare JSON outputs
if: env.SOLR_AVAILABLE == 'true'
- name: Run examples from README.md and validate structure
run: |
python -m src.test.test_examples_diff
env:
PYTHONPATH: ${{ github.workspace }}
if: env.SOLR_AVAILABLE == 'true'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ test_results.py
.pytest_cache
.venv
.vscode/settings.json
temp_examples_output.txt
json_block_*.json
85 changes: 43 additions & 42 deletions CACHING.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
# VFBquery Caching Guide

VFBquery includes intelligent caching for optimal performance. Caching is **enabled by default** with production-ready settings.
VFBquery includes intelligent SOLR-based caching for optimal performance. Caching is **enabled by default** with production-ready settings.

## Default Behavior

VFBquery automatically enables caching when imported:
VFBquery automatically enables SOLR caching when imported:

```python
import vfbquery as vfb

# Caching is already active with optimal settings:
# SOLR caching is already active with optimal settings:
# - 3-month cache duration
# - 2GB memory cache with LRU eviction
# - Persistent disk storage
# - Persistent across sessions
# - Zero configuration required

result = vfb.get_term_info('FBbt_00003748') # Cached automatically
```

## How It Works

VFBquery uses a single-layer caching approach with SOLR:

1. **First query**: Fetches data from Neo4j/Owlery and caches in SOLR
2. **Subsequent queries**: Served directly from SOLR cache
3. **Cache persistence**: Survives Python restarts and server reboots
4. **Automatic expiration**: 3-month TTL matches VFB_connect behavior

## Runtime Configuration

Adjust cache settings while your application is running:
Control caching behavior:

```python
import vfbquery as vfb

# Modify cache duration
vfb.set_cache_ttl(720) # 1 month
vfb.set_cache_ttl(24) # 1 day

# Adjust memory limits
vfb.set_cache_memory_limit(512) # 512MB
vfb.set_cache_max_items(5000) # 5K items
# Clear specific cache entries
vfb.clear_solr_cache('term_info', 'FBbt_00003748')

# Toggle disk persistence
vfb.disable_disk_cache() # Memory-only
vfb.enable_disk_cache() # Restore persistence
# Get SOLR cache statistics
stats = vfb.get_solr_cache().get_cache_stats()
```

### Environment Control
Expand All @@ -48,39 +50,38 @@ export VFBQUERY_CACHE_ENABLED=false

## Performance Benefits

VFBquery caching provides significant performance improvements:
VFBquery SOLR caching provides significant performance improvements:

```python
import vfbquery as vfb

# First query: builds cache (~1-2 seconds)
# First query: builds SOLR cache (~1-2 seconds)
result1 = vfb.get_term_info('FBbt_00003748')

# Subsequent queries: served from cache (<0.1 seconds)
# Subsequent queries: served from SOLR cache (<0.1 seconds)
result2 = vfb.get_term_info('FBbt_00003748') # 54,000x faster!

# Similarity queries are also cached
similar = vfb.get_similar_neurons('VFB_jrchk00s') # Cached after first run
```

**Typical Performance:**

- First query: 1-2 seconds
- Cached queries: <0.1 seconds
- Speedup: Up to 54,000x for complex queries
- **NBLAST similarity queries**: 10+ seconds → <0.1 seconds (cached)

## Monitoring Cache Performance

```python
import vfbquery as vfb

# Get cache statistics
stats = vfb.get_vfbquery_cache_stats()
print(f"Hit rate: {stats['hit_rate_percent']}%")
print(f"Memory used: {stats['memory_cache_size_mb']}MB")
print(f"Cache items: {stats['memory_cache_items']}")

# Get current configuration
config = vfb.get_cache_config()
print(f"TTL: {config['cache_ttl_hours']} hours")
print(f"Memory limit: {config['memory_cache_size_mb']}MB")
# Get SOLR cache statistics
cache = vfb.get_solr_cache()
stats = cache.get_cache_stats()
print(f"Total cached items: {stats['total_documents']}")
print(f"Cache size: {stats['total_size_mb']:.1f}MB")
```

## Usage Examples
Expand All @@ -90,21 +91,21 @@ print(f"Memory limit: {config['memory_cache_size_mb']}MB")
```python
import vfbquery as vfb

# Caching is enabled automatically with optimal defaults
# Adjust only if your application has specific needs
# SOLR caching is enabled automatically with optimal defaults
# Cache persists across application restarts

# Example: Long-running server with limited memory
vfb.set_cache_memory_limit(512) # 512MB limit
vfb.set_cache_ttl(168) # 1 week TTL
# Example: Long-running server
result = vfb.get_term_info('FBbt_00003748') # Fast on repeated runs
instances = vfb.get_instances('FBbt_00003748') # Cached automatically
```

### Jupyter Notebooks

```python
import vfbquery as vfb

# Caching works automatically in notebooks
# Data persists between kernel restarts
# SOLR caching works automatically in notebooks
# Data persists between kernel restarts and notebook sessions

result = vfb.get_term_info('FBbt_00003748') # Fast on repeated runs
instances = vfb.get_instances('FBbt_00003748') # Cached automatically
Expand All @@ -114,14 +115,14 @@ instances = vfb.get_instances('FBbt_00003748') # Cached automatically

- **Dramatic Performance**: 54,000x speedup for repeated queries
- **Zero Configuration**: Works out of the box with optimal settings
- **Persistent Storage**: Cache survives Python restarts
- **Memory Efficient**: LRU eviction prevents memory bloat
- **Multi-layer Caching**: Optimizes SOLR queries, parsing, and results
- **Persistent Storage**: SOLR cache survives Python restarts and server reboots
- **Server-side Caching**: Shared across multiple processes/instances
- **Similarity Queries**: NBLAST and morphological similarity searches are cached
- **Production Ready**: 3-month TTL matches VFB_connect behavior

## Best Practices

- **Monitor performance**: Use `get_vfbquery_cache_stats()` regularly
- **Adjust for your use case**: Tune memory limits for long-running applications
- **Consider data freshness**: Shorter TTL for frequently changing data
- **Monitor performance**: Use SOLR cache statistics regularly
- **Clear when needed**: Use `clear_solr_cache()` to force fresh data
- **Consider data freshness**: SOLR cache TTL ensures data doesn't become stale
- **Disable when needed**: Use environment variable if caching isn't desired
Loading