Skip to content

Add NotificationSummary class for structured, version-stamped inspection reports#353

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-notification-summary-class
Draft

Add NotificationSummary class for structured, version-stamped inspection reports#353
Copilot wants to merge 2 commits intomainfrom
copilot/add-notification-summary-class

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 19, 2026

Notifications were written as a raw JSON array with no version-stamping, no human-readable format, and no aggregation of repeated notification types.

New: NotificationSummary

Introduced nwb2bids.NotificationSummary — a lightweight wrapper around a list of notifications that produces structured, version-stamped reports.

import nwb2bids

dataset_converter = nwb2bids.convert_nwb_dataset(nwb_paths=[...], run_config=run_config)
summary = nwb2bids.NotificationSummary(
    notifications=dataset_converter.notifications,
    run_id=run_config.run_id,
)

print(summary)          # aggregated human-readable report
summary.to_json()       # full non-aggregated JSON string (all individual entries)
summary.to_file(path)   # write .json or .txt based on suffix; aggregate=True by default

Key behaviors

  • __str__ — aggregated by identifier, with occurrence count and merged file paths per type; suitable for notebooks and IPython
  • to_json() — full, non-aggregated dump; wraps the notifications array in {"nwb2bids_version": ..., "run_id": ..., "notifications": [...]}
  • to_file(path, aggregate=True) — format inferred from suffix (.json vs text); aggregated by default (one entry per notification type with count field and merged paths), aggregate=False writes every individual notification

Updated: DatasetConverter.convert_to_bids_dataset()

Now uses NotificationSummary and writes both the .txt (human-readable) and .json (structured) report files on every run. Previously only the JSON file was written and it lacked version metadata.

Breaking change to .json report format

The {run_id}_notifications.json file is now a JSON object rather than a bare array:

{
  "nwb2bids_version": "0.1.0",
  "run_id": "datetime-20240101120000",
  "notifications": [
    { "identifier": "InvalidSpecies", "count": 2, "severity": "ERROR", ... }
  ]
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Generate nice 'report' of inspections</issue_title>
<issue_description>Right now I just form and dump a list of messages through .model_dump on each message of a DatasetConverter

Would be nice to create (and version-stamp) official report structure in both human readable text and JSON, similar to BIDs and NWB Inspector</issue_description>

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

@CodyCBakerPhD Plan:
  • introduce a new class, the NotificationSummary which takes a list of notifications as input
  • this class should have a nice-looking __str__ override for printing out in places like notebooks and ipython consoles
  • it should have to_json (dumps all information in full) and to_file (with a flag determining whether to aggregate over similar types of notifications or show all information; default is to aggregate methods)
  • this should be used in place of the other method which dumps notifications to the .nwb2bids directory and should dump a copy of both files by default</comment_new>

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

- Add `NotificationSummary` class in `notifications/_notification_summary.py`
  with `__str__`, `to_json()`, and `to_file(path, aggregate=True)` methods
- Export `NotificationSummary` from `notifications/__init__.py` and top-level `__init__.py`
- Update `DatasetConverter.convert_to_bids_dataset()` to use `NotificationSummary`
  and write both `.json` and `.txt` report files
- Update integration test to match new JSON structure (dict with version/run_id/notifications)
- Add unit tests in `tests/unit/test_notification_summary.py`

Co-authored-by: CodyCBakerPhD <51133164+CodyCBakerPhD@users.noreply.github.com>
Copilot AI changed the title [WIP] Add report generation for inspections with NotificationSummary class Add NotificationSummary class for structured, version-stamped inspection reports Mar 19, 2026
Copilot AI requested a review from CodyCBakerPhD March 19, 2026 03:51
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.

Generate nice 'report' of inspections

2 participants