Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pathlib.Path for rr.save #4036

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading