From 3e07cb5958486819ab047a7d6c45a340a06653b9 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:00:15 +0200 Subject: [PATCH 01/22] add `build_args` to example readmes --- examples/python/arkit_scenes/README.md | 1 + examples/python/detect_and_track_objects/README.md | 1 + examples/python/dicom_mri/README.md | 1 + examples/python/dna/README.md | 5 +++-- examples/python/human_pose_tracking/README.md | 1 + examples/python/plots/README.md | 5 +++-- examples/python/structure_from_motion/README.md | 1 + 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/python/arkit_scenes/README.md b/examples/python/arkit_scenes/README.md index c788a7246226..0385ab2272a9 100644 --- a/examples/python/arkit_scenes/README.md +++ b/examples/python/arkit_scenes/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/blob/latest/examples/python/arkit_scen tags: [2D, 3D, depth, mesh, object-detection, pinhole-camera] description: "Visualize the ARKitScenes dataset, which contains color+depth images, the reconstructed mesh and labeled bounding boxes." thumbnail: https://static.rerun.io/8b90a80c72b27fad289806b7e5dff0c9ac97e87c_arkit_scenes_480w.png +build_args: [] --- diff --git a/examples/python/detect_and_track_objects/README.md b/examples/python/detect_and_track_objects/README.md index 18a475286b5f..bcfe8fe5c879 100644 --- a/examples/python/detect_and_track_objects/README.md +++ b/examples/python/detect_and_track_objects/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/detect_and tags: [2D, huggingface, object-detection, object-tracking, opencv] description: "Visualize object detection and segmentation using the Huggingface `transformers` library." thumbnail: https://static.rerun.io/efb301d64eef6f25e8f6ae29294bd003c0cda3a7_detect_and_track_objects_480w.png +build_args: [] --- diff --git a/examples/python/dicom_mri/README.md b/examples/python/dicom_mri/README.md index 8d1e1c3a5c00..4b231d2102ec 100644 --- a/examples/python/dicom_mri/README.md +++ b/examples/python/dicom_mri/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/dicom_mri/ tags: [tensor, mri, dicom] description: "Example using a DICOM MRI scan. This demonstrates the flexible tensor slicing capabilities of the Rerun viewer." thumbnail: https://static.rerun.io/b8b25dd01e892e6daf5177e6fc05ff5feb19ee8d_dicom_mri_480w.png +build_args: [] --- diff --git a/examples/python/dna/README.md b/examples/python/dna/README.md index b52b4255607c..0e71ec87b2df 100644 --- a/examples/python/dna/README.md +++ b/examples/python/dna/README.md @@ -1,9 +1,10 @@ --- title: Helix python: https://github.com/rerun-io/rerun/tree/latest/examples/python/dna/main.py -thumbnail: https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png -description: "Simple example of logging point and line primitives to draw a 3D helix." tags: [3d, api-example] +description: "Simple example of logging point and line primitives to draw a 3D helix." +thumbnail: https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png +build_args: [] --- diff --git a/examples/python/human_pose_tracking/README.md b/examples/python/human_pose_tracking/README.md index e536cfae3bce..3daa58b82013 100644 --- a/examples/python/human_pose_tracking/README.md +++ b/examples/python/human_pose_tracking/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/human_pose tags: [mediapipe, keypoint-detection, 2D, 3D] description: "Use the MediaPipe Pose solution to detect and track a human pose in video." thumbnail: https://static.rerun.io/277b9c72da1d0d0ae9d221f7552dede9c4d5b2fa_human_pose_tracking_480w.png +build_args: [] --- diff --git a/examples/python/plots/README.md b/examples/python/plots/README.md index 238634b7ec76..54ca6fe48186 100644 --- a/examples/python/plots/README.md +++ b/examples/python/plots/README.md @@ -1,9 +1,10 @@ --- title: Plots python: https://github.com/rerun-io/rerun/tree/latest/examples/python/plots/main.py -thumbnail: https://static.rerun.io/ca0c72df93d70c79b0e640fb4b7c33cdc0bfe5f4_plots_480w.png -description: "Demonstration of various plots and charts supported by Rerun." tags: [2d, plots, api-example] +description: "Demonstration of various plots and charts supported by Rerun." +thumbnail: https://static.rerun.io/ca0c72df93d70c79b0e640fb4b7c33cdc0bfe5f4_plots_480w.png +build_args: [] --- diff --git a/examples/python/structure_from_motion/README.md b/examples/python/structure_from_motion/README.md index cec8feed615a..12d8e8c56716 100644 --- a/examples/python/structure_from_motion/README.md +++ b/examples/python/structure_from_motion/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/structure_ tags: [2D, 3D, colmap, pinhole-camera, time-series] description: "Visualize a sparse reconstruction by COLMAP, a general-purpose Structure-from-Motion and Multi-View Stereo pipeline." thumbnail: https://static.rerun.io/033edff752f86bcdc9a81f7877e0b4411ff4e6c5_structure_from_motion_480w.png +build_args: ["--dataset=colmap_fiat", "--resize=800x600"] --- From 7480d5169d65b1b1597b0648fd481f8aee8ab798 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:00:30 +0200 Subject: [PATCH 02/22] add `thumbnails` script for generating thumbnail_dimensions --- scripts/ci/thumbnails.py | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 scripts/ci/thumbnails.py diff --git a/scripts/ci/thumbnails.py b/scripts/ci/thumbnails.py new file mode 100755 index 000000000000..208d083d822c --- /dev/null +++ b/scripts/ci/thumbnails.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 + +"""Check or update example thumbnails.""" +from __future__ import annotations + +import argparse +from io import BytesIO +from pathlib import Path +from typing import Generator + +import frontmatter +import requests +from PIL import Image + + +class Example: + def __init__(self, path: Path, readme: str, fm: frontmatter.Post) -> None: + self.path = path + self.readme = readme + self.fm = fm + + +def get_thumbnail_dimensions(thumbnail: str) -> tuple[int, int]: + response = requests.get(thumbnail) + response.raise_for_status() + size: tuple[int, int] = Image.open(BytesIO(response.content)).size + return size + + +def examples_with_thumbnails() -> Generator[Example, None, None]: + for path in Path("examples/python").iterdir(): + if (path / "README.md").exists(): + readme = (path / "README.md").read_text() + fm = frontmatter.loads(readme) + if fm.get("thumbnail"): + yield Example(path, readme, fm) + + +def update() -> None: + for example in examples_with_thumbnails(): + width, height = get_thumbnail_dimensions(example.fm["thumbnail"]) + + thumbnail_key_start = example.readme.find("thumbnail: ") + assert thumbnail_key_start != -1 + thumbnail_key_end = example.readme.find("\n", thumbnail_key_start) + assert thumbnail_key_end != -1 + + (example.path / "README.md").write_text( + example.readme[: thumbnail_key_end + 1] + + f"thumbnail_dimensions: [{width}, {height}]" + + example.readme[thumbnail_key_end:] + ) + + print(f"✔ {example.path}") + + +def check() -> None: + bad = False + for example in examples_with_thumbnails(): + if not example.fm.get("thumbnail_dimensions"): + print(f"{example.path} has no `thumbnail_dimensions`") + bad = True + continue + + current = tuple(example.fm["thumbnail_dimensions"]) + actual = get_thumbnail_dimensions(example.fm["thumbnail"]) + if current != actual: + print(f"{example.path} `thumbnail_dimensions` are incorrect (current: {current}, actual: {actual})") + bad = True + + print(f"✔ {example.path}") + + if bad: + print("Please run `scripts/ci/thumbnails.py update`.") + exit(1) + + +def main() -> None: + parser = argparse.ArgumentParser(description="Check example thumbnails") + cmd_parser = parser.add_subparsers(title="cmd", dest="cmd", required=True) + cmd_parser.add_parser("check", help="Check that example thumbnails have correct thumbnail_dimensions") + cmd_parser.add_parser("update", help="Update thumbnail_dimensions for each example") + args = parser.parse_args() + + if args.cmd == "check": + check() + elif args.cmd == "update": + update() + + +if __name__ == "__main__": + main() From e344c1aed0dc935a650375a129b27665379732b2 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:21:20 +0200 Subject: [PATCH 03/22] add `thumbnail_dimensions` to readmes --- examples/python/arkit_scenes/README.md | 1 + examples/python/car/README.md | 1 + examples/python/clock/README.md | 1 + examples/python/depth_guided_stable_diffusion/README.md | 1 + examples/python/detect_and_track_objects/README.md | 1 + examples/python/dicom_mri/README.md | 1 + examples/python/differentiable_blocks_world/README.md | 1 + examples/python/dna/README.md | 1 + examples/python/face_tracking/README.md | 1 + examples/python/human_pose_tracking/README.md | 1 + examples/python/limap/README.md | 1 + examples/python/live_camera_edge_detection/README.md | 1 + examples/python/live_depth_sensor/README.md | 1 + examples/python/mcc/README.md | 1 + examples/python/minimal/README.md | 1 + examples/python/multiprocessing/README.md | 1 + examples/python/multithreading/README.md | 1 + examples/python/objectron/README.md | 1 + examples/python/open_photogrammetry_format/README.md | 1 + examples/python/plots/README.md | 1 + examples/python/raw_mesh/README.md | 1 + examples/python/rgbd/README.md | 1 + examples/python/ros_node/README.md | 1 + examples/python/segment_anything_model/README.md | 1 + examples/python/shape_pointe/README.md | 1 + examples/python/signed_distance_fields/README.md | 1 + examples/python/simplerecon/README.md | 1 + examples/python/slahmr/README.md | 1 + examples/python/structure_from_motion/README.md | 1 + examples/python/tapir/README.md | 1 + examples/python/text_logging/README.md | 1 + examples/python/widebaseline/README.md | 1 + 32 files changed, 32 insertions(+) diff --git a/examples/python/arkit_scenes/README.md b/examples/python/arkit_scenes/README.md index 0385ab2272a9..015204a5d358 100644 --- a/examples/python/arkit_scenes/README.md +++ b/examples/python/arkit_scenes/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/blob/latest/examples/python/arkit_scen tags: [2D, 3D, depth, mesh, object-detection, pinhole-camera] description: "Visualize the ARKitScenes dataset, which contains color+depth images, the reconstructed mesh and labeled bounding boxes." thumbnail: https://static.rerun.io/8b90a80c72b27fad289806b7e5dff0c9ac97e87c_arkit_scenes_480w.png +thumbnail_dimensions: [480, 243] build_args: [] --- diff --git a/examples/python/car/README.md b/examples/python/car/README.md index e15a3d3b8da8..c738a57a28cc 100644 --- a/examples/python/car/README.md +++ b/examples/python/car/README.md @@ -2,6 +2,7 @@ title: Car python: https://github.com/rerun-io/rerun/tree/latest/examples/python/car/main.py thumbnail: https://static.rerun.io/8a3845b71f90bc36af78978f83e60ddd65e40667_car_480w.png +thumbnail_dimensions: [480, 235] --- diff --git a/examples/python/clock/README.md b/examples/python/clock/README.md index 013a8d9a9593..bcd49668b3b6 100644 --- a/examples/python/clock/README.md +++ b/examples/python/clock/README.md @@ -3,6 +3,7 @@ title: Clock python: https://github.com/rerun-io/rerun/tree/latest/examples/python/clock/main.py rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/clock/src/main.rs thumbnail: https://static.rerun.io/52f791f1bcc092fb4e3cd4d825b6ad361c016220_clock_480w.png +thumbnail_dimensions: [480, 350] --- diff --git a/examples/python/depth_guided_stable_diffusion/README.md b/examples/python/depth_guided_stable_diffusion/README.md index 0665d3d50587..00bce2ec6e76 100644 --- a/examples/python/depth_guided_stable_diffusion/README.md +++ b/examples/python/depth_guided_stable_diffusion/README.md @@ -3,6 +3,7 @@ title: Depth Guided Stable Diffusion python: https://github.com/rerun-io/rerun/tree/latest/examples/python/depth_guided_stable_diffusion/main.py tags: [2D, depth, huggingface, stable-diffusion, tensor, text] thumbnail: https://static.rerun.io/15e7ff64aef69deba8bd036e0018e2bf3c7ef587_depth_guided_stable_diffusion_480w.png +thumbnail_dimensions: [480, 253] --- diff --git a/examples/python/detect_and_track_objects/README.md b/examples/python/detect_and_track_objects/README.md index bcfe8fe5c879..5cf7a70c3daa 100644 --- a/examples/python/detect_and_track_objects/README.md +++ b/examples/python/detect_and_track_objects/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/detect_and tags: [2D, huggingface, object-detection, object-tracking, opencv] description: "Visualize object detection and segmentation using the Huggingface `transformers` library." thumbnail: https://static.rerun.io/efb301d64eef6f25e8f6ae29294bd003c0cda3a7_detect_and_track_objects_480w.png +thumbnail_dimensions: [480, 279] build_args: [] --- diff --git a/examples/python/dicom_mri/README.md b/examples/python/dicom_mri/README.md index 4b231d2102ec..7d3b0401b6d5 100644 --- a/examples/python/dicom_mri/README.md +++ b/examples/python/dicom_mri/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/dicom_mri/ tags: [tensor, mri, dicom] description: "Example using a DICOM MRI scan. This demonstrates the flexible tensor slicing capabilities of the Rerun viewer." thumbnail: https://static.rerun.io/b8b25dd01e892e6daf5177e6fc05ff5feb19ee8d_dicom_mri_480w.png +thumbnail_dimensions: [480, 285] build_args: [] --- diff --git a/examples/python/differentiable_blocks_world/README.md b/examples/python/differentiable_blocks_world/README.md index 298407cd3f0c..8f4ae41e16de 100644 --- a/examples/python/differentiable_blocks_world/README.md +++ b/examples/python/differentiable_blocks_world/README.md @@ -3,6 +3,7 @@ title: "Differentiable Blocks World: Qualitative 3D Decomposition by Rendering P python: https://github.com/rerun-io/differentiable-blocksworld tags: [3D, mesh, pinhole-camera] thumbnail: https://static.rerun.io/fd44aa668cdebc6a4c14ff038e28f48cfb83c5ee_dbw_480w.png +thumbnail_dimensions: [480, 311] --- Finding a textured mesh decomposition from a collection of posed images is a very challenging optimization problem. “Differentiable Block Worlds” by @t_monnier et al. shows impressive results using differentiable rendering. I visualized how this optimization works using the Rerun SDK. diff --git a/examples/python/dna/README.md b/examples/python/dna/README.md index 0e71ec87b2df..0550a973f355 100644 --- a/examples/python/dna/README.md +++ b/examples/python/dna/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/dna/main.p tags: [3d, api-example] description: "Simple example of logging point and line primitives to draw a 3D helix." thumbnail: https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png +thumbnail_dimensions: [480, 285] build_args: [] --- diff --git a/examples/python/face_tracking/README.md b/examples/python/face_tracking/README.md index 47b50d2c740f..324b8c527ada 100644 --- a/examples/python/face_tracking/README.md +++ b/examples/python/face_tracking/README.md @@ -3,6 +3,7 @@ title: Face Tracking python: https://github.com/rerun-io/rerun/tree/latest/examples/python/face_tracking/main.py tags: [2d, 3d, camera, face-tracking, live, mediapipe, time-series] thumbnail: https://static.rerun.io/9f4ecc9d8447375cbad0af17fe2faf8ad2761025_mp_face_480w.png +thumbnail_dimensions: [480, 335] --- diff --git a/examples/python/human_pose_tracking/README.md b/examples/python/human_pose_tracking/README.md index 3daa58b82013..7b1c60357722 100644 --- a/examples/python/human_pose_tracking/README.md +++ b/examples/python/human_pose_tracking/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/human_pose tags: [mediapipe, keypoint-detection, 2D, 3D] description: "Use the MediaPipe Pose solution to detect and track a human pose in video." thumbnail: https://static.rerun.io/277b9c72da1d0d0ae9d221f7552dede9c4d5b2fa_human_pose_tracking_480w.png +thumbnail_dimensions: [480, 272] build_args: [] --- diff --git a/examples/python/limap/README.md b/examples/python/limap/README.md index 4d6729793d9c..56cccae1747f 100644 --- a/examples/python/limap/README.md +++ b/examples/python/limap/README.md @@ -3,6 +3,7 @@ title: "3D Line Mapping Revisited" python: hhttps://github.com/rerun-io/limap tags: [2D, 3D, structure-from-motion, time-series, line-detection, pinhole-camera] thumbnail: https://static.rerun.io/1c99ab95ad2a9e673effa0e104f5240912c80850_limap_480w.png +thumbnail_dimensions: [480, 277] --- Human-made environments contain a lot of straight lines, which are currently not exploited by most mapping approaches. With their recent work "3D Line Mapping Revisited" Shaohui Liu et al. take steps towards changing that. diff --git a/examples/python/live_camera_edge_detection/README.md b/examples/python/live_camera_edge_detection/README.md index cf165984e120..1d423feb2b47 100644 --- a/examples/python/live_camera_edge_detection/README.md +++ b/examples/python/live_camera_edge_detection/README.md @@ -3,6 +3,7 @@ title: Live Camera Edge Detection python: https://github.com/rerun-io/rerun/blob/latest/examples/python/live_camera_edge_detection/main.py tags: [2D, canny, live, opencv] thumbnail: https://static.rerun.io/06752fd08215ecd575219474dd886688c44acea8_live_camera_edge_detection_480w.png +thumbnail_dimensions: [480, 364] --- diff --git a/examples/python/live_depth_sensor/README.md b/examples/python/live_depth_sensor/README.md index 63a44e30bd99..100e6f28e2a7 100644 --- a/examples/python/live_depth_sensor/README.md +++ b/examples/python/live_depth_sensor/README.md @@ -3,6 +3,7 @@ title: Live Depth Sensor python: https://github.com/rerun-io/rerun/blob/latest/examples/python/live_depth_sensor/main.py tags: [2D, 3D, live, depth, realsense] thumbnail: https://static.rerun.io/8b7fe937b90b05972e01b0e79b4b87dde4a47914_live_depth_sensor_480w.png +thumbnail_dimensions: [480, 360] --- diff --git a/examples/python/mcc/README.md b/examples/python/mcc/README.md index 5e733a7b89ac..f9a79cd03da9 100644 --- a/examples/python/mcc/README.md +++ b/examples/python/mcc/README.md @@ -3,6 +3,7 @@ title: "Single Image 3D Reconstruction using MCC, SAM, and ZoeDepth" python: https://github.com/rerun-io/MCC tags: [2D, 3D, segmentation, point-cloud, sam] thumbnail: https://static.rerun.io/e62757c5953407373f2279be37a80748334cb6d7_mcc_480w.png +thumbnail_dimensions: [480, 274] --- By combining MetaAI's [Segment Anything Model (SAM)](https://github.com/facebookresearch/segment-anything) and [Multiview Compressive Coding (MCC)](https://github.com/facebookresearch/MCC) we can get a 3D object from a single image. diff --git a/examples/python/minimal/README.md b/examples/python/minimal/README.md index a5fe6682b7c9..92ae961b25a0 100644 --- a/examples/python/minimal/README.md +++ b/examples/python/minimal/README.md @@ -3,6 +3,7 @@ title: Minimal example python: https://github.com/rerun-io/rerun/tree/latest/examples/python/minimal/main.py rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/minimal/src/main.rs thumbnail: https://static.rerun.io/92a1f80b5cf2cd2c04a10d8ced35849da8f1c0ed_minimal_480w.png +thumbnail_dimensions: [480, 322] --- diff --git a/examples/python/multiprocessing/README.md b/examples/python/multiprocessing/README.md index dd93a2a5dad0..5cb0fce21f1d 100644 --- a/examples/python/multiprocessing/README.md +++ b/examples/python/multiprocessing/README.md @@ -2,6 +2,7 @@ title: Multiprocessing python: https://github.com/rerun-io/rerun/tree/latest/examples/python/multiprocessing/main.py thumbnail: https://static.rerun.io/feec58fbf50abb31487b49d8636a3667598db4c2_multiprocessing_480w.png +thumbnail_dimensions: [480, 308] --- diff --git a/examples/python/multithreading/README.md b/examples/python/multithreading/README.md index ee691b36e0c4..8d00242718f8 100644 --- a/examples/python/multithreading/README.md +++ b/examples/python/multithreading/README.md @@ -2,6 +2,7 @@ title: Multithreading python: https://github.com/rerun-io/rerun/tree/latest/examples/python/multithreading/main.py thumbnail: https://static.rerun.io/2c7e83a9044f62079c9aa56039b96c0b5adec17a_multithreading_480w.png +thumbnail_dimensions: [480, 312] --- diff --git a/examples/python/objectron/README.md b/examples/python/objectron/README.md index 21208d4fe205..ca275e45927d 100644 --- a/examples/python/objectron/README.md +++ b/examples/python/objectron/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/objectron/ rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/objectron/src/main.rs tags: [2D, 3D, object-detection, pinhole-camera] thumbnail: https://static.rerun.io/d218170b8f4bfbc38ea5918747e595cff841029e_objectron_480w.png +thumbnail_dimensions: [480, 268] --- diff --git a/examples/python/open_photogrammetry_format/README.md b/examples/python/open_photogrammetry_format/README.md index b0ae91eb57aa..c63ee983d2c9 100644 --- a/examples/python/open_photogrammetry_format/README.md +++ b/examples/python/open_photogrammetry_format/README.md @@ -3,6 +3,7 @@ title: Open Photogrammetry Format python: https://github.com/rerun-io/rerun/tree/latest/examples/python/open_photogrammetry_format/main.py tags: [2d, 3d, camera, photogrammetry] thumbnail: https://static.rerun.io/20716c6a10ffaa3960a212673adcbfff36da682e_open_photogrammetry_format_480w.png +thumbnail_dimensions: [480, 310] --- diff --git a/examples/python/plots/README.md b/examples/python/plots/README.md index 54ca6fe48186..698804ae0477 100644 --- a/examples/python/plots/README.md +++ b/examples/python/plots/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/plots/main tags: [2d, plots, api-example] description: "Demonstration of various plots and charts supported by Rerun." thumbnail: https://static.rerun.io/ca0c72df93d70c79b0e640fb4b7c33cdc0bfe5f4_plots_480w.png +thumbnail_dimensions: [480, 271] build_args: [] --- diff --git a/examples/python/raw_mesh/README.md b/examples/python/raw_mesh/README.md index fc75fad87389..1660a6541bc8 100644 --- a/examples/python/raw_mesh/README.md +++ b/examples/python/raw_mesh/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/raw_mesh/m rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/raw_mesh/src/main.rs tags: [mesh] thumbnail: https://static.rerun.io/d0ffad0d9c317a368181a6f8a1ba81b3aca64e97_raw_mesh_480w.png +thumbnail_dimensions: [480, 271] --- diff --git a/examples/python/rgbd/README.md b/examples/python/rgbd/README.md index 8c21b68a9de2..c308ae30ac86 100644 --- a/examples/python/rgbd/README.md +++ b/examples/python/rgbd/README.md @@ -3,6 +3,7 @@ title: RGBD python: https://github.com/rerun-io/rerun/tree/latest/examples/python/rgbd/main.py tags: [2D, 3D, depth, nyud, pinhole-camera] thumbnail: https://static.rerun.io/f9092d1915455dae9c5c5cabc083748444eae90b_rgbd_480w.png +thumbnail_dimensions: [480, 254] --- diff --git a/examples/python/ros_node/README.md b/examples/python/ros_node/README.md index 373672cd4f08..69f772203029 100644 --- a/examples/python/ros_node/README.md +++ b/examples/python/ros_node/README.md @@ -3,6 +3,7 @@ title: ROS Node python: https://github.com/rerun-io/rerun/blob/latest/examples/python/ros_node/main.py tags: [2D, 3D, mesh, pinhole-camera, ros, time-series] thumbnail: https://static.rerun.io/6e9326c44de2653b022d2048b608894208f2c391_ros_node_480w.png +thumbnail_dimensions: [480, 266] --- diff --git a/examples/python/segment_anything_model/README.md b/examples/python/segment_anything_model/README.md index 827bda6d6ca0..4fd8bcdf42bf 100644 --- a/examples/python/segment_anything_model/README.md +++ b/examples/python/segment_anything_model/README.md @@ -3,6 +3,7 @@ title: Segment Anything Model python: https://github.com/rerun-io/rerun/tree/latest/examples/python/segment_anything_model/main.py tags: [2D, sam, segmentation] thumbnail: https://static.rerun.io/4aa50186208378d417d1738ee7e53e3f804961ad_segment_anything_model_480w.png +thumbnail_dimensions: [480, 283] --- diff --git a/examples/python/shape_pointe/README.md b/examples/python/shape_pointe/README.md index 0568939e1f10..3f514d688d4e 100644 --- a/examples/python/shape_pointe/README.md +++ b/examples/python/shape_pointe/README.md @@ -3,6 +3,7 @@ title: "Point-E and Shap-E" python: https://github.com/rerun-io/point-shap-e tags: [3D, diffusion, point, mesh] thumbnail: https://static.rerun.io/c17f91298ad12eee6347a911338fca0604178f58_overview_480w.png +thumbnail_dimensions: [480, 293] --- OpenAI has released two models for text-to-3d generation: Point-E and Shape-E. Both of these methods are fast and interesting but still low fidelity for now. diff --git a/examples/python/signed_distance_fields/README.md b/examples/python/signed_distance_fields/README.md index 7b51aa4906ff..3468b53d79b6 100644 --- a/examples/python/signed_distance_fields/README.md +++ b/examples/python/signed_distance_fields/README.md @@ -3,6 +3,7 @@ title: Signed Distance Fields python: https://github.com/rerun-io/rerun/tree/latest/examples/python/signed_distance_fields/main.py tags: [3D, mesh, tensor] thumbnail: https://static.rerun.io/5d754551816a01c11726f005e7a02a39571a11a5_signed_distance_fields_480w.png +thumbnail_dimensions: [480, 294] --- diff --git a/examples/python/simplerecon/README.md b/examples/python/simplerecon/README.md index 1fde4a141ee3..f2d16204aa15 100644 --- a/examples/python/simplerecon/README.md +++ b/examples/python/simplerecon/README.md @@ -3,6 +3,7 @@ title: "SimpleRecon: 3D Reconstruction Without 3D Convolutions" python: https://github.com/rerun-io/simplerecon tags: [3D, depth, time-series, pinhole-camera, mesh] thumbnail: https://static.rerun.io/394d6544341a45882dcad4f2f5fbaabd74b3d1a3_simplerecon_480w.png +thumbnail_dimensions: [480, 271] --- SimpleRecon is a back-to-basics approach for 3D scene reconstruction from posed monocular images by Niantic Labs. It offers state-of-the-art depth accuracy and competitive 3D scene reconstruction which makes it perfect for resource-constrained environments. diff --git a/examples/python/slahmr/README.md b/examples/python/slahmr/README.md index b5d15d2b6b68..67102ee57c71 100644 --- a/examples/python/slahmr/README.md +++ b/examples/python/slahmr/README.md @@ -3,6 +3,7 @@ title: Decoupling Human and Camera Motion from Videos in the Wild python: https://github.com/rerun-io/slahmr tags: [3D, SLAM, keypoint-detection, mesh, time-series] thumbnail: https://static.rerun.io/43709757e7179f0272d3749560f529747f3e9149_slahmr_480w.png +thumbnail_dimensions: [480, 293] --- SLAHMR robustly tracks the motion of multiple moving people filmed with a moving camera and works well on “in-the-wild” videos. It’s a great showcase of how to build working computer vision systems by intelligently combining several single purpose models. diff --git a/examples/python/structure_from_motion/README.md b/examples/python/structure_from_motion/README.md index 12d8e8c56716..fc1d409a76cb 100644 --- a/examples/python/structure_from_motion/README.md +++ b/examples/python/structure_from_motion/README.md @@ -4,6 +4,7 @@ python: https://github.com/rerun-io/rerun/tree/latest/examples/python/structure_ tags: [2D, 3D, colmap, pinhole-camera, time-series] description: "Visualize a sparse reconstruction by COLMAP, a general-purpose Structure-from-Motion and Multi-View Stereo pipeline." thumbnail: https://static.rerun.io/033edff752f86bcdc9a81f7877e0b4411ff4e6c5_structure_from_motion_480w.png +thumbnail_dimensions: [480, 275] build_args: ["--dataset=colmap_fiat", "--resize=800x600"] --- diff --git a/examples/python/tapir/README.md b/examples/python/tapir/README.md index 00d342d62327..895f3fbde8ff 100644 --- a/examples/python/tapir/README.md +++ b/examples/python/tapir/README.md @@ -3,6 +3,7 @@ title: "TAPIR: Tracking Any Point with per-frame Initialization and temporal Ref python: https://github.com/rerun-io/tapnet tags: [2D, point-tracking, time-series, tensor, jax] thumbnail: https://static.rerun.io/991f089320edd15d5b2756f664ec6afcff802bc5_tapir_480w.png +thumbnail_dimensions: [480, 288] --- diff --git a/examples/python/text_logging/README.md b/examples/python/text_logging/README.md index 3621cfb71356..9730a6979a6b 100644 --- a/examples/python/text_logging/README.md +++ b/examples/python/text_logging/README.md @@ -2,6 +2,7 @@ title: Text Logging python: https://github.com/rerun-io/rerun/tree/latest/examples/python/text_logging/main.py thumbnail: https://static.rerun.io/33696e46db189cc690d5f31f1db3a641032232e6_text_logging_480w.png +thumbnail_dimensions: [480, 323] --- diff --git a/examples/python/widebaseline/README.md b/examples/python/widebaseline/README.md index 9a93f2d275e2..0d0649222600 100644 --- a/examples/python/widebaseline/README.md +++ b/examples/python/widebaseline/README.md @@ -3,6 +3,7 @@ title: "Learning to Render Novel Views from Wide-Baseline Stereo Pairs" python: https://github.com/rerun-io/cross_attention_renderer/ tags: [2D, 3D, view-synthesis, time-series, pinhole-camera] thumbnail: https://static.rerun.io/2bca79bebaf58c7f8780756e07b93798abe5f6d8_widebaseline_480w.png +thumbnail_dimensions: [480, 316] --- Novel view synthesis has made remarkable progress in recent years, but most methods require per-scene optimization on many images. In their [CVPR 2023 paper](https://openaccess.thecvf.com/content/CVPR2023/html/Du_Learning_To_Render_Novel_Views_From_Wide-Baseline_Stereo_Pairs_CVPR_2023_paper.html) Yilun Du et al. propose a method that works with just 2 views. I created a visual walkthrough of the work using the Rerun SDK. From b72ed83cf7e2dd31c4e71c090a265664fa760bf2 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:36:07 +0200 Subject: [PATCH 04/22] add examples build script --- .cargo/config.toml | 3 + Cargo.lock | 54 ++++++- crates/re_viewer/Cargo.toml | 3 + crates/re_viewer/build.rs | 155 +++++++++++++++++++ crates/re_viewer/data/examples_manifest.json | 80 +++++----- 5 files changed, 249 insertions(+), 46 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 0e1423762e60..29cde01ed140 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -20,6 +20,9 @@ run-wasm = "run --release --package run_wasm --" # so that we don't run them on cargo publish or on users machines. IS_IN_RERUN_WORKSPACE = "yes" +# The build script in `re_viewer` uses this to build the `example_manifest.json`. +EXAMPLES_MANIFEST_BASE_URL = "https://demo.rerun.io/version/nightly" + # web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses, # https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html # as well as WebGPU apis. diff --git a/Cargo.lock b/Cargo.lock index ffb46a0b0c69..2bbb928acffc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1640,6 +1640,12 @@ dependencies = [ "serde", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "err-derive" version = "0.3.1" @@ -1765,7 +1771,7 @@ checksum = "79386fdcec5e0fde91b1a6a5bcd89677d1f9304f7f986b154a1b9109038854d9" dependencies = [ "az", "bytemuck", - "half 1.8.2", + "half 2.3.1", "serde", "typenum", ] @@ -2153,7 +2159,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -2203,6 +2209,12 @@ dependencies = [ "rayon", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "hassle-rs" version = "0.10.0" @@ -2387,6 +2399,16 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + [[package]] name = "indoc" version = "1.0.9" @@ -2972,7 +2994,7 @@ dependencies = [ "bitflags 2.3.1", "codespan-reporting", "hexf-parse", - "indexmap", + "indexmap 1.9.3", "log", "num-traits", "rustc-hash", @@ -3439,7 +3461,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.3", ] [[package]] @@ -3543,7 +3565,7 @@ dependencies = [ "comfy-table", "either", "hashbrown 0.13.2", - "indexmap", + "indexmap 1.9.3", "num-traits", "once_cell", "polars-arrow", @@ -4762,6 +4784,7 @@ dependencies = [ "ron", "serde", "serde_json", + "serde_yaml", "thiserror", "time", "wasm-bindgen-futures", @@ -5433,6 +5456,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" +dependencies = [ + "indexmap 2.0.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha-1" version = "0.10.1" @@ -6003,7 +6039,7 @@ version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ - "indexmap", + "indexmap 1.9.3", "toml_datetime", "winnow", ] @@ -6170,6 +6206,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" +[[package]] +name = "unsafe-libyaml" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" + [[package]] name = "untrusted" version = "0.7.1" diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 7c987b6dd78c..927cfe735ea2 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -113,3 +113,6 @@ web-sys = { version = "0.3.52", features = ["Window"] } [build-dependencies] re_build_tools.workspace = true +serde = { version = "1", features = ["derive"] } +serde_json = "1" +serde_yaml = "0.9" diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index 7fb960bd4880..9d2ad8be1674 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -1,4 +1,159 @@ +use std::path::Path; + +type AnyError = Box; +type Result = std::result::Result; + +#[derive(Debug)] +struct Error(String); +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.0) + } +} +impl std::error::Error for Error {} +macro_rules! error { + ($lit:literal) => (Error($lit.to_owned())); + ($($tt:tt)*) => (Error(format!($($tt)*))); +} +macro_rules! bail { + ($lit:literal) => (return Err(error!($lit))); + ($($tt:tt)*) => (return Err(error!($($tt)*).into())); +} + +#[derive(serde::Deserialize)] +struct Frontmatter { + title: Option, + tags: Option>, + description: Option, + thumbnail: Option, + thumbnail_dimensions: Option<[u64; 2]>, + build_args: Option>, +} + +#[derive(serde::Serialize)] +struct ManifestEntry { + name: String, + title: String, + description: String, + tags: Vec, + demo_url: String, + rrd_url: String, + thumbnail: Thumbnail, +} + +#[derive(serde::Serialize)] +struct Thumbnail { + url: String, + width: u64, + height: u64, +} + +impl TryFrom for ManifestEntry { + type Error = Error; + fn try_from(example: Example) -> Result { + macro_rules! get { + ($e:ident, $f:ident) => { + match $e.readme.$f { + Some(value) => value, + None => bail!("{:?} is missing field {:?}", $e.name, stringify!($f)), + } + }; + } + + let base_url = std::env::var("EXAMPLES_MANIFEST_BASE_URL") + .unwrap_or_else(|_e| "https://demo.rerun.io/version/nightly".into()); + + let thumbnail_dimensions = get!(example, thumbnail_dimensions); + + Ok(Self { + title: get!(example, title), + description: get!(example, description), + tags: get!(example, tags), + demo_url: format!("{base_url}/examples/arkit_scenes/"), + rrd_url: format!("{base_url}/examples/arkit_scenes/data.rrd"), + thumbnail: Thumbnail { + url: get!(example, thumbnail), + width: thumbnail_dimensions[0], + height: thumbnail_dimensions[1], + }, + name: example.name, + }) + } +} + +struct Example { + name: String, + readme: Frontmatter, +} + +fn examples() -> Result> { + let mut examples = vec![]; + for folder in std::fs::read_dir("../../examples/python")? { + let folder = folder?; + let metadata = folder.metadata()?; + let name = folder.file_name().to_string_lossy().to_string(); + let readme = folder.path().join("README.md"); + if metadata.is_dir() && readme.exists() { + let readme = parse_frontmatter(readme)?; + let Some(readme) = readme else { continue }; + if readme.build_args.is_none() { + continue; + } + examples.push(Example { name, readme }); + } + } + Ok(examples) +} + +fn parse_frontmatter>(path: P) -> Result> { + let path = path.as_ref(); + let content = std::fs::read_to_string(path)?; + let Some(content) = content.strip_prefix("---\n") else { + return Ok(None); + }; + let Some(end) = content.find("---") else { + bail!("{:?} has invalid frontmatter", path); + }; + Ok(Some(serde_yaml::from_str(&content[..end]).map_err( + |e| { + error!( + "failed to read {:?}: {e}", + path.parent().unwrap().file_name().unwrap() + ) + }, + )?)) +} + +const MANIFEST_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/data/examples_manifest.json"); + +fn write_examples_manifest() -> Result<()> { + let mut manifest = vec![]; + for example in examples()? { + manifest.push(ManifestEntry::try_from(example)?); + } + re_build_tools::write_file_if_necessary( + MANIFEST_PATH, + serde_json::to_string_pretty(&manifest)?.as_bytes(), + )?; + Ok(()) +} + +fn write_examples_manifest_if_necessary() { + if !re_build_tools::is_tracked_env_var_set("IS_IN_RERUN_WORKSPACE") + || re_build_tools::is_tracked_env_var_set("RERUN_IS_PUBLISHING") + { + return; + } + re_build_tools::rerun_if_changed_or_doesnt_exist(MANIFEST_PATH); + + if let Err(e) = write_examples_manifest() { + panic!("{e}"); + } +} + fn main() { re_build_tools::rebuild_if_crate_changed("re_viewer"); re_build_tools::export_env_vars(); + + write_examples_manifest_if_necessary(); } diff --git a/crates/re_viewer/data/examples_manifest.json b/crates/re_viewer/data/examples_manifest.json index cf97a410b3e0..de821ef56a35 100644 --- a/crates/re_viewer/data/examples_manifest.json +++ b/crates/re_viewer/data/examples_manifest.json @@ -11,8 +11,8 @@ "object-detection", "pinhole-camera" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { "url": "https://static.rerun.io/8b90a80c72b27fad289806b7e5dff0c9ac97e87c_arkit_scenes_480w.png", "width": 480, @@ -20,22 +20,19 @@ } }, { - "name": "structure_from_motion", - "title": "Structure from Motion", - "description": "Visualize a sparse reconstruction by COLMAP, a general-purpose Structure-from-Motion and Multi-View Stereo pipeline.", + "name": "dna", + "title": "Helix", + "description": "Simple example of logging point and line primitives to draw a 3D helix.", "tags": [ - "2D", - "3D", - "colmap", - "pinhole-camera", - "time-series" + "3d", + "api-example" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/structure_from_motion/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/structure_from_motion/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { - "url": "https://static.rerun.io/033edff752f86bcdc9a81f7877e0b4411ff4e6c5_structure_from_motion_480w.png", + "url": "https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png", "width": 480, - "height": 275 + "height": 285 } }, { @@ -47,8 +44,8 @@ "mri", "dicom" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/dicom_mri/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/dicom_mri/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { "url": "https://static.rerun.io/b8b25dd01e892e6daf5177e6fc05ff5feb19ee8d_dicom_mri_480w.png", "width": 480, @@ -56,21 +53,22 @@ } }, { - "name": "human_pose_tracking", - "title": "Human Pose Tracking", - "description": "Use the MediaPipe Pose solution to detect and track a human pose in video.", + "name": "structure_from_motion", + "title": "Structure from Motion", + "description": "Visualize a sparse reconstruction by COLMAP, a general-purpose Structure-from-Motion and Multi-View Stereo pipeline.", "tags": [ - "mediapipe", - "keypoint-detection", "2D", - "3D" + "3D", + "colmap", + "pinhole-camera", + "time-series" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/human_pose_tracking/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/human_pose_tracking/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { - "url": "https://static.rerun.io/277b9c72da1d0d0ae9d221f7552dede9c4d5b2fa_human_pose_tracking_480w.png", + "url": "https://static.rerun.io/033edff752f86bcdc9a81f7877e0b4411ff4e6c5_structure_from_motion_480w.png", "width": 480, - "height": 272 + "height": 275 } }, { @@ -82,8 +80,8 @@ "plots", "api-example" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/plots/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/plots/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { "url": "https://static.rerun.io/ca0c72df93d70c79b0e640fb4b7c33cdc0bfe5f4_plots_480w.png", "width": 480, @@ -101,8 +99,8 @@ "object-tracking", "opencv" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/detect_and_track_objects/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/detect_and_track_objects/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { "url": "https://static.rerun.io/efb301d64eef6f25e8f6ae29294bd003c0cda3a7_detect_and_track_objects_480w.png", "width": 480, @@ -110,19 +108,21 @@ } }, { - "name": "dna", - "title": "Helix", - "description": "Simple example of logging point and line primitives to draw a 3D helix.", + "name": "human_pose_tracking", + "title": "Human Pose Tracking", + "description": "Use the MediaPipe Pose solution to detect and track a human pose in video.", "tags": [ - "3d", - "api-example" + "mediapipe", + "keypoint-detection", + "2D", + "3D" ], - "demo_url": "https://demo.rerun.io/commit/6f0c1f2/examples/dna/", - "rrd_url": "https://demo.rerun.io/commit/6f0c1f2/examples/dna/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", "thumbnail": { - "url": "https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png", + "url": "https://static.rerun.io/277b9c72da1d0d0ae9d221f7552dede9c4d5b2fa_human_pose_tracking_480w.png", "width": 480, - "height": 285 + "height": 272 } } -] +] \ No newline at end of file From 19d8f0c1971043b728508390136efe317692e35f Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:39:43 +0200 Subject: [PATCH 05/22] check thumbnails --- .github/workflows/reusable_checks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/reusable_checks.yml b/.github/workflows/reusable_checks.yml index 47998d7a9e8c..337833554ca8 100644 --- a/.github/workflows/reusable_checks.yml +++ b/.github/workflows/reusable_checks.yml @@ -266,6 +266,7 @@ jobs: - name: Install dependencies run: | pip install gitignore_parser python-frontmatter + pip install -r ./scripts/ci/requirements.txt - name: Rerun lints run: | @@ -279,6 +280,10 @@ jobs: run: | ./scripts/ci/check_requirements.py + - name: Check Python example thumbnails + run: | + ./scripits/ci/thumbnails.py check + # --------------------------------------------------------------------------- spell-check: From 526c7b9d053e4015dd0773f5df716430fb4c76d7 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:03:34 +0200 Subject: [PATCH 06/22] update `re_viewer` build script to detect and handle CI --- .cargo/config.toml | 3 --- Cargo.lock | 1 + crates/re_viewer/Cargo.toml | 3 +++ crates/re_viewer/build.rs | 52 +++++++++++++++++++++++++++++++++++-- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 29cde01ed140..0e1423762e60 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -20,9 +20,6 @@ run-wasm = "run --release --package run_wasm --" # so that we don't run them on cargo publish or on users machines. IS_IN_RERUN_WORKSPACE = "yes" -# The build script in `re_viewer` uses this to build the `example_manifest.json`. -EXAMPLES_MANIFEST_BASE_URL = "https://demo.rerun.io/version/nightly" - # web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses, # https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html # as well as WebGPU apis. diff --git a/Cargo.lock b/Cargo.lock index 2bbb928acffc..b4fd1bedf91a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4792,6 +4792,7 @@ dependencies = [ "web-time", "wgpu", "winapi", + "xshell", ] [[package]] diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 927cfe735ea2..97d51e35625a 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -113,6 +113,9 @@ web-sys = { version = "0.3.52", features = ["Window"] } [build-dependencies] re_build_tools.workspace = true + +# External serde = { version = "1", features = ["derive"] } serde_json = "1" serde_yaml = "0.9" +xshell = "0.2" diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index 9d2ad8be1674..b0a8dd26cbfe 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -1,5 +1,8 @@ use std::path::Path; +use xshell::cmd; +use xshell::Shell; + type AnyError = Box; type Result = std::result::Result; @@ -20,6 +23,34 @@ macro_rules! bail { ($($tt:tt)*) => (return Err(error!($($tt)*).into())); } +fn git_branch_name(sh: &Shell) -> Result { + Ok(String::from_utf8( + cmd!(sh, "git rev-parse --abbrev-ref HEAD").output()?.stdout, + )?) +} + +fn git_short_hash(sh: &Shell) -> Result { + let full_hash = String::from_utf8(cmd!(sh, "git rev-parse HEAD").output()?.stdout)?; + Ok(full_hash.trim()[0..7].to_string()) +} + +fn parse_release_version(branch: &str) -> Option { + // release-\d+.\d+.\d+ + + let branch = branch.strip_prefix("release-")?; + + let mut version_parts = branch.split('.'); + let major = version_parts.next()?.parse::().ok()?; + let minor = version_parts.next()?.parse::().ok()?; + let patch = version_parts.next()?.parse::().ok()?; + + if version_parts.next().is_some() { + return None; + } + + Some(format!("{major}.{minor}.{patch}")) +} + #[derive(serde::Deserialize)] struct Frontmatter { title: Option, @@ -49,7 +80,7 @@ struct Thumbnail { } impl TryFrom for ManifestEntry { - type Error = Error; + type Error = AnyError; fn try_from(example: Example) -> Result { macro_rules! get { ($e:ident, $f:ident) => { @@ -60,9 +91,26 @@ impl TryFrom for ManifestEntry { }; } - let base_url = std::env::var("EXAMPLES_MANIFEST_BASE_URL") + let mut base_url = std::env::var("EXAMPLES_MANIFEST_BASE_URL") .unwrap_or_else(|_e| "https://demo.rerun.io/version/nightly".into()); + if std::env::var("CI").is_ok() { + // We're in CI: + let sh = Shell::new()?; + let branch = git_branch_name(&sh)?; + // If we are on `main`, leave the base url at `version/nightly` + if branch != "main" { + if let Some(version) = parse_release_version(&branch) { + // In builds on `release-x.y.z` branches, use `version/{x.y.z}`. + base_url = format!("https://demo.rerun.io/version/{version}"); + } else { + // On any other branch, use `commit/{short_sha}`. + let sha = git_short_hash(&sh)?; + base_url = format!("https://demo.rerun.io/commit/{sha}"); + } + } + } + let thumbnail_dimensions = get!(example, thumbnail_dimensions); Ok(Self { From b8c90c1711bc64cbe4b631bba7ffa82e30ea888c Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:13:03 +0200 Subject: [PATCH 07/22] release `version/nightly` when pushing on main --- .github/workflows/README.md | 2 -- .github/workflows/manual_adhoc_web.yml | 2 -- .github/workflows/manual_build_release.yml | 2 -- .github/workflows/manual_dispatch.yml | 2 -- .github/workflows/on_push_main.yml | 3 +-- .github/workflows/reusable_upload_web.yml | 24 ++++++++++++++----- .../workflows/reusable_upload_web_demo.yml | 14 +++++++---- 7 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 4db53f915f8b..49950eb33e8c 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -42,7 +42,6 @@ uploaded anywhere. - `RELEASE_VERSION` - If producing a release, the version number. This must match the version in `Cargo.toml`. - [reusable_upload_web.yml](reusable_upload_web.yml) - This job uploads the web assets to google cloud. By default this only uploads to: `app.rerun.io/commit//` - - `MARK_PRERELEASE_FOR_MAINLINE` - If true, then the web assets will go to `app.rerun.io/prelease/ - `MARK_TAGGED_VERSION` - If true, then the web assets will go to `app.rerun.io/version/` - `RELEASE_VERSION` - If producing a release, the version number. - `RRD_ARTIFACT_NAME` - Intermediate name of the GitHub rrd artifact. This should match the name passed to @@ -54,7 +53,6 @@ uploaded anywhere. source source code link in the built app always points to the pull request's `HEAD`. - [reusable_upload_web_demo.yml](reusable_upload_web_demo.yml) - This job uploads the `demo.rerun.io` assets to google cloud. By default this only uploads to: `demo.rerun.io/commit//` - - `MARK_PRERELEASE_FOR_MAINLINE` - If true, then the web assets will go to `demo.rerun.io/prelease/ - `MARK_TAGGED_VERSION` - If true, then the web assets will go to `demo.rerun.io/version/` - `RELEASE_VERSION` - If producing a release, the version number. - `UPLOAD_COMMIT_OVERRIDE` - If set, will replace the value of ``. This is necessary because we want pull diff --git a/.github/workflows/manual_adhoc_web.yml b/.github/workflows/manual_adhoc_web.yml index 7ea179917315..2ccd873bd978 100644 --- a/.github/workflows/manual_adhoc_web.yml +++ b/.github/workflows/manual_adhoc_web.yml @@ -40,7 +40,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web.yml with: CONCURRENCY: adhoc-web-${{ github.event.inputs.ADHOC_NAME }} - MARK_PRERELEASE_FOR_MAINLINE: false MARK_TAGGED_VERSION: false ADHOC_NAME: ${{ github.event.inputs.ADHOC_NAME }} RRD_ARTIFACT_NAME: linux-rrd-fast @@ -62,7 +61,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web_demo.yml with: CONCURRENCY: adhoc-web-${{ github.event.inputs.ADHOC_NAME }} - MARK_PRERELEASE_FOR_MAINLINE: false MARK_TAGGED_VERSION: false ADHOC_NAME: ${{ github.event.inputs.ADHOC_NAME }} UPLOAD_COMMIT: false diff --git a/.github/workflows/manual_build_release.yml b/.github/workflows/manual_build_release.yml index ecd30d19a3b4..bf3d669d0a0d 100644 --- a/.github/workflows/manual_build_release.yml +++ b/.github/workflows/manual_build_release.yml @@ -116,7 +116,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web.yml with: CONCURRENCY: manual-dispatch-${{ github.run_id}} - MARK_PRERELEASE_FOR_MAINLINE: false MARK_TAGGED_VERSION: true RRD_ARTIFACT_NAME: linux-rrd RELEASE_VERSION: ${{ github.event.inputs.RELEASE_VERSION }} @@ -137,7 +136,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web_demo.yml with: CONCURRENCY: manual-dispatch-${{ github.run_id}} - MARK_PRERELEASE_FOR_MAINLINE: false MARK_TAGGED_VERSION: true RELEASE_VERSION: ${{ github.event.inputs.RELEASE_VERSION }} secrets: inherit diff --git a/.github/workflows/manual_dispatch.yml b/.github/workflows/manual_dispatch.yml index 077caa0f43e8..ef2f046f1a8a 100644 --- a/.github/workflows/manual_dispatch.yml +++ b/.github/workflows/manual_dispatch.yml @@ -213,7 +213,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web.yml with: CONCURRENCY: manual-dispatch-${{ github.run_id}} - MARK_PRERELEASE_FOR_MAINLINE: false MARK_TAGGED_VERSION: false RRD_ARTIFACT_NAME: linux-rrd-fast secrets: inherit @@ -235,7 +234,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web_demo.yml with: CONCURRENCY: manual-dispatch-${{ github.run_id}} - MARK_PRERELEASE_FOR_MAINLINE: false MARK_TAGGED_VERSION: false secrets: inherit diff --git a/.github/workflows/on_push_main.yml b/.github/workflows/on_push_main.yml index ad758b8fad95..c5a2a1ffbd3f 100644 --- a/.github/workflows/on_push_main.yml +++ b/.github/workflows/on_push_main.yml @@ -47,7 +47,6 @@ jobs: with: CONCURRENCY: push-${{ github.ref_name }} RRD_ARTIFACT_NAME: linux-rrd - MARK_PRERELEASE_FOR_MAINLINE: true secrets: inherit build-web-demo: @@ -73,7 +72,6 @@ jobs: uses: ./.github/workflows/reusable_upload_web_demo.yml with: CONCURRENCY: push-${{ github.ref_name }} - MARK_PRERELEASE_FOR_MAINLINE: true secrets: inherit build-rerun_c-and-upload-linux: @@ -273,3 +271,4 @@ jobs: allowUpdates: true removeArtifacts: true replacesArtifacts: true + diff --git a/.github/workflows/reusable_upload_web.yml b/.github/workflows/reusable_upload_web.yml index d6b29e1d88ef..d7e2f5a70dec 100644 --- a/.github/workflows/reusable_upload_web.yml +++ b/.github/workflows/reusable_upload_web.yml @@ -10,10 +10,6 @@ on: type: string required: false default: "" - MARK_PRERELEASE_FOR_MAINLINE: - required: false - type: boolean - default: false MARK_TAGGED_VERSION: required: false type: boolean @@ -100,7 +96,7 @@ jobs: parent: false - name: "Upload web-viewer (prerelease)" - if: inputs.MARK_PRERELEASE_FOR_MAINLINE + if: github.ref == 'refs/heads/master' uses: google-github-actions/upload-cloud-storage@v1 with: path: "web_viewer" @@ -108,13 +104,29 @@ jobs: parent: false - name: "Upload RRD (prerelease)" - if: inputs.MARK_PRERELEASE_FOR_MAINLINE + if: github.ref == 'refs/heads/master' uses: google-github-actions/upload-cloud-storage@v1 with: path: "rrd" destination: "rerun-example-rrd/prerelease" parent: false + - name: "Upload web-viewer (nightly)" + if: github.ref == 'refs/heads/master' + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: "web_viewer" + destination: "rerun-web-viewer/version/nightly" + parent: false + + - name: "Upload RRD (nightly)" + if: github.ref == 'refs/heads/master' + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: "rrd" + destination: "rerun-example-rrd/version/nightly" + parent: false + - name: "Upload web-viewer (tagged)" if: inputs.MARK_TAGGED_VERSION uses: google-github-actions/upload-cloud-storage@v1 diff --git a/.github/workflows/reusable_upload_web_demo.yml b/.github/workflows/reusable_upload_web_demo.yml index 028902c4ed94..4eda1fcbfbc1 100644 --- a/.github/workflows/reusable_upload_web_demo.yml +++ b/.github/workflows/reusable_upload_web_demo.yml @@ -10,10 +10,6 @@ on: type: string required: false default: "" - MARK_PRERELEASE_FOR_MAINLINE: - required: false - type: boolean - default: false MARK_TAGGED_VERSION: required: false type: boolean @@ -85,13 +81,21 @@ jobs: parent: false - name: "Upload web demo (prerelease)" - if: inputs.MARK_PRERELEASE_FOR_MAINLINE + if: github.ref == 'refs/heads/master' uses: google-github-actions/upload-cloud-storage@v1 with: path: "web_demo" destination: "rerun-demo/prerelease" parent: false + - name: "Upload web demo (nightly)" + if: github.ref == 'refs/heads/master' + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: "web_demo" + destination: "rerun-demo/version/nightly" + parent: false + - name: "Upload web demo (tagged)" if: inputs.MARK_TAGGED_VERSION uses: google-github-actions/upload-cloud-storage@v1 From 92f03b461cf8084554ec62636b30535000a504aa Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:16:49 +0200 Subject: [PATCH 08/22] fix lints --- crates/re_viewer/build.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index b0a8dd26cbfe..512b72192b6d 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -8,16 +8,20 @@ type Result = std::result::Result; #[derive(Debug)] struct Error(String); + impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&self.0) } } + impl std::error::Error for Error {} + macro_rules! error { ($lit:literal) => (Error($lit.to_owned())); ($($tt:tt)*) => (Error(format!($($tt)*))); } + macro_rules! bail { ($lit:literal) => (return Err(error!($lit))); ($($tt:tt)*) => (return Err(error!($($tt)*).into())); @@ -81,6 +85,7 @@ struct Thumbnail { impl TryFrom for ManifestEntry { type Error = AnyError; + fn try_from(example: Example) -> Result { macro_rules! get { ($e:ident, $f:ident) => { @@ -194,8 +199,8 @@ fn write_examples_manifest_if_necessary() { } re_build_tools::rerun_if_changed_or_doesnt_exist(MANIFEST_PATH); - if let Err(e) = write_examples_manifest() { - panic!("{e}"); + if let Err(err) = write_examples_manifest() { + panic!("{err}"); } } From e3385d5624531dc2b3e30713d2479aa6eb79ac5c Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:21:19 +0200 Subject: [PATCH 09/22] put `xshell` in workspace deps --- Cargo.toml | 1 + crates/re_types_builder/Cargo.toml | 4 ++-- crates/re_viewer/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2b9e25d8803..cec4403202fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,6 +137,7 @@ web-time = "0.2.0" # See also https://gpuweb.github.io/gpuweb/explainer/#multithreading-transfer (unsolved part of the Spec as of writing!) wgpu = { version = "0.17.0", features = ["fragile-send-sync-non-atomic-wasm"] } wgpu-core = "0.17.0" +xshell = "0.2" [profile.dev] diff --git a/crates/re_types_builder/Cargo.toml b/crates/re_types_builder/Cargo.toml index 339a2a2847e1..6928554082f3 100644 --- a/crates/re_types_builder/Cargo.toml +++ b/crates/re_types_builder/Cargo.toml @@ -37,7 +37,7 @@ rayon.workspace = true rust-format = "0.3" syn = "2.0" unindent.workspace = true -xshell = "0.2" +xshell.workspace = true [build-dependencies] @@ -46,4 +46,4 @@ xshell = "0.2" re_build_tools.workspace = true # External -xshell = "0.2" +xshell.workspace = true diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 97d51e35625a..94582cc8138b 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -118,4 +118,4 @@ re_build_tools.workspace = true serde = { version = "1", features = ["derive"] } serde_json = "1" serde_yaml = "0.9" -xshell = "0.2" +xshell.workspace = true From de7a86edd800ce5007d3175baa9ee59c52f0ab33 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:22:03 +0200 Subject: [PATCH 10/22] fix script path --- .github/workflows/reusable_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_checks.yml b/.github/workflows/reusable_checks.yml index 337833554ca8..f8ec3cc1c3ff 100644 --- a/.github/workflows/reusable_checks.yml +++ b/.github/workflows/reusable_checks.yml @@ -282,7 +282,7 @@ jobs: - name: Check Python example thumbnails run: | - ./scripits/ci/thumbnails.py check + ./scripts/ci/thumbnails.py check # --------------------------------------------------------------------------- From 04e670544c81eae637c46563a3dbcc3db158eaba Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:26:36 +0200 Subject: [PATCH 11/22] pin serde_yaml to older version --- Cargo.lock | 38 +++++++----------------------- Cargo.toml | 1 - crates/re_types_builder/Cargo.toml | 4 ++-- crates/re_viewer/Cargo.toml | 4 ++-- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4fd1bedf91a..d08c3c5a74e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1640,12 +1640,6 @@ dependencies = [ "serde", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "err-derive" version = "0.3.1" @@ -2159,7 +2153,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -2209,12 +2203,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - [[package]] name = "hassle-rs" version = "0.10.0" @@ -2399,16 +2387,6 @@ dependencies = [ "hashbrown 0.12.3", ] -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", -] - [[package]] name = "indoc" version = "1.0.9" @@ -2994,7 +2972,7 @@ dependencies = [ "bitflags 2.3.1", "codespan-reporting", "hexf-parse", - "indexmap 1.9.3", + "indexmap", "log", "num-traits", "rustc-hash", @@ -3461,7 +3439,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap", ] [[package]] @@ -3565,7 +3543,7 @@ dependencies = [ "comfy-table", "either", "hashbrown 0.13.2", - "indexmap 1.9.3", + "indexmap", "num-traits", "once_cell", "polars-arrow", @@ -5459,11 +5437,11 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.25" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" +checksum = "d9d684e3ec7de3bf5466b32bd75303ac16f0736426e5a4e0d6e489559ce1249c" dependencies = [ - "indexmap 2.0.0", + "indexmap", "itoa", "ryu", "serde", @@ -6040,7 +6018,7 @@ version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ - "indexmap 1.9.3", + "indexmap", "toml_datetime", "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index cec4403202fd..b2b9e25d8803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,7 +137,6 @@ web-time = "0.2.0" # See also https://gpuweb.github.io/gpuweb/explainer/#multithreading-transfer (unsolved part of the Spec as of writing!) wgpu = { version = "0.17.0", features = ["fragile-send-sync-non-atomic-wasm"] } wgpu-core = "0.17.0" -xshell = "0.2" [profile.dev] diff --git a/crates/re_types_builder/Cargo.toml b/crates/re_types_builder/Cargo.toml index 6928554082f3..339a2a2847e1 100644 --- a/crates/re_types_builder/Cargo.toml +++ b/crates/re_types_builder/Cargo.toml @@ -37,7 +37,7 @@ rayon.workspace = true rust-format = "0.3" syn = "2.0" unindent.workspace = true -xshell.workspace = true +xshell = "0.2" [build-dependencies] @@ -46,4 +46,4 @@ xshell.workspace = true re_build_tools.workspace = true # External -xshell.workspace = true +xshell = "0.2" diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 94582cc8138b..4fd46064578b 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -117,5 +117,5 @@ re_build_tools.workspace = true # External serde = { version = "1", features = ["derive"] } serde_json = "1" -serde_yaml = "0.9" -xshell.workspace = true +serde_yaml = "=0.9.21" +xshell = "0.2" From 65143c919397a5fa39bee1c31a13b94d45ab2f1e Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:36:05 +0200 Subject: [PATCH 12/22] fix example manifest links --- crates/re_viewer/build.rs | 4 ++-- crates/re_viewer/data/examples_manifest.json | 24 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index 512b72192b6d..6e01ebb9040f 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -122,8 +122,8 @@ impl TryFrom for ManifestEntry { title: get!(example, title), description: get!(example, description), tags: get!(example, tags), - demo_url: format!("{base_url}/examples/arkit_scenes/"), - rrd_url: format!("{base_url}/examples/arkit_scenes/data.rrd"), + demo_url: format!("{base_url}/examples/{}/", example.name), + rrd_url: format!("{base_url}/examples/{}/data.rrd", example.name), thumbnail: Thumbnail { url: get!(example, thumbnail), width: thumbnail_dimensions[0], diff --git a/crates/re_viewer/data/examples_manifest.json b/crates/re_viewer/data/examples_manifest.json index de821ef56a35..6a32291d0575 100644 --- a/crates/re_viewer/data/examples_manifest.json +++ b/crates/re_viewer/data/examples_manifest.json @@ -27,8 +27,8 @@ "3d", "api-example" ], - "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/dna/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/dna/data.rrd", "thumbnail": { "url": "https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png", "width": 480, @@ -44,8 +44,8 @@ "mri", "dicom" ], - "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/dicom_mri/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/dicom_mri/data.rrd", "thumbnail": { "url": "https://static.rerun.io/b8b25dd01e892e6daf5177e6fc05ff5feb19ee8d_dicom_mri_480w.png", "width": 480, @@ -63,8 +63,8 @@ "pinhole-camera", "time-series" ], - "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/structure_from_motion/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/structure_from_motion/data.rrd", "thumbnail": { "url": "https://static.rerun.io/033edff752f86bcdc9a81f7877e0b4411ff4e6c5_structure_from_motion_480w.png", "width": 480, @@ -80,8 +80,8 @@ "plots", "api-example" ], - "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/plots/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/plots/data.rrd", "thumbnail": { "url": "https://static.rerun.io/ca0c72df93d70c79b0e640fb4b7c33cdc0bfe5f4_plots_480w.png", "width": 480, @@ -99,8 +99,8 @@ "object-tracking", "opencv" ], - "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/detect_and_track_objects/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/detect_and_track_objects/data.rrd", "thumbnail": { "url": "https://static.rerun.io/efb301d64eef6f25e8f6ae29294bd003c0cda3a7_detect_and_track_objects_480w.png", "width": 480, @@ -117,8 +117,8 @@ "2D", "3D" ], - "demo_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/", - "rrd_url": "https://demo.rerun.io/version/nightly/examples/arkit_scenes/data.rrd", + "demo_url": "https://demo.rerun.io/version/nightly/examples/human_pose_tracking/", + "rrd_url": "https://demo.rerun.io/version/nightly/examples/human_pose_tracking/data.rrd", "thumbnail": { "url": "https://static.rerun.io/277b9c72da1d0d0ae9d221f7552dede9c4d5b2fa_human_pose_tracking_480w.png", "width": 480, From abe62b47f9cc745f1c3f7cdab4f969790738a60e Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:38:32 +0200 Subject: [PATCH 13/22] `main`, not `master` --- .github/workflows/reusable_upload_web.yml | 8 ++++---- .github/workflows/reusable_upload_web_demo.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reusable_upload_web.yml b/.github/workflows/reusable_upload_web.yml index d7e2f5a70dec..1a75c4852e0b 100644 --- a/.github/workflows/reusable_upload_web.yml +++ b/.github/workflows/reusable_upload_web.yml @@ -96,7 +96,7 @@ jobs: parent: false - name: "Upload web-viewer (prerelease)" - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: path: "web_viewer" @@ -104,7 +104,7 @@ jobs: parent: false - name: "Upload RRD (prerelease)" - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: path: "rrd" @@ -112,7 +112,7 @@ jobs: parent: false - name: "Upload web-viewer (nightly)" - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: path: "web_viewer" @@ -120,7 +120,7 @@ jobs: parent: false - name: "Upload RRD (nightly)" - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: path: "rrd" diff --git a/.github/workflows/reusable_upload_web_demo.yml b/.github/workflows/reusable_upload_web_demo.yml index 4eda1fcbfbc1..208035894564 100644 --- a/.github/workflows/reusable_upload_web_demo.yml +++ b/.github/workflows/reusable_upload_web_demo.yml @@ -81,7 +81,7 @@ jobs: parent: false - name: "Upload web demo (prerelease)" - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: path: "web_demo" @@ -89,7 +89,7 @@ jobs: parent: false - name: "Upload web demo (nightly)" - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: path: "web_demo" From 3896f80b248b3f11413898b681f32c7ad2bea222 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:54:15 +0200 Subject: [PATCH 14/22] document `re_viewer/build.rs` --- crates/re_viewer/build.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index 6e01ebb9040f..f5161de9e41e 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -1,3 +1,18 @@ +//! This build script generates the `data/examples_manifest.json` file. +//! It looks at all examples in the workspace (under `examples/python`), +//! and only includes those with a `build_args` set in their `README.md` +//! frontmatter. +//! +//! The URLs embedded in the `example_manifest.json` file point to a specific version. +//! This version is resolved according to the current environment: +//! +//! If the `CI` env var is set + the branch name is not `main`, then: +//! - On any `release-x.y.z` branch, the version is `version/x.y.z` +//! - On any other branch, the version is `commit/$COMMIT_SHORT_HASH` +//! +//! Otherwise, the version is `version/nightly`. This means local builds, +//! and builds on `main` point to `version/nightly`. + use std::path::Path; use xshell::cmd; From 9a085b989f072428276526123752a5d1fc894c87 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:41:04 +0200 Subject: [PATCH 15/22] update `thumbnails.py` summary --- scripts/ci/thumbnails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/thumbnails.py b/scripts/ci/thumbnails.py index 208d083d822c..ebc1d077a675 100755 --- a/scripts/ci/thumbnails.py +++ b/scripts/ci/thumbnails.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -"""Check or update example thumbnails.""" +"""Checks or updates cached thumbnail dimensions in example READMEs.""" from __future__ import annotations import argparse From 519bf89a309717621e43c54ea960271d2fc9acd0 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:47:14 +0200 Subject: [PATCH 16/22] only call git once per run on CI --- crates/re_viewer/build.rs | 68 +++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index f5161de9e41e..db7acb5b718c 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -91,17 +91,8 @@ struct ManifestEntry { thumbnail: Thumbnail, } -#[derive(serde::Serialize)] -struct Thumbnail { - url: String, - width: u64, - height: u64, -} - -impl TryFrom for ManifestEntry { - type Error = AnyError; - - fn try_from(example: Example) -> Result { +impl ManifestEntry { + fn new(example: Example, base_url: &str) -> Result { macro_rules! get { ($e:ident, $f:ident) => { match $e.readme.$f { @@ -111,26 +102,6 @@ impl TryFrom for ManifestEntry { }; } - let mut base_url = std::env::var("EXAMPLES_MANIFEST_BASE_URL") - .unwrap_or_else(|_e| "https://demo.rerun.io/version/nightly".into()); - - if std::env::var("CI").is_ok() { - // We're in CI: - let sh = Shell::new()?; - let branch = git_branch_name(&sh)?; - // If we are on `main`, leave the base url at `version/nightly` - if branch != "main" { - if let Some(version) = parse_release_version(&branch) { - // In builds on `release-x.y.z` branches, use `version/{x.y.z}`. - base_url = format!("https://demo.rerun.io/version/{version}"); - } else { - // On any other branch, use `commit/{short_sha}`. - let sha = git_short_hash(&sh)?; - base_url = format!("https://demo.rerun.io/commit/{sha}"); - } - } - } - let thumbnail_dimensions = get!(example, thumbnail_dimensions); Ok(Self { @@ -149,6 +120,13 @@ impl TryFrom for ManifestEntry { } } +#[derive(serde::Serialize)] +struct Thumbnail { + url: String, + width: u64, + height: u64, +} + struct Example { name: String, readme: Frontmatter, @@ -192,12 +170,38 @@ fn parse_frontmatter>(path: P) -> Result> { )?)) } +fn get_base_url() -> Result { + let mut base_url = std::env::var("EXAMPLES_MANIFEST_BASE_URL") + .unwrap_or_else(|_e| "https://demo.rerun.io/version/nightly".into()); + + if std::env::var("CI").is_ok() { + // We're in CI: + let sh = Shell::new()?; + let branch = git_branch_name(&sh)?; + // If we are on `main`, leave the base url at `version/nightly` + if branch != "main" { + if let Some(version) = parse_release_version(&branch) { + // In builds on `release-x.y.z` branches, use `version/{x.y.z}`. + base_url = format!("https://demo.rerun.io/version/{version}"); + } else { + // On any other branch, use `commit/{short_sha}`. + let sha = git_short_hash(&sh)?; + base_url = format!("https://demo.rerun.io/commit/{sha}"); + } + } + } + + Ok(base_url) +} + const MANIFEST_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/data/examples_manifest.json"); fn write_examples_manifest() -> Result<()> { + let base_url = get_base_url()?; + let mut manifest = vec![]; for example in examples()? { - manifest.push(ManifestEntry::try_from(example)?); + manifest.push(ManifestEntry::new(example, &base_url)?); } re_build_tools::write_file_if_necessary( MANIFEST_PATH, From 86047898cb76b4feb1b85ce2cf4d2a108f43e1fb Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 15:54:39 +0200 Subject: [PATCH 17/22] explain `nightly` tracking `main` --- .github/workflows/reusable_upload_web.yml | 2 ++ .github/workflows/reusable_upload_web_demo.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/reusable_upload_web.yml b/.github/workflows/reusable_upload_web.yml index 1a75c4852e0b..f73a8c386796 100644 --- a/.github/workflows/reusable_upload_web.yml +++ b/.github/workflows/reusable_upload_web.yml @@ -112,6 +112,7 @@ jobs: parent: false - name: "Upload web-viewer (nightly)" + # TEMP: Tracking `main` until we can do actual nightly builds. if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: @@ -120,6 +121,7 @@ jobs: parent: false - name: "Upload RRD (nightly)" + # TEMP: Tracking `main` until we can do actual nightly builds. if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: diff --git a/.github/workflows/reusable_upload_web_demo.yml b/.github/workflows/reusable_upload_web_demo.yml index 208035894564..10bf39581ed0 100644 --- a/.github/workflows/reusable_upload_web_demo.yml +++ b/.github/workflows/reusable_upload_web_demo.yml @@ -89,6 +89,7 @@ jobs: parent: false - name: "Upload web demo (nightly)" + # TEMP: Tracking `main` until we can do actual nightly builds. if: github.ref == 'refs/heads/main' uses: google-github-actions/upload-cloud-storage@v1 with: From 5c22115e849658a52b0aded949dda60ba6779cae Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:20:33 +0200 Subject: [PATCH 18/22] add `demo` field to frontmatter --- crates/re_viewer/build.rs | 6 ++++-- examples/python/arkit_scenes/README.md | 2 +- examples/python/detect_and_track_objects/README.md | 2 +- examples/python/dicom_mri/README.md | 2 +- examples/python/dna/README.md | 2 +- examples/python/human_pose_tracking/README.md | 2 +- examples/python/plots/README.md | 2 +- examples/python/structure_from_motion/README.md | 1 + 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index db7acb5b718c..4cd09518dbb5 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -77,7 +77,8 @@ struct Frontmatter { description: Option, thumbnail: Option, thumbnail_dimensions: Option<[u64; 2]>, - build_args: Option>, + #[serde(default)] + demo: bool, } #[derive(serde::Serialize)] @@ -142,7 +143,7 @@ fn examples() -> Result> { if metadata.is_dir() && readme.exists() { let readme = parse_frontmatter(readme)?; let Some(readme) = readme else { continue }; - if readme.build_args.is_none() { + if !readme.demo { continue; } examples.push(Example { name, readme }); @@ -154,6 +155,7 @@ fn examples() -> Result> { fn parse_frontmatter>(path: P) -> Result> { let path = path.as_ref(); let content = std::fs::read_to_string(path)?; + re_build_tools::rerun_if_changed(path); let Some(content) = content.strip_prefix("---\n") else { return Ok(None); }; diff --git a/examples/python/arkit_scenes/README.md b/examples/python/arkit_scenes/README.md index 015204a5d358..d8ac279dfa3d 100644 --- a/examples/python/arkit_scenes/README.md +++ b/examples/python/arkit_scenes/README.md @@ -5,7 +5,7 @@ tags: [2D, 3D, depth, mesh, object-detection, pinhole-camera] description: "Visualize the ARKitScenes dataset, which contains color+depth images, the reconstructed mesh and labeled bounding boxes." thumbnail: https://static.rerun.io/8b90a80c72b27fad289806b7e5dff0c9ac97e87c_arkit_scenes_480w.png thumbnail_dimensions: [480, 243] -build_args: [] +demo: true --- diff --git a/examples/python/detect_and_track_objects/README.md b/examples/python/detect_and_track_objects/README.md index 5cf7a70c3daa..eed12b25d9a8 100644 --- a/examples/python/detect_and_track_objects/README.md +++ b/examples/python/detect_and_track_objects/README.md @@ -5,7 +5,7 @@ tags: [2D, huggingface, object-detection, object-tracking, opencv] description: "Visualize object detection and segmentation using the Huggingface `transformers` library." thumbnail: https://static.rerun.io/efb301d64eef6f25e8f6ae29294bd003c0cda3a7_detect_and_track_objects_480w.png thumbnail_dimensions: [480, 279] -build_args: [] +demo: true --- diff --git a/examples/python/dicom_mri/README.md b/examples/python/dicom_mri/README.md index 7d3b0401b6d5..1ad3156c6d5d 100644 --- a/examples/python/dicom_mri/README.md +++ b/examples/python/dicom_mri/README.md @@ -5,7 +5,7 @@ tags: [tensor, mri, dicom] description: "Example using a DICOM MRI scan. This demonstrates the flexible tensor slicing capabilities of the Rerun viewer." thumbnail: https://static.rerun.io/b8b25dd01e892e6daf5177e6fc05ff5feb19ee8d_dicom_mri_480w.png thumbnail_dimensions: [480, 285] -build_args: [] +demo: true --- diff --git a/examples/python/dna/README.md b/examples/python/dna/README.md index 0550a973f355..e7a97b4aa2b8 100644 --- a/examples/python/dna/README.md +++ b/examples/python/dna/README.md @@ -5,7 +5,7 @@ tags: [3d, api-example] description: "Simple example of logging point and line primitives to draw a 3D helix." thumbnail: https://static.rerun.io/ea7a9ab2f716bd37d1bbc1eabf3f55e4f526660e_helix_480w.png thumbnail_dimensions: [480, 285] -build_args: [] +demo: true --- diff --git a/examples/python/human_pose_tracking/README.md b/examples/python/human_pose_tracking/README.md index 7b1c60357722..163b03552b7c 100644 --- a/examples/python/human_pose_tracking/README.md +++ b/examples/python/human_pose_tracking/README.md @@ -5,7 +5,7 @@ tags: [mediapipe, keypoint-detection, 2D, 3D] description: "Use the MediaPipe Pose solution to detect and track a human pose in video." thumbnail: https://static.rerun.io/277b9c72da1d0d0ae9d221f7552dede9c4d5b2fa_human_pose_tracking_480w.png thumbnail_dimensions: [480, 272] -build_args: [] +demo: true --- diff --git a/examples/python/plots/README.md b/examples/python/plots/README.md index 698804ae0477..d2a2b26d7a35 100644 --- a/examples/python/plots/README.md +++ b/examples/python/plots/README.md @@ -5,7 +5,7 @@ tags: [2d, plots, api-example] description: "Demonstration of various plots and charts supported by Rerun." thumbnail: https://static.rerun.io/ca0c72df93d70c79b0e640fb4b7c33cdc0bfe5f4_plots_480w.png thumbnail_dimensions: [480, 271] -build_args: [] +demo: true --- diff --git a/examples/python/structure_from_motion/README.md b/examples/python/structure_from_motion/README.md index fc1d409a76cb..4e9ed45cc63f 100644 --- a/examples/python/structure_from_motion/README.md +++ b/examples/python/structure_from_motion/README.md @@ -5,6 +5,7 @@ tags: [2D, 3D, colmap, pinhole-camera, time-series] description: "Visualize a sparse reconstruction by COLMAP, a general-purpose Structure-from-Motion and Multi-View Stereo pipeline." thumbnail: https://static.rerun.io/033edff752f86bcdc9a81f7877e0b4411ff4e6c5_structure_from_motion_480w.png thumbnail_dimensions: [480, 275] +demo: true build_args: ["--dataset=colmap_fiat", "--resize=800x600"] --- From 6036a40fd23a1322baa8068260e8a3a1a37e6cba Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:21:49 +0200 Subject: [PATCH 19/22] update `build.rs` comment --- crates/re_viewer/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index 4cd09518dbb5..3aa968512cca 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -1,6 +1,6 @@ //! This build script generates the `data/examples_manifest.json` file. //! It looks at all examples in the workspace (under `examples/python`), -//! and only includes those with a `build_args` set in their `README.md` +//! and only includes those with `demo` set to `true` in their `README.md` //! frontmatter. //! //! The URLs embedded in the `example_manifest.json` file point to a specific version. From 4765fb4b61fdb8b220b8e188b8706990729e1e6a Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 23:24:11 +0200 Subject: [PATCH 20/22] minor cleanup - `Frontmatter` does not need `Option` fields - `parse_release_version` does not need to format the version --- crates/re_viewer/build.rs | 67 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/crates/re_viewer/build.rs b/crates/re_viewer/build.rs index 3aa968512cca..3f675b169aca 100644 --- a/crates/re_viewer/build.rs +++ b/crates/re_viewer/build.rs @@ -53,30 +53,35 @@ fn git_short_hash(sh: &Shell) -> Result { Ok(full_hash.trim()[0..7].to_string()) } -fn parse_release_version(branch: &str) -> Option { +fn parse_release_version(branch: &str) -> Option<&str> { // release-\d+.\d+.\d+ - let branch = branch.strip_prefix("release-")?; + let version = branch.strip_prefix("release-")?; - let mut version_parts = branch.split('.'); - let major = version_parts.next()?.parse::().ok()?; - let minor = version_parts.next()?.parse::().ok()?; - let patch = version_parts.next()?.parse::().ok()?; + let mut version_parts = version.split('.'); + version_parts.next()?.parse::().ok()?; + version_parts.next()?.parse::().ok()?; + version_parts.next()?.parse::().ok()?; if version_parts.next().is_some() { return None; } - Some(format!("{major}.{minor}.{patch}")) + Some(version) } #[derive(serde::Deserialize)] struct Frontmatter { - title: Option, - tags: Option>, - description: Option, - thumbnail: Option, - thumbnail_dimensions: Option<[u64; 2]>, + #[serde(default)] + title: String, + #[serde(default)] + tags: Vec, + #[serde(default)] + description: String, + #[serde(default)] + thumbnail: String, + #[serde(default)] + thumbnail_dimensions: [u64; 2], #[serde(default)] demo: bool, } @@ -93,31 +98,21 @@ struct ManifestEntry { } impl ManifestEntry { - fn new(example: Example, base_url: &str) -> Result { - macro_rules! get { - ($e:ident, $f:ident) => { - match $e.readme.$f { - Some(value) => value, - None => bail!("{:?} is missing field {:?}", $e.name, stringify!($f)), - } - }; - } - - let thumbnail_dimensions = get!(example, thumbnail_dimensions); - - Ok(Self { - title: get!(example, title), - description: get!(example, description), - tags: get!(example, tags), - demo_url: format!("{base_url}/examples/{}/", example.name), - rrd_url: format!("{base_url}/examples/{}/data.rrd", example.name), + fn new(example: Example, base_url: &str) -> Self { + let Example { name, readme } = example; + Self { + title: readme.title, + description: readme.description, + tags: readme.tags, + demo_url: format!("{base_url}/examples/{name}/"), + rrd_url: format!("{base_url}/examples/{name}/data.rrd"), thumbnail: Thumbnail { - url: get!(example, thumbnail), - width: thumbnail_dimensions[0], - height: thumbnail_dimensions[1], + url: readme.thumbnail, + width: readme.thumbnail_dimensions[0], + height: readme.thumbnail_dimensions[1], }, - name: example.name, - }) + name, + } } } @@ -203,7 +198,7 @@ fn write_examples_manifest() -> Result<()> { let mut manifest = vec![]; for example in examples()? { - manifest.push(ManifestEntry::new(example, &base_url)?); + manifest.push(ManifestEntry::new(example, &base_url)); } re_build_tools::write_file_if_necessary( MANIFEST_PATH, From 116ae7920896f6cc2f7818838fb77043bde9e944 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 23:25:04 +0200 Subject: [PATCH 21/22] use docker image in rerun lints job --- .github/workflows/reusable_checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reusable_checks.yml b/.github/workflows/reusable_checks.yml index f8ec3cc1c3ff..9f76bb113fd9 100644 --- a/.github/workflows/reusable_checks.yml +++ b/.github/workflows/reusable_checks.yml @@ -253,6 +253,8 @@ jobs: misc-rerun-lints: name: Rerun lints runs-on: ubuntu-latest + container: + image: rerunio/ci_docker:0.9 steps: - uses: actions/checkout@v4 with: From 555adddf85c10e780aedcf1fd4556a6e09dbdf2a Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Mon, 18 Sep 2023 23:34:33 +0200 Subject: [PATCH 22/22] ...remove container from rerun lints job --- .github/workflows/reusable_checks.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/reusable_checks.yml b/.github/workflows/reusable_checks.yml index 9f76bb113fd9..f8ec3cc1c3ff 100644 --- a/.github/workflows/reusable_checks.yml +++ b/.github/workflows/reusable_checks.yml @@ -253,8 +253,6 @@ jobs: misc-rerun-lints: name: Rerun lints runs-on: ubuntu-latest - container: - image: rerunio/ci_docker:0.9 steps: - uses: actions/checkout@v4 with: