Skip to content

Log Cell Annotation store initialization and tighten scaffolding coverage#70

Merged
yulewu merged 2 commits into
cell_annotationfrom
copilot/add-cell-annotation-plugin-again
Mar 17, 2026
Merged

Log Cell Annotation store initialization and tighten scaffolding coverage#70
yulewu merged 2 commits into
cell_annotationfrom
copilot/add-cell-annotation-plugin-again

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown

This PR completes the remaining scaffolding for the Cell Annotation plugin lifecycle: when the feature flag is enabled, dataset open now emits the resolved .UELer store path, and the storage tests cover the expected atomic-write and persistence guarantees more explicitly.

  • Plugin lifecycle

    • Log the resolved dataset store path from CellAnnotationPlugin.on_dataset_opened().
    • Accept ENABLE_CELL_ANNOTATION=on in addition to the existing truthy flag values.
  • Atomic storage semantics

    • Extend coverage to assert atomic_write_json() does not leave visible temp files after a successful replace.
    • Extend coverage to assert atomic_replace() fsyncs both the source and destination directories around os.replace().
  • Scaffolding behavior coverage

    • Add focused coverage for dataset-open logging so the plugin’s checkpoint/store initialization is externally visible when enabled.

Example of the plugin-open signal added here:

def on_dataset_opened(self, base_folder: str | Path) -> None:
    self._store = DatasetStore(base_folder)
    self._store.ensure_dirs()
    self._manifest = Manifest(self._store.store_path)
    if self._manifest.load() is None:
        self._manifest.rebuild_from_disk()
    logger.info("[CellAnnotation] dataset store ready: %s", self._store.store_path)
Original prompt

This section details on the original issue you should resolve

<issue_title>Sub-issue: Plugin Scaffolding — Cell Annotation + Storage</issue_title>
<issue_description># Plugin: Create Cell Annotation plugin skeleton & storage scaffolding

Tracked by: #15
Milestone: M1 — Scaffolding
Labels: area:cell-annotation, area:storage, type:infra, size:M, priority:P1

Summary

Add a new Cell Annotation plugin that owns checkpoint orchestration and .UELer persistence. Provide storage helpers and lifecycle hooks so the plugin initializes per-dataset folders.

Scope

In

  • New package viewer/plugins/cell_annotation/
    • plugin.py: orchestrator class, event hooks (on_dataset_opened/closed)
    • store.py: .UELer resolver, dataset ID hashing, atomic write helpers (temp → fsync → os.replace)
    • manifest.py: thin wrapper (stub for now) with load(), save_atomic(), rebuild_from_disk()
  • Wire plugin registration into the viewer bootstrap so it’s available behind a feature flag

Out

  • No UI yet (browser, dialogs)
  • No AnnData serialization (handled in Serializer sub-issue)

Deliverables

  • plugins/cell_annotation/{__init__.py,plugin.py,store.py,manifest.py}
  • Feature flag: ENABLE_CELL_ANNOTATION (env/config) gates registration
  • Dataset-level folders on open:
.UELer/dataset_<stable-id>/
checkpoints/
thumbnails/
selections/
manifest.json (may not exist yet)
  • Atomic write helper functions:
  • atomic_write_json(path, obj)
  • atomic_replace(src_tmp, dst_final) (fsync file + dir)

Acceptance Criteria

  • With flag on, plugin loads and logs dataset store path on open
  • .UELer/dataset_<stable-id>/{checkpoints,thumbnails,selections} created if missing
  • atomic_write_json() writes a file recoverable after simulated crash (no partials left visible)
  • With flag off, plugin does not register; app runs unchanged

Test Plan

  • Unit: store path resolution from dataset root; atomic write semantics (fsync + replace)
  • Integration: open dataset → folders exist; toggle flag on/off
  • Windows path test: ensure no file handle leaks; partial files ignored by future scans

Dependencies

<agent_instructions>This is a sub-issue of Issue #15</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: yulewu <38241047+yulewu@users.noreply.github.com>
Copilot AI changed the title [WIP] [HartmannLab/UELer#15] Add Cell Annotation plugin skeleton and storage scaffolding Log Cell Annotation store initialization and tighten scaffolding coverage Mar 17, 2026
Copilot AI requested a review from yulewu March 17, 2026 23:33
@yulewu yulewu marked this pull request as ready for review March 17, 2026 23:36
@yulewu yulewu merged commit fb216d2 into cell_annotation Mar 17, 2026
4 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.

2 participants