Skip to content

python(feat): add MCAP imports - #755

Open
wei-qlu wants to merge 9 commits into
mainfrom
eng-12130-sift-client-mcap-imports
Open

python(feat): add MCAP imports#755
wei-qlu wants to merge 9 commits into
mainfrom
eng-12130-sift-client-mcap-imports

Conversation

@wei-qlu

@wei-qlu wei-qlu commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds MCAP (.mcap) import support to sift_client for ROS 2 topics (ros2msg/cdr)

job = client.data_import.import_from_path("recording.mcap", asset=my_asset)

detect_config reads the file's channels locally without decoding messages, giving one entry per flattened field named <topic>.<field_path>. Edit it to select, rename, or retype channels; leave data empty to import everything.

Variable-cardinality fields are typed BYTES, with complex_types_import_mode deciding what each becomes, matching Parquet. Undecodable topics are skipped with a warning unless parse_error_policy is IGNORE_ERROR, which fails the import.

Adds the MCAP config types, DataTypeKey.MCAP, an example, and a new mcap extra.

Testing

Unit tests covering schema flattening, type mapping, topic rules, the three scan paths, and each complex types mode.

Manual imports with MCAP files

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Python docs preview: https://sift-stack.github.io/sift/python/pr-755/

Deployed from 2c81fff. The link may take up to a minute to become live as GitHub Pages propagates.

@wei-qlu
wei-qlu force-pushed the eng-12130-sift-client-mcap-imports branch from cd5f9d4 to 3534540 Compare August 27, 2026 18:16
@wei-qlu
wei-qlu requested a review from marc-sift August 27, 2026 20:19
@wei-qlu
wei-qlu marked this pull request as ready for review August 27, 2026 20:19
asset_name: The asset name to set on the config.

Returns:
A config whose ``data`` lists one channel per leaf field, with default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe say "A config who data is a flattened list of fields...`?

@wei-qlu wei-qlu Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated the wording 9028138

for topic in topics:
for leaf in topic.leaves:
name = f"{topic.topic}.{leaf.field_path}"
data_type = ChannelDataType.BYTES if leaf.kind == "complex" else leaf.sift_type()

@marc-sift marc-sift Sep 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should default to ChannelDataType.BOTH since that's what we do elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the default is both: complex_types_import_mode: McapComplexTypesImportMode = McapComplexTypesImportMode.BOTH, BYTES here just flags it before expanding, updated docstring cbff58f

record = next(records)
except StopIteration:
return
except Exception as e:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a more specific Exception we can catch?

@wei-qlu wei-qlu Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the try only wraps the mcap library call, so every error here comes from the library (EndOfFile, struct.error, decompression and decode errors)

didn't list them explicitly since a library update could make the tuple stale, added a comment for this

b0c641a

file.seek(0)
try:
summary = make_reader(file).get_summary()
except Exception:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a more specific Exception we can catch?

@wei-qlu wei-qlu Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as above, thetry only wraps the mcap call b0c641a

return leaves


def _read_schemas_and_channels(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pretty much everything in this module is private. But there's inconsistent usage of underscores. I think we can just get rid of them.

@wei-qlu wei-qlu Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed underscores entirely b0c641a

@wei-qlu
wei-qlu requested a review from marc-sift September 2, 2026 06:44
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