feat: Add event CLI for managing events in MCAP files - #143
Merged
Conversation
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
There was a problem hiding this comment.
💡 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".
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
description and custom key-value pairs
Features: