Skip to content

Add CATMAID pass-through for the hosted instances - #95

Merged
Robbie1977 merged 6 commits into
mainfrom
catmaid-passthrough
Aug 29, 2026
Merged

Add CATMAID pass-through for the hosted instances#95
Robbie1977 merged 6 commits into
mainfrom
catmaid-passthrough

Conversation

@Robbie1977

@Robbie1977 Robbie1977 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

What changed

New catmaid_client module exposing the VFB-hosted CATMAID instances (registry and anonymous read-only tokens fetched from https://virtualflybrain.org/data/EM/catmaid.json, cached for the whole run) through a curated, read-only command registry — skeletons, SWC export, connectivity, connectivity matrix, annotations, connectors, labels, nodes, stats and landmarks. Anywhere a command takes skeleton ids you can pass CATMAID skids, VFB ids or a mixed list: VFB ids are converted through the KB's database_cross_reference xrefs (site map derived live from Site link_base URLs, static fallback), and CATMAID neuron ids are bridged from skids via neurons/from-models. Results default to a VFB envelope with id_map/unmatched/reverse_map; raw=True (or ?raw=true) returns the untouched CATMAID response.

swc additionally takes aligned= naming a template space (short_form or label, e.g. aligned=JRC2018Unisex), serving VFB's template-registered volume.swc from the image store instead of CATMAID's EM-space skeleton — a skid input is reverse-mapped to its VFB record first. aligned=vfb means "the VFB copy" and works while a single registration exists; once neurons are registered to several spaces (e.g. a unified brain+VNC template) it errors listing the choices. aligned=original or omitted is the CATMAID original. A companion swc_alignments command lists the spaces an SWC is available in for one neuron — the original plus each VFB registration, HEAD-checked for an actual volume.swc and carrying the aligned= value that fetches it.

The HA API gains GET /catmaid, GET /catmaid/{instance} and GET /catmaid/{instance}/{command}?ids=…[&project=][&raw=true] on the shared dispatch machinery. The path allowlist learns prefix routes, and _dispatch_to_pool grows an opt-in client_error_types so caller mistakes come back as 400s (only the /catmaid handlers set it).

Why

Third-party tools and VFBchat need CATMAID data addressed by VFB ids without every client reimplementing token handling, id conversion and the skid↔neuron-id dance.

How to test

pytest src/test/test_catmaid_passthrough.py (unit + integration-marked live tests), or python -m vfbquery.ha_api and curl 'localhost:8080/catmaid/fafb/neuron_names?ids=VFB_001011rj,10603863'.

Follow-ups left

larva1099 is skid-only until its neurons are loaded into VFB; abd1.5, iav-robo, iav-tnt and l3vnc host mutant specimens outside VFB's wildtype-based data model, so they are expected to stay skid-only. NBLAST compare and point/pointcloud reads were left out of the registry pending a use case.

New catmaid_client module: a curated read-only registry of ~49 CATMAID
API commands runnable against any VFB-hosted instance (registry and
anonymous tokens fetched from virtualflybrain.org/data/EM/catmaid.json).
Commands that take skeleton ids accept CATMAID skids, VFB ids or a
mixed list; VFB ids are converted through the KB's
database_cross_reference xrefs (site map derived live from the Site
link_base URLs, static fallback), and CATMAID neuron ids are bridged
from skids via neurons/from-models since the KB does not store them.

Results default to a VFB envelope carrying id_map/unmatched plus a
reverse_map of skid-shaped result keys back to VFB ids; raw=True (or
?raw=true) returns the untouched CATMAID response, sharing one cache
entry with the wrapped view.

ha_api gains GET /catmaid, /catmaid/{instance} and
/catmaid/{instance}/{command}, riding the shared dispatch machinery;
the path allowlist learns prefix routes, and _dispatch_to_pool grows an
opt-in client_error_types so worker-side ValueErrors surface as 400s
rather than 500s (only the /catmaid handlers set it).

Only the FAFB, FANC and L1EM projects have skid xrefs in the KB, so the
other instances are skid-only; a VFB id passed there errors clearly.
swc grows aligned=true (with optional template=), serving the template-
registered volume.swc from the VFB image store instead of CATMAID's
EM-space skeleton. A skid input is reverse-mapped to its VFB record
first; registrations come from the KB's in_register_with folders, and a
neuron registered to several templates asks the caller to pick rather
than guessing.

catmaid.json now caches for the whole run by default (TTL 0); a
positive VFBQUERY_CATMAID_CONFIG_TTL restores periodic refresh for
long-lived servers.
aligned=True plus a separate template= read as one boolean choice, but
VFB will soon register nearly every adult neuron to two spaces (JRC2018U
and the planned unified brain+VNC template), so the option now takes a
value: a template short_form or label picks the space, vfb/true means
'the VFB copy' and works only while a single registration exists (it
errors listing the choices otherwise), and original/catmaid/omitted is
the CATMAID EM-space skeleton. The separate template= parameter is gone
before anyone depends on it.
larva1099 is simply not yet loaded into VFB, so its xrefs will arrive
with the data; abd1.5, iav-robo, iav-tnt and l3vnc host mutant
specimens, which sit outside VFB's wildtype-based data model, so no
xref import is planned for them.
One row for the original EM-space skeleton (CATMAID) plus one per VFB
template registration, each HEAD-checked for an actual volume.swc in
the image store and carrying the aligned= value that fetches it through
the swc command. A skid with no VFB record lists the original only,
with a note. First local (VFBquery-answered) registry command; the
registry gains a 'local' flag for it.
The test-examples job wraps every vfb.*(...) call in print(), so
'fafb = vfb.catmaid(...)' became 'fafb = print(...)' and every later
fafb call exploded on None. Import catmaid directly for the
instantiation line — the rewrite leaves it alone — and the block runs
clean under the exact CI sed (verified locally against live services).
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

⚠️ 7 test(s) skipped — VFB backend was unreachable

The full suite ran, but 7 test(s) were skipped because the VFB backend (Neo4j / SOLR / Owlery) did not answer during this run.

These are not failures and not a problem with this branch — but those queries went unverified, so a green check here is an incomplete run.

To re-run: open this workflow run and click Re-run all jobs once the backend is healthy (re-running the “Run completeness” check itself does nothing — it has no job behind it).

721 passed, 7 skipped, 340 warnings in 959.90s (0:15:59)

Posted automatically. This comment is removed once a run completes with zero skips.

@Robbie1977
Robbie1977 merged commit b5f5710 into main Aug 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant