Skip to content

feat: Add event CLI for managing events in MCAP files - #143

Merged
siliconlad merged 15 commits into
mainfrom
claude/add-event-cli-YrJs2
Feb 7, 2026
Merged

feat: Add event CLI for managing events in MCAP files#143
siliconlad merged 15 commits into
mainfrom
claude/add-event-cli-YrJs2

Conversation

@siliconlad

Copy link
Copy Markdown
Owner

Events allow users to mark significant occurrences in MCAP recordings,
such as collisions, waypoints, or other notable moments. Events are
stored as metadata records with a special name prefix (pybag.event).

New CLI subcommands:

  • pybag event list - List events with optional filtering by name/time
  • pybag event add - Add new events with optional
    description and custom key-value pairs
  • pybag event delete - Delete events with optional filtering

Features:

  • Events support timestamps, names, descriptions, and custom fields
  • JSON output format supported for list command
  • Time range filtering for list and delete operations
  • Preserves all existing messages, attachments, and metadata
  • Events are only supported for MCAP format (not bag files)

Events allow users to mark significant occurrences in MCAP recordings,
such as collisions, waypoints, or other notable moments. Events are
stored as metadata records with a special name prefix (pybag.event).

New CLI subcommands:
- pybag event list <file> - List events with optional filtering by name/time
- pybag event add <file> <name> <timestamp> - Add new events with optional
  description and custom key-value pairs
- pybag event delete <file> - Delete events with optional filtering

Features:
- Events support timestamps, names, descriptions, and custom fields
- JSON output format supported for list command
- Time range filtering for list and delete operations
- Preserves all existing messages, attachments, and metadata
- Events are only supported for MCAP format (not bag files)
… file

The event add command now modifies the MCAP file directly by appending
the new event metadata record and updating the summary section in place.
This is more efficient than rewriting the entire file and matches the
expected behavior where events are added to an existing recording.

Changes:
- Remove output path, chunk-size, chunk-compression, and overwrite options
  from the event add command (no longer needed)
- Use McapSummaryFactory with FileReader to load existing summary
- Use McapRecordWriterFactory in append mode to write the new metadata
- Update tests to reflect in-place modification behavior
The clip command extracts a portion of an MCAP file centered on an
event's timestamp, making it easy to isolate specific incidents from
larger recordings.

Features:
- Symmetric margins: --before 5 uses 5s before AND after
- Asymmetric: --before 2 --after 10 for different margins
- Default: 5 seconds before and after if not specified
- Reuses filter_mcap for actual extraction
- Supports topic filtering with --include-topic/--exclude-topic
- Supports all filter options (chunk-size, compression, overwrite)

Example usage:
  pybag event clip recording.mcap "collision" --before 5 --after 10
  pybag event clip recording.mcap "incident" --before 2
  pybag event clip recording.mcap "start"  # defaults to 5s each way
Document the new event command and its subcommands:
- event list: List events with optional filtering
- event add: Add events to MCAP files (appends in place)
- event delete: Remove events from MCAP files
- event clip: Extract MCAP portion around an event timestamp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40326c366a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/pybag/cli/event.py Outdated
Comment thread src/pybag/cli/event.py Outdated
claude and others added 11 commits January 23, 2026 21:37
Change clip command behavior:
- --before X: clips from (event_time - X) to event_time
- --after X: clips from event_time to (event_time + X)
- --margin X: symmetric, clips X seconds before AND after (new flag)
- --before X --after Y: clips from (event_time - X) to (event_time + Y)

The --margin flag cannot be combined with --before or --after.
If no options are specified, defaults to --margin 5.

Updated tests and README documentation to reflect new behavior.
Events are now soft deleted by default by marking them with a deleted
field in the metadata, which doesn't require rewriting the entire MCAP.
Use --force to perform a hard delete that rewrites the file.

Changes:
- Add soft_delete_events_mcap for in-place deletion marking
- Rename delete_events_mcap to hard_delete_events_mcap
- Update delete CLI with --force flag (default is soft delete)
- Add --include-deleted flag to list command
- Update clip to skip soft-deleted events
- Update tests and README documentation
Instead of using --force for hard delete, the -o flag now determines
whether operations modify the file in place or create a copy:

- event add: append in place by default, copy with -o
- event delete: soft delete in place by default, hard delete with -o

This provides consistent semantics for both add and delete commands.
@siliconlad
siliconlad merged commit 240b22a into main Feb 7, 2026
12 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