|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from pathlib import Path |
3 | 4 | from typing import Any, Iterable |
4 | 5 |
|
5 | 6 | import pyarrow as pa |
@@ -282,6 +283,72 @@ def log_components( |
282 | 283 | ) |
283 | 284 |
|
284 | 285 |
|
| 286 | +@catch_and_log_exceptions() |
| 287 | +def log_file_from_path( |
| 288 | + file_path: str | Path, |
| 289 | + *, |
| 290 | + recording: RecordingStream | None = None, |
| 291 | +) -> None: |
| 292 | + r""" |
| 293 | + Logs the file at the given `path` using all `re_data_source::DataLoader`s available. |
| 294 | +
|
| 295 | + A single `path` might be handled by more than one loader. |
| 296 | +
|
| 297 | + This method blocks until either at least one `re_data_source::DataLoader` starts |
| 298 | + streaming data in or all of them fail. |
| 299 | +
|
| 300 | + See <https://www.rerun.io/docs/howto/open-any-file> for more information. |
| 301 | +
|
| 302 | + Parameters |
| 303 | + ---------- |
| 304 | + file_path: |
| 305 | + Path to the file to be logged. |
| 306 | +
|
| 307 | + recording: |
| 308 | + Specifies the [`rerun.RecordingStream`][] to use. If left unspecified, |
| 309 | + defaults to the current active data recording, if there is one. See |
| 310 | + also: [`rerun.init`][], [`rerun.set_global_data_recording`][]. |
| 311 | +
|
| 312 | + """ |
| 313 | + |
| 314 | + bindings.log_file_from_path(Path(file_path), recording=recording) |
| 315 | + |
| 316 | + |
| 317 | +@catch_and_log_exceptions() |
| 318 | +def log_file_from_contents( |
| 319 | + file_path: str | Path, |
| 320 | + file_contents: bytes, |
| 321 | + *, |
| 322 | + recording: RecordingStream | None = None, |
| 323 | +) -> None: |
| 324 | + r""" |
| 325 | + Logs the given `file_contents` using all `crate::DataLoader`s available. |
| 326 | +
|
| 327 | + A single `path` might be handled by more than one loader. |
| 328 | +
|
| 329 | + This method blocks until either at least one `re_data_source::DataLoader` starts |
| 330 | + streaming data in or all of them fail. |
| 331 | +
|
| 332 | + See <https://www.rerun.io/docs/howto/open-any-file> for more information. |
| 333 | +
|
| 334 | + Parameters |
| 335 | + ---------- |
| 336 | + file_path: |
| 337 | + Path to the file that the `file_contents` belong to. |
| 338 | +
|
| 339 | + file_contents: |
| 340 | + Contents to be logged. |
| 341 | +
|
| 342 | + recording: |
| 343 | + Specifies the [`rerun.RecordingStream`][] to use. If left unspecified, |
| 344 | + defaults to the current active data recording, if there is one. See |
| 345 | + also: [`rerun.init`][], [`rerun.set_global_data_recording`][]. |
| 346 | +
|
| 347 | + """ |
| 348 | + |
| 349 | + bindings.log_file_from_contents(Path(file_path), file_contents, recording=recording) |
| 350 | + |
| 351 | + |
285 | 352 | def escape_entity_path_part(part: str) -> str: |
286 | 353 | r""" |
287 | 354 | Escape an individual part of an entity path. |
|
0 commit comments