-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: External data-loader example | ||
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/external_data_loader/main.py?speculative-link | ||
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/external_data_loader/src/main.rs?speculative-link | ||
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/external_data_loader/main.cpp?speculative-link | ||
thumbnail: https://static.rerun.io/external_data_loader_rust/45b1312910063086708d2db52dc3eb619e741d8c/480w.png | ||
--- | ||
|
||
<picture> | ||
<img src="https://static.rerun.io/external_data_loader_rust/45b1312910063086708d2db52dc3eb619e741d8c/full.png" alt=""> | ||
<source media="(max-width: 480px)" srcset="https://static.rerun.io/external_data_loader_rust/45b1312910063086708d2db52dc3eb619e741d8c/480w.png"> | ||
<source media="(max-width: 768px)" srcset="https://static.rerun.io/external_data_loader_rust/45b1312910063086708d2db52dc3eb619e741d8c/768w.png"> | ||
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/external_data_loader_rust/45b1312910063086708d2db52dc3eb619e741d8c/1024w.png"> | ||
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/external_data_loader_rust/45b1312910063086708d2db52dc3eb619e741d8c/1200w.png"> | ||
</picture> | ||
|
||
This is an example executable data-loader plugin for the Rerun Viewer. | ||
|
||
It will log Python source code files as markdown documents. | ||
To try it out, copy it in your $PATH as `rerun-loader-python-file`, then open a Python source file with Rerun (`rerun file.py`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
"""Example of an executable data-loader plugin for the Rerun Viewer.""" | ||
from __future__ import annotations | ||
|
||
import argparse | ||
import os | ||
|
||
import rerun as rr # pip install rerun-sdk | ||
|
||
# The Rerun Viewer will always pass these two pieces of information: | ||
# 1. The path to be loaded, as a positional arg. | ||
# 2. A shared recording ID, via the `--recording-id` flag. | ||
# | ||
# It is up to you whether you make use of that shared recording ID or not. | ||
# If you use it, the data will end up in the same recording as all other plugins interested in | ||
# that file, otherwise you can just create a dedicated recording for it. Or both. | ||
parser = argparse.ArgumentParser( | ||
description=""" | ||
This is an example executable data-loader plugin for the Rerun Viewer. | ||
It will log Python source code files as markdown documents. | ||
To try it out, copy it in your $PATH as `rerun-loader-python-file`, then open a Python source file with Rerun (`rerun file.py`). | ||
""" | ||
) | ||
parser.add_argument("filepath", type=str) | ||
parser.add_argument("--recording-id", type=str) | ||
args = parser.parse_args() | ||
|
||
|
||
def main() -> None: | ||
is_file = os.path.isfile(args.filepath) | ||
is_rust_file = os.path.splitext(args.filepath)[1].lower() == ".py" | ||
|
||
# We're not interested: just exit silently. | ||
# Don't return an error, as that would show up to the end user in the Rerun Viewer! | ||
if not (is_file and is_rust_file): | ||
return | ||
|
||
rr.init("rerun_example_external_loader", recording_id=args.recording_id) | ||
# The most important part of this: log to standard output so the Rerun Viewer can ingest it! | ||
rr.stdout() | ||
|
||
with open(args.filepath) as file: | ||
body = file.read() | ||
text = f"""## Some Python code\n```python\n{body}\n```\n""" | ||
rr.log(args.filepath, rr.TextDocument(text, media_type=rr.MediaType.MARKDOWN), timeless=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rerun-sdk |