Skip to content

Two disagreeing views of an .h5's identifiers: resume re-embeds and silently swaps grouped datasets #472

Description

@tsenoner

There are two competing answers to "what identifiers does this .h5 contain", and they disagree:

  • load_existing_ids (now in data/embedding/store.py) returns set(f.keys())flat, top level only. This is the resume key for both embedding backends and the completeness gate.
  • _collect_datasets in data/loaders/h5.py walks one level of groups. This is what load_h5 — and therefore every downstream stage — actually sees.

Consequences on a grouped .h5 (e.g. one produced by another tool, with a prot_t5/ group holding the datasets):

  1. Resume re-embeds everything. load_existing_ids returns {'prot_t5'}, which never intersects the protein ids, so every sequence is treated as outstanding.
  2. Duplicates are then written flat, alongside the grouped originals.
  3. load_h5 silently keeps the new flat copies and drops the originals as duplicates — h5py iterates the root alphabetically, so P12345 precedes the prot_t5 group. A stale/fresh swap with no warning.

Separately, _collect_datasets walks exactly one level, so an identifier nested two levels deep (a/b/c) is handled correctly by neither function — load_h5 omits it entirely while load_existing_ids reports 'a'.

Suggested fix. Promote _collect_datasets to a public path-taking helper (dataset_names(h5_path)) owned by h5.py, and route the resume/completeness reads through it so the gate becomes an exact predicate on what load_h5 will produce. Note this changes resume semantics — a grouped third-party .h5 would start counting as already-embedded, which is correct but is a behaviour change worth calling out. cli/annotate.py already imports the private _collect_datasets and should move to the public spelling in the same change.

Prerequisite (already shipped in fix/embed-completeness-contract): both backends now reject identifiers containing / before writing, so protspace-produced files are always flat and the two views agree for them.

Found while reviewing #430.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions