Skip to content

Do not assert on Container type in compare_snippet_output #9275

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

Merged
merged 6 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions crates/build/re_dev_tools/src/build_examples/snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ fn collect_snippets_recursively(
let snippet = snippet?;
let meta = snippet.metadata()?;
let path = snippet.path();

if path.file_name().is_some_and(|p| p == "__init__.py") {
continue;
}

// Compare snippet outputs sometimes leaves orphaned rrd files.
if path.extension().is_some_and(|p| p == "rrd") {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ fn collect_snippets_recursively<'o>(
let meta = snippet.metadata()?;
let path = snippet.path();

if path.file_name().is_some_and(|name| name == "__init__.py") {
continue;
}

let name = path.file_stem().unwrap().to_str().unwrap().to_owned();
let name_qualified = path.strip_prefix(snippet_root_path)?.with_extension("");
let name_qualified = name_qualified.to_str().unwrap().replace('\\', "/");
Expand Down
10 changes: 6 additions & 4 deletions docs/snippets/compare_snippet_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys
import time
from pathlib import Path
from typing import Any
from typing import Any, cast

import tomlkit
from tomlkit.container import Container
Expand All @@ -21,10 +21,10 @@

config_path = Path(__file__).parent / "snippets.toml"
config = tomlkit.loads(config_path.read_text())
assert isinstance(config["opt_out"], Container)

OPT_OUT_ENTIRELY: dict[str, Any] = config["opt_out"]["run"].value
OPT_OUT_COMPARE = config["opt_out"]["compare"].value
OPT_OUT: dict[str, Any] = cast(Container, config["opt_out"])
OPT_OUT_ENTIRELY: dict[str, Any] = OPT_OUT["run"].value
OPT_OUT_COMPARE = OPT_OUT["compare"].value
EXTRA_ARGS = config["extra_args"].value


Expand Down Expand Up @@ -126,6 +126,8 @@ def main() -> None:
dir = os.path.join(os.path.dirname(__file__), "all")
for file in glob.glob(dir + "/**", recursive=True):
name = os.path.basename(file)
if name == "__init__.py":
continue
name, extension = os.path.splitext(name)
if extension == ".cpp" and not args.no_cpp or extension == ".py" and not args.no_py or extension == ".rs":
subdir = os.path.relpath(os.path.dirname(file), dir)
Expand Down
11 changes: 10 additions & 1 deletion docs/snippets/snippets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ features = [
# You should only ever use this if the test isn't implemented and cannot yet be implemented
# for one or more specific SDKs.
[opt_out.run]
"__init__" = ["py"] # That init file is to make mypy happy.
"./__init__" = [ # That init file is to make mypy happy.
"py",
"cpp",
"rust",
]
"concepts/explicit_recording" = [ # python-specific check
"cpp",
"rust",
Expand Down Expand Up @@ -214,6 +218,11 @@ features = [
# You should only ever use this if the test cannot yet be implemented in a way that yields the right
# data, but you still want to check whether the test runs properly and outputs _something_.
[opt_out.compare]
"./__init__" = [ # That init file is to make mypy happy.
"py",
"cpp",
"rust",
]
"concepts/explicit_recording" = ["cpp", "rust"] # Only python
"concepts/how_helix_was_logged" = ["cpp", "rust"] # Only python
"concepts/different_data_per_timeline" = [
Expand Down
1 change: 1 addition & 0 deletions taplo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include = [
"rerun_notebook/*.toml",
"rerun_py/*.toml",
"tests/rust/**/*.toml",
"docs/snippets/**/*.toml",
]

[formatting]
Expand Down
Loading