Add partial cache support to inject-links-pid #6

Closed
msz wants to merge 1 commit from msz/query-rse-group:more-cache-and-tweaks into main
Owner

The --record-cache argument in inject_links_pid was available but the cache was never used by the command. Given that this command normally requests records to be looked up from the Pool by class (not by single PID) it is not obvious what a full implementation of cache should look like (commands which fetch one PID at a time can consult cache first and API only if not cached).

This PR adds partial, but hopefully intuitive cache handling. If the option --only-from-cache is given, then no requests to the API will be made; instead, all cached records (and cached records only) will be scanned, filtered by class name (if requested), checked whether they link the given object, and injected.

No writing to cache is done. If the --only-from-cache option is not used, the cache is ignored (as previously).

This "inject from cache" was motivated by the following use case: extending Person records with their Project roles. This can be done as follows: Fetch project records, inline associated_with::roles, save in cache, then run inject-links-pid --only-from-cache to inject projects with roles inlined (inline-records currently can't deal with nested properties).

Note: This PR also bundled smaller tweaks in pyproject.toml which have since been cherry-picked by @mih (thanks!). I rebased & force-pushed the branch to get rid of (now empty) commits.

The `--record-cache` argument in `inject_links_pid` was available but the cache was never used by the command. Given that this command normally requests records to be looked up from the Pool by class (not by single PID) it is not obvious what a full implementation of cache should look like (commands which fetch one PID at a time can consult cache first and API only if not cached). This PR adds partial, but hopefully intuitive cache handling. If the option `--only-from-cache` is given, then no requests to the API will be made; instead, all cached records (and cached records only) will be scanned, filtered by class name (if requested), checked whether they link the given object, and injected. No writing to cache is done. If the `--only-from-cache` option is not used, the cache is ignored (as previously). This "inject from cache" was motivated by the following use case: extending Person records with their Project roles. This can be done as follows: Fetch project records, inline `associated_with::roles`, save in cache, then run inject-links-pid --only-from-cache to inject projects with roles inlined (inline-records currently can't deal with nested properties). Note: This PR also bundled smaller tweaks in `pyproject.toml` which have since been cherry-picked by @mih (thanks!). I rebased & force-pushed the branch to get rid of (now empty) commits.
msz referenced this pull request from a commit 2026-03-06 19:50:43 +00:00
msz force-pushed more-cache-and-tweaks from 8079dbd9fe to 16a7b74f82 2026-03-09 11:21:31 +00:00 Compare
msz force-pushed more-cache-and-tweaks from 16a7b74f82 to fb5b766334 2026-03-09 11:28:43 +00:00 Compare
msz changed title from Add partial cache support to inject-links-pid, small pyproject update to Add partial cache support to inject-links-pid 2026-03-09 11:30:07 +00:00
mih referenced this pull request from a commit 2026-03-10 07:11:39 +00:00
Owner

I am finding this PR just now. No memory of having seen this before, but my own commit in www-from-model proves otherwise.

The --cache option in inject-links-pid appears to be unused still.

TBH, I do not like adding an option to interpret what the cache should be used for, whenever it is really just a choice between ONLY and NOTATALL. But the situation is messy to begin with, and the proposed solution certainly does not make it worse.

I need to add some tests, before I look more closely re a merge.

I am finding this PR just now. No memory of having seen this before, but my own commit in www-from-model proves otherwise. The --cache option in inject-links-pid appears to be unused still. TBH, I do not like adding an option to interpret what the cache should be used for, whenever it is really just a choice between ONLY and NOTATALL. But the situation is messy to begin with, and the proposed solution certainly does not make it worse. I need to add some tests, before I look more closely re a merge.
mih referenced this pull request from a commit 2026-08-26 07:03:10 +00:00
Owner

I am closing this PR, having filed #9

I think it is better to take a fresh look at the problem, now that a new set of tools became available.

I am closing this PR, having filed https://hub.psychoinformatics.de/orinoco/query-things/issues/9 I think it is better to take a fresh look at the problem, now that a new set of tools became available.
mih closed this pull request 2026-08-27 12:58:20 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
orinoco/query-things!6
No description provided.