Repository navigation
Feature/replace caching - #102
Conversation
…een calls so I split the tests into two functions
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (75.38%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #102 +/- ##
===========================================
+ Coverage 84.01% 88.00% +3.99%
===========================================
Files 18 18
Lines 2615 2635 +20
===========================================
+ Hits 2197 2319 +122
+ Misses 418 316 -102
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Noting that tests/test_ipr/test_upload.py takes twice as long to run with this (3 mins to 6). If we want to incorporate this change to help with use of the package at scale we should probably make it optional somehow |
where are you getting the 6m for that particular test file from? nothing in this PR should affect IPR upload as this was strictly gkb caching. |
|
test_upload is an end-to-end test that incorporates gkb matching. |
|
I did some load testing of this myself using the test_main script since interactions with IPR are not impacted by any of the changes in this PR. I ran several iterations on both versions all run from the same server both using python 3.11.6. Some run overlapping each other, some run not overlapping. It varies quite a bit depending on the load on the gkb server at the time the script is run (I was running other scripts against gkb from a different server while doing all this test) master branch this branch PR branch: 2:42 - 4:35 |
|
I've been seeing runtimes like this when I use test_upload.py to benchmark: Branch: feature/replace-caching Branch: develop (These are from alternating runs - run on feat, switch to dev, run on dev, switch to feat, etc) I tried with cache-control True and False and got basically the same times. But when I use a version of test_upload that only runs create_report once, I see better times on the feature branch than on dev: Branch: feature/replace-caching Branch: develop It seems like what's happening is the session-level implementation in feat is removing the benefit that specifically test_upload was seeing from module-level caching. So if there are multiple GKB conns being used, the benefit from caching will be removed. I think this is an improvement in normal use. I took a look at gsc_report and it looks like a single GKB conn is used for create_report so it shouldn't affect performance there. edit to add - I assume the rate limiter will slow things down though - appreciate having this disabled during tests. |
Merge branch 'feature/replace-caching' of https://github.com/bcgsc/pori_python into feature/replace-caching
…t also monkeypatch sessions
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Authentication retries, cache-only mode, rate limiting, and POST retry behavior contain correctness or reliability defects.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (5)
What changed in this PR
Replaces custom GraphKB caching with configurable requests-cache sessions, including persistent SQLite caching and cache-control options.
Changes:
- Adds cached sessions, rate-limiting support, and cache controls.
- Removes custom query and feature caches.
- Updates dependencies, tests, and CI integration-test execution.
| File | Description |
|---|---|
.github/workflows/pytest.yml |
Splits short and full test runs by Python version. |
.gitignore |
Ignores .venv. |
pori_python/graphkb/match.py |
Removes feature-cache population API. |
pori_python/graphkb/util.py |
Implements session-based caching and rate limiting. |
pori_python/graphkb/vocab.py |
Removes custom vocabulary caching. |
setup.cfg |
Adds caching and rate-limiting dependencies. |
tests/test_graphkb/test_match.py |
Removes feature-cache tests. |
tests/test_graphkb/test_statement.py |
Updates mocks and custom-category coverage. |
tests/test_ipr/test_main.py |
Re-enables report integration tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…rriting adapters. New code ensure the adapters are merged if both are present before mounting them


This replaces the custom caching with a standard caching library. It is very useful if you want to cache between scripts to (for example) an sqlite database so if you were generating many reports right after one another you could so so without having to make as many API calls. By default this will just use an in-memory cache (similar to the current behaviour) unless a cache_name is given.
However I am not sure if the one function i deleted is in use anywhere so that should be double checked with other stakeholders.