cellmap_flow.finetune.session.store

Which session a base output path means, and the volumes registered for painting.

Attributes

logger

SESSION_DIR_RE

Classes

SessionStore

Sessions and the volume registry, kept in the dicts it is given.

Module Contents

cellmap_flow.finetune.session.store.logger
cellmap_flow.finetune.session.store.SESSION_DIR_RE
class cellmap_flow.finetune.session.store.SessionStore(sessions: dict, volumes: dict | None = None)

Sessions and the volume registry, kept in the dicts it is given.

sessions maps a base output path to the session this process made under it (the dashboard’s get_session().output_sessions); volumes maps a volume id – its MinIO bucket key without “.zarr” – to its record (get_session().annotation_volumes). The store holds nothing else, so any number of them over the same dicts agree. Both dicts live in memory only; latest_on_disk is what finds a session again after a restart.

get_or_create(base: str) → str

The session this process uses under base: the one it made before, else a new <base>/<timestamp> (not created on disk).

latest_on_disk(base: str) → str | None

The newest session under base that has something to train on.

That is the latest <base>/<YYYYmmdd_HHMMSS>/ whose corrections/ holds a virtual-sources manifest. The in-memory map dies with the dashboard, so after a restart get_or_create hands out a new, empty session, and submitting training for the base path failed with “Corrections path does not exist” although the session painted before the restart was right there. None when there is none.

register_volume(volume_id: str, *, keep_sync_state: bool = False, **data) → dict

Record a volume being served for painting; returns its record.

The record starts with no chunk sync state, so the next sync compares MinIO against nothing and pulls every chunk. keep_sync_state updates an existing record instead, keeping the state a pull just recorded (an instance correction reattached after its pre-mirror pull).

volumes() → dict

The registry itself: volume id -> record.

session_volume(corrections_dir: str | None = None)

(volume_id, record) of the volume a session is painting, or (None, None).

That is the last one registered for corrections_dir, or for any corrections dir when it is None: a session can hold several volumes, and the latest is the one the user just made or reattached. Every route asks this, so a crop import, the good regions and training all mean the same volume; load-crops used to take the first instead, and imported into one volume while the user painted another.