Skip to content

Selecting on inventory-defined fields is not supported when an inventory is attached #857

Description

@d-chambers

Once a spool carries an inventory, the fields that inventory defines should be selectable, and today they are not: spool.attach_inventory(inv).select(coupling="cement") raises InvalidSpoolQueryError because the index has no such column. The spec (API/spool.qmd) documents this workflow, so the gap is between the design and the implementation rather than in the design.

Two levels, with quite different mechanics:

Acquisition-level (whole patch). Fields of the acquisition or interrogator — gauge_length, interrogator.model. A patch matches or it does not. Resolution is pure metadata: for each distinct data_source_id and time window in the index, resolve the acquisition, test the predicate, keep or drop the row. No patch data is loaded and len(spool) stays exact.

Channel-level (within a patch). Track fields (coupling.medium), annotation groups (zone), geometry axes (latitude, z), and optical distance. These select a set of channels, which may be disjoint along the fiber, so a matching patch is trimmed and sometimes subdivided. That changes the number of patches, so it cannot be answered from the index alone; it needs a resolution pass over the inventory per row. prune_to_inventory (below) is the natural place for that pass, since it is already the documented one-time metadata cost.

What comes back on the patch. A name used in a select should arrive on the extracted patch, and nothing more: select(coupling="cement") yields patches carrying coupling.medium so the result says why each channel survived, without paying for blanket enrichment. Composed with an explicit Spool.enrich, the patch owes the union of what was asked for.

Related and not yet implemented:

  • Spool.prune_to_inventory(inventory=None) — resolve the index against the inventory, drop rows it does not describe (on_missing of raise/warn/drop), and subdivide rows straddling an epoch boundary.
  • Lazy attachment: attach_inventory should accept a path and not read it until something needs it, plus an auto-attach from a blessed name in a spool directory. This depends on the authoring-format loader, which does not exist yet.

Spool.select currently adds a note to its error naming the attached inventory and saying this is not supported yet, so the failure at least points somewhere useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    spoolrelated to Spool class

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions