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

Split examples by language #1181

Merged
merged 29 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e9245db
Split python and rust examples into separate folders
emilk Feb 10, 2023
df4737a
objectron: ensure logging reaches the screen
emilk Feb 10, 2023
6e829e4
try fix
emilk Feb 10, 2023
2ae70b9
remove dead shellscript
emilk Feb 10, 2023
497ed70
fix objectron build-script
emilk Feb 10, 2023
a3eeb5a
Fixes
emilk Feb 10, 2023
9f90b82
Fix Rust objectron demo
emilk Feb 10, 2023
1c1b95d
Add readme for rust examples
emilk Feb 10, 2023
63e3e51
lint
emilk Feb 10, 2023
6fa1237
fix mypy
emilk Feb 10, 2023
06b8785
Merge branch 'main' into emilk/split-examples-by-language
teh-cmc Feb 10, 2023
47fcaee
Improve the docs of `rerun` (#1179)
emilk Feb 10, 2023
7a3041d
Add newlines before types, `impl`, `fn`, and docstrings
emilk Feb 10, 2023
2bea9d7
Update examples/requirements.txt
emilk Feb 10, 2023
a5dc541
Mark git directories as safe for our docker_ci container and fix carg…
jleibs Feb 10, 2023
b1557d1
Run cargo check after patching pre-release (#1190)
jleibs Feb 10, 2023
74be952
Allow logging the contents of an image file, not by path (#1193)
emilk Feb 11, 2023
a2a7780
Add --dataset and --resize flags to colmap (#1177)
jleibs Feb 11, 2023
e94670c
Enable `--web-viewer` in the Python Wheels (#1182)
emilk Feb 11, 2023
59cc8b7
Install web dependencies before running cargo check (#1196)
jleibs Feb 11, 2023
8bb3bf6
Update arrow2, arrow2_convert and polars (#1189)
emilk Feb 11, 2023
63244bc
Turn on and fix Python linting of examples (#1191)
emilk Feb 11, 2023
e525e3b
Merge branch 'main' into emilk/split-examples-by-language
emilk Feb 11, 2023
e748f92
Update the paths in .flake8
emilk Feb 11, 2023
e921307
Merge branch 'main' into emilk/split-examples-by-language
teh-cmc Feb 11, 2023
cbf1a51
examples/deep_sdf: sort scenes by relevance instead of lexically + be…
teh-cmc Feb 11, 2023
82b4a59
examples/raw_mesh: sort scenes by relevance instead of lexically + be…
teh-cmc Feb 11, 2023
c37d567
examples/raw_mesh: now offering a higher level --scene flag
teh-cmc Feb 11, 2023
79559b3
Merge remote-tracking branch 'origin/main' into emilk/split-examples-…
teh-cmc Feb 11, 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
6 changes: 3 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ extend-exclude =
target/,

# generated
examples/objectron/dataset/proto/objectron/proto.py,
examples/python/objectron/proto/objectron/proto.py,

# Copied from https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py
examples/stable_diffusion/huggingface_pipeline.py,
examples/python/stable_diffusion/huggingface_pipeline.py,

# Copied from https://github.com/colmap/colmap/blob/bf3e19140f491c3042bfd85b7192ef7d249808ec/scripts/python/read_write_model.py
examples/colmap/read_write_model.py,
examples/python/colmap/read_write_model.py,
10 changes: 5 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
paths:
- "rerun_py/**"
- "examples/**"
- "examples/python/**"
- ".github/workflows/python.yml"
push:
branches:
Expand Down Expand Up @@ -152,8 +152,8 @@ jobs:
- name: Generate Embedded RRD file
shell: bash
run: |
pip install -r examples/car/requirements.txt
python examples/car/main.py --headless --save car.rrd
pip install -r examples/python/car/requirements.txt
python examples/python/car/main.py --headless --save car.rrd
cp car.rrd rerun_py/rerun_sdk/rerun_demo/demo.rrd

- name: Build Wheel
Expand All @@ -179,8 +179,8 @@ jobs:

- name: Run Car example
run: |
pip install -r examples/car/requirements.txt
./examples/car/main.py --headless
pip install -r examples/python/car/requirements.txt
./examples/python/car/main.py --headless

- name: Upload wheels
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
files = rerun_py/rerun_sdk/rerun, rerun_py/tests, examples
exclude = examples/objectron/dataset/proto
files = rerun_py/rerun_sdk/rerun, rerun_py/tests, examples/python
exclude = examples/python/objectron/proto
namespace_packages = True
show_error_codes = True
strict = True
Expand Down
10 changes: 1 addition & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
[workspace]
resolver = "2"
members = [
"crates/*",
"rerun_py",
"run_wasm",
"examples/api_demo",
"examples/minimal",
"examples/objectron",
"examples/raw_mesh",
]
members = ["crates/*", "examples/rust/*", "rerun_py", "run_wasm"]

[workspace.package]
authors = ["rerun.io <[email protected]>"]
Expand Down
36 changes: 1 addition & 35 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1 @@
# Rerun Examples
The simplest example is [`minimal`](minimal/main.py). You may want to start there!

## Setup
First install the Rerun Python SDK with `pip install rerun-sdk` (coming soon!)

<!-- TODO(emilk): remove the coming soon -->

## Dependencies
Each example comes with its own set of dependencies listed in a `requirements.txt` file. For example, to install dependencies and run the toy `car` example (which doesn't need to download any data) run:

```sh
pip install -r examples/car/requirements.txt
examples/car/main.py
```

You can also install all dependencies needed to run all examples with:

```sh
pip install -r examples/requirements.txt
```

## Running the examples
By default, the examples spawn a Rerun Viewer and stream log data to it.

You can instead save the log data to an `.rrd` file using `examples/car/main.py --save data.rrd`. You can then open that `.rrd` file with `rerun data.rrd`.

(`rerun` is an alias for `python -m rerun`).

NOTE: `.rrd` files do not yet guarantee any backwards or forwards compatibility. One version of Rerun will likely not be able to open an `.rrd` file generated by another Rerun version.

## Contributions welcome
Feel free to open a PR to add a new example!

See [`CONTRIBUTING.md`](../CONTRIBUTING.md) for details on how to contribute.
# Official Rerun examples
1 change: 0 additions & 1 deletion examples/deep_sdf/dataset/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/objectron/dataset/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions examples/objectron/dataset/compile_protobuf.sh

This file was deleted.

Empty file.
Empty file.
38 changes: 38 additions & 0 deletions examples/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Rerun Examples
The simplest example is [`minimal`](minimal/main.py). You may want to start there!

## Setup
First install the Rerun Python SDK with `pip install rerun-sdk` (coming soon!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
First install the Rerun Python SDK with `pip install rerun-sdk` (coming soon!)
First install the Rerun Python SDK with `pip install rerun-sdk`.

Might as well pre-emptively get this right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: if rerun-sdk is already published, why can't I find it on https://pypi.org/project/rerun-sdk/ ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only been published on testpypi, so pip install -i https://test.pypi.org/simple/ rerun-sdk

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if pip install rerun-sdk doesn't work yet, then let's not write it yet.


<!-- TODO(emilk): remove the coming soon -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<!-- TODO(emilk): remove the coming soon -->


## Dependencies
Each example comes with its own set of dependencies listed in a `requirements.txt` file. For example, to install dependencies and run the toy `car` example (which doesn't need to download any data) run:

```sh
pip install -r examples/python/car/requirements.txt
examples/python/car/main.py
```

You can also install all dependencies needed to run all examples with:

```sh
pip install -r examples/python/requirements.txt
```

## Running the examples
By default, the examples spawn a Rerun Viewer and stream log data to it.

You can instead save the log data to an `.rrd` file using `examples/python/car/main.py --save data.rrd`. You can then open that `.rrd` file with `rerun data.rrd`.

(`rerun` is an alias for `python -m rerun`).

NOTE: `.rrd` files do not yet guarantee any backwards or forwards compatibility. One version of Rerun will likely not be able to open an `.rrd` file generated by another Rerun version.

## Datasets
Some examples will download a small datasets before they run. They will do so the first time you run the example. The datasets will be added to a subdir called `dataset`, which is in the repo-wide `.gitignore`.

## Contributions welcome
Feel free to open a PR to add a new example!

See [`CONTRIBUTING.md`](../CONTRIBUTING.md) for details on how to contribute.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Minimal examples of Rerun SDK usage.

Example usage:
* Run all demos: `examples/api_demo/main.py`
* Run specific demo: `examples/api_demo/main.py --demo rects`
* Run all demos: `examples/python/api_demo/main.py`
* Run specific demo: `examples/python/api_demo/main.py --demo rects`
"""

import argparse
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

# TODO(cmc): re-enable obj meshes when we support those on the viewer's side
AVAILABLE_MESHES: Final = [
"lantern",
"avocado",
"buggy",
"brain_stem",
# "buddha",
"buggy",
# "bunny",
# "dragon",
"lantern",
# "mori_knob",
]
DOWNLOADED_DIR: Final = Path(os.path.dirname(__file__)) / "downloaded"
DOWNLOADED_DIR: Final = Path(os.path.dirname(__file__)) / "dataset"


def ensure_mesh_downloaded(mesh_name: str) -> Path:
Expand Down Expand Up @@ -67,7 +67,7 @@ def download_mcguire_sample(package: str, name: str) -> Path:
}
url = f"https://casual-effects.com/g3d/data10/{package}/model/{name}/{name}.zip"

dir = Path(os.path.dirname(__file__)) / "downloaded"
dir = Path(os.path.dirname(__file__)) / "dataset"
os.makedirs(dir, exist_ok=True)

def download_and_extract(url: str, path: Path) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Run:
```sh
# assuming your virtual env is up
examples/deep_sdf/main.py
examples/python/deep_sdf/main.py
```
"""

Expand All @@ -38,7 +38,7 @@
import numpy as np
import numpy.typing as npt
import trimesh
from dataset.dataset import AVAILABLE_MESHES, ensure_mesh_downloaded
from download_dataset import AVAILABLE_MESHES, ensure_mesh_downloaded
from rerun.log.file import MeshFormat
from rerun.log.text import LogLevel
from trimesh import Trimesh
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/dicom/main.py → examples/python/dicom/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Run:
``` sh
python3 examples/dicom/main.py
python3 examples/python/dicom/main.py
```
"""

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/mp_pose/main.py → examples/python/mp_pose/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def get_downloaded_path(dataset_dir: Path, video_name: str) -> str:


def main() -> None:
# Ensure the logging gets written to stderr:
logging.getLogger().addHandler(logging.StreamHandler())
logging.getLogger().setLevel("INFO")

parser = argparse.ArgumentParser(description="Uses the MediaPipe Pose solution to track a human pose in video.")
parser.add_argument(
"--video",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import requests

DATASET_BASE_URL = "https://storage.googleapis.com/objectron"
LOCAL_DATASET_DIR: Final = Path(os.path.dirname(__file__)) / "downloaded"
LOCAL_DATASET_DIR: Final = Path(os.path.dirname(__file__)) / "dataset"
IMAGE_RESOLUTION: Final = (1440, 1920)
GEOMETRY_FILENAME: Final = "geometry.pbdata"
ANNOTATIONS_FILENAME: Final = "annotation.pbdata"
Expand All @@ -29,7 +29,7 @@
def ensure_downloaded(src_url: str, dst_path: Path) -> None:
os.makedirs(dst_path.parent, exist_ok=True)
if not dst_path.exists():
logging.info("Downloading from %s to %s", src_url, dst_path)
logging.info("Downloading %s to %s", src_url, dst_path)
with requests.get(src_url, stream=True) as req:
req.raise_for_status()
with open(dst_path, "wb") as f:
Expand Down
12 changes: 8 additions & 4 deletions examples/objectron/main.py → examples/python/objectron/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"""
Example of using the Rerun SDK to log the Objectron dataset.

Example: `examples/objectron/main.py --recording chair`
Example: `examples/python/objectron/main.py --recording chair`
"""


import argparse
import logging
import math
import os
import sys
Expand All @@ -18,15 +18,15 @@

import numpy as np
import numpy.typing as npt
from dataset.dataset import (
from download_dataset import (
ANNOTATIONS_FILENAME,
AVAILABLE_RECORDINGS,
GEOMETRY_FILENAME,
IMAGE_RESOLUTION,
LOCAL_DATASET_DIR,
ensure_recording_available,
)
from dataset.proto.objectron.proto import (
from proto.objectron.proto import (
ARCamera,
ARFrame,
ARPointCloud,
Expand Down Expand Up @@ -256,6 +256,10 @@ def log_projected_bbox(path: str, keypoints: npt.NDArray[np.float32]) -> None:


def main() -> None:
# Ensure the logging in download_dataset.py gets written to stderr:
logging.getLogger().addHandler(logging.StreamHandler())
logging.getLogger().setLevel("INFO")

parser = argparse.ArgumentParser(description="Logs Objectron data using the Rerun SDK.")
parser.add_argument(
"--frames", type=int, default=sys.maxsize, help="If specified, limits the number of frames logged"
Expand Down
2 changes: 1 addition & 1 deletion examples/plots/main.py → examples/python/plots/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Run:
```sh
./examples/plot/main.py
./examples/python/plot/main.py
```
"""

Expand Down
File renamed without changes.
Loading