Skip to content

Commit

Permalink
Support pathlib.Path for rr.save (#4036)
Browse files Browse the repository at this point in the history
- Fixes #4024
  • Loading branch information
teh-cmc authored Oct 27, 2023
1 parent 689ac2c commit 4fed666
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
from ..components import MediaType


def guess_media_type(path: str) -> MediaType | None:
from pathlib import Path

def guess_media_type(path: str | pathlib.Path) -> MediaType | None:
from ..components import MediaType

ext = Path(path).suffix.lower()
ext = pathlib.Path(path).suffix.lower()
if ext == ".glb":
return MediaType.GLB
elif ext == ".gltf":
Expand Down
5 changes: 3 additions & 2 deletions rerun_py/rerun_sdk/rerun/sinks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import pathlib
import socket

import rerun_bindings as bindings # type: ignore[attr-defined]
Expand Down Expand Up @@ -42,7 +43,7 @@ def connect(
_connect = connect # we need this because Python scoping is horrible


def save(path: str, recording: RecordingStream | None = None) -> None:
def save(path: str | pathlib.Path, recording: RecordingStream | None = None) -> None:
"""
Stream all log-data to a file.
Expand All @@ -64,7 +65,7 @@ def save(path: str, recording: RecordingStream | None = None) -> None:
return

recording = RecordingStream.to_native(recording)
bindings.save(path=path, recording=recording)
bindings.save(path=str(path), recording=recording)


def disconnect(recording: RecordingStream | None = None) -> None:
Expand Down

0 comments on commit 4fed666

Please sign in to comment.