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

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

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.
The project depends on dump-things-pyclient (main branch from Forgejo)
which requires Python >= 3.11, so this change matches the dependency
requirements.

This is mostly inconsequential, but for example uv run would complain
about the mismatch.
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 commit 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).
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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u more-cache-and-tweaks:msz-more-cache-and-tweaks
git switch msz-more-cache-and-tweaks

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff msz-more-cache-and-tweaks
git switch msz-more-cache-and-tweaks
git rebase main
git switch main
git merge --ff-only msz-more-cache-and-tweaks
git switch msz-more-cache-and-tweaks
git rebase main
git switch main
git merge --no-ff msz-more-cache-and-tweaks
git switch main
git merge --squash msz-more-cache-and-tweaks
git switch main
git merge --ff-only msz-more-cache-and-tweaks
git switch main
git merge msz-more-cache-and-tweaks
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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.