Skip to content

Commit 4ec817b

Browse files
[Data] Fix MCAP datasource import for better compatibility (#57964)
## Description This PR fixes the import statement in `MCAPDatasource` to follow Python best practices for explicit imports. **Change**: Updated from `import mcap` + `mcap.reader.make_reader(f)` to `from mcap.reader import make_reader` for cleaner, more explicit importing. **Why this is needed**: - Follows Python best practices for explicit imports (PEP 8) - Improves code readability by making it clear what's being used - Better compatibility with different mcap package versions - Reduces namespace pollution ## Related issues None - this is a code quality improvement. ## Additional information ### What changed **Before:** ```python import mcap reader = mcap.reader.make_reader(f) ``` **After:** ```python from mcap.reader import make_reader reader = make_reader(f) ``` ### Impact - **Minimal risk**: This is a refactoring of the import statement only - **No API changes**: The `MCAPDatasource` public API remains unchanged - **No behavioral changes**: The functionality is identical - **Tested**: All ruff lint checks pass ### File modified - `python/ray/data/_internal/datasource/mcap_datasource.py` (2 lines changed) This change makes the code more maintainable and follows modern Python conventions for explicit imports. Signed-off-by: soffer-anyscale <[email protected]>
1 parent 4181b44 commit 4ec817b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/ray/data/_internal/datasource/mcap_datasource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def _read_stream(self, f: "pyarrow.NativeFile", path: str) -> Iterator[Block]:
139139
Raises:
140140
ValueError: If the MCAP file cannot be read or has invalid format.
141141
"""
142-
import mcap
142+
from mcap.reader import make_reader
143143

144-
reader = mcap.reader.make_reader(f)
144+
reader = make_reader(f)
145145
# Note: MCAP summaries are optional and iter_messages works without them
146146
# We don't need to validate the summary since it's not required
147147

0 commit comments

Comments
 (0)