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

Add example template #2392

Merged
merged 23 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
80ca0df
add example templates
jprochazk Jun 12, 2023
5ae543d
update `python/template/main.py`
jprochazk Jun 12, 2023
dceb7d3
remove unused arg
jprochazk Jun 12, 2023
281c368
Merge branch 'main' into jan/example-template
jprochazk Jun 13, 2023
e7b4e82
Update examples/python/template/README.md
jprochazk Jun 13, 2023
3037bb3
Update examples/python/template/main.py
jprochazk Jun 13, 2023
226125c
Update examples/python/template/README.md
jprochazk Jun 13, 2023
da29309
Update examples/python/template/main.py
jprochazk Jun 13, 2023
58a4eeb
Update examples/python/template/main.py
jprochazk Jun 13, 2023
556f586
Update examples/python/template/main.py
jprochazk Jun 13, 2023
e8edfbe
Update examples/rust/template/src/main.rs
jprochazk Jun 13, 2023
e2e1bc5
Update examples/rust/template/README.md
jprochazk Jun 13, 2023
ec9cd7a
Update examples/python/template/main.py
jprochazk Jun 13, 2023
4081e04
add tags to example templates
jprochazk Jun 13, 2023
d4c7c3e
fix format
jprochazk Jun 13, 2023
faedbba
Update examples/python/template/main.py
jprochazk Jun 13, 2023
05bd8ca
Merge branch 'main' into jan/example-template
jprochazk Jun 13, 2023
327a1e5
remove log forwarding
jprochazk Jun 13, 2023
5870638
explain how to take screenshot
jprochazk Jun 13, 2023
68f2b58
Merge branch 'main' into jan/example-template
jprochazk Jun 16, 2023
29ac31d
update readmes
jprochazk Jun 16, 2023
43bebd5
hint to use `python` instead of running as executable
jprochazk Jun 16, 2023
139360d
Merge branch 'main' into jan/example-template
jprochazk Jun 16, 2023
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ tags: [2D, huggingface, object-detection, object-tracking, opencv]
The contents of this `README.md` file and its frontmatter are used to render the examples in [the documentation](https://rerun.io/examples). Individual examples are currently "stitched together" to form one large markdown file for every category of examples (`artificial-data`, `real-data`).

The `manifest.yml` file describes the structure of the examples contained in this repository. Only the examples which appear in the manifest are included in the [generated documentation](https://rerun.io/examples). The file contains a description of its own format.

## Adding a new example

You can base your example off of `python/template` or `rust/template`.
Once it's ready to be displayed in the docs, add it to the [manifest](./manifest.yml).
3 changes: 2 additions & 1 deletion examples/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
-r segment_anything_model/requirements.txt
-r signed_distance_fields/requirements.txt
-r structure_from_motion/requirements.txt
-r text_logging/requirements.txt
-r template/requirements.txt
-r text_logging/requirements.txt
18 changes: 18 additions & 0 deletions examples/python/template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Template
jprochazk marked this conversation as resolved.
Show resolved Hide resolved
tags: [kebab-case, comma, separated]
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/template/main.py
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/template/src/main.rs
---

<!--
Place a screenshot in place of this comment
Use `just upload --help` for instructions
-->

This is an example example. It is not a real example. You can duplicate the directory and use it as a starting point for writing a real example.

```bash
pip install -r examples/python/template/requirements.txt
python examples/python/template/main.py
jprochazk marked this conversation as resolved.
Show resolved Hide resolved
```
31 changes: 31 additions & 0 deletions examples/python/template/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
"""
Example template.

Run:
```sh
pip install -r examples/python/template/requirements.txt
python examples/python/template/main.py
```
"""
from __future__ import annotations

import argparse

import rerun as rr # pip install rerun-sdk


def main() -> None:
parser = argparse.ArgumentParser(description="Example of using the Rerun visualizer")
rr.script_add_args(parser)
args = parser.parse_args()

rr.script_setup(args, "my_example_name")

# ... example code

rr.script_teardown(args)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/python/template/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rerun-sdk
10 changes: 10 additions & 0 deletions examples/rust/template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "template"
version = "0.7.0-alpha.0"
edition = "2021"
rust-version = "1.69"
license = "MIT OR Apache-2.0"
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["native_viewer"] }
18 changes: 18 additions & 0 deletions examples/rust/template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Template
jprochazk marked this conversation as resolved.
Show resolved Hide resolved
tags: [kebab-case, comma, separated]
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/template/main.py
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/template/src/main.rs
---

<!--
Place a screenshot in place of this comment
Use `just upload --help` for instructions
-->

This is an example example. It is not a real example. You can duplicate the directory and use it as a starting point for writing a real example.

```bash
cargo run --release -p template
```

15 changes: 15 additions & 0 deletions examples/rust/template/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Example template.

use rerun::RecordingStreamBuilder;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let (rec_stream, storage) = RecordingStreamBuilder::new("my_example_name").memory()?;

let _ = rec_stream;

// ... example code

rerun::native_viewer::show(storage.take())?;

Ok(())
}