Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all test assets to single location & introduce a script to for downloading larger test assets #7401

Merged
merged 3 commits into from
Sep 12, 2024
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
6 changes: 6 additions & 0 deletions docs/snippets/compare_snippet_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def main() -> None:

print("----------------------------------------------------------")

print("Downloading test assets…")
run(["pixi", "run", "python", "./tests/assets/download_test_assets.py"])
print("")

print("----------------------------------------------------------")

active_languages = ["rust"]
if not args.no_cpp:
active_languages.append("cpp")
Expand Down
7 changes: 4 additions & 3 deletions docs/snippets/snippets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ quick_start = [ # These examples don't have exactly the same implementation.


# `$config_dir` will be replaced with the absolute path of `docs/snippets`.
# Note that the snippet comparison tool will automatically run `/tests/assets/download_test_assets.py` before running the snippets.
[extra_args]
"archetypes/asset3d_simple" = ["$config_dir/../assets/cube.glb"]
"archetypes/asset3d_out_of_tree" = ["$config_dir/../assets/cube.glb"]
"archetypes/video_simple" = ["$config_dir/../assets/empty.mp4"]
"archetypes/asset3d_simple" = ["$config_dir/../../tests/assets/cube.glb"]
"archetypes/asset3d_out_of_tree" = ["$config_dir/../../tests/assets/cube.glb"]
"archetypes/video_simple" = ["$config_dir/../../tests/assets/empty.mp4"]
2 changes: 1 addition & 1 deletion rerun_py/tests/unit/test_asset3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import rerun as rr

CUBE_FILEPATH = pathlib.Path(__file__).parent.parent.parent.parent / "docs" / "assets" / "cube.glb"
CUBE_FILEPATH = pathlib.Path(__file__).parent.parent.parent.parent / "tests" / "assets" / "cube.glb"
assert CUBE_FILEPATH.is_file()


Expand Down
1 change: 1 addition & 0 deletions tests/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
video
File renamed without changes.
52 changes: 52 additions & 0 deletions tests/assets/download_test_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
Downloads test assets used by tests.

Usage:
pixi run python ./tests/assets/download_assets.py
"""

from __future__ import annotations

import os
from pathlib import Path
from typing import Final

import requests
import tqdm

test_assets = ["video/Big_Buck_Bunny_1080_10s_av1.mp4"]

test_asset_base_url = "https://storage.googleapis.com/rerun-test-assets/"


def download_file(url: str, dst_file_path: Path) -> None:
"""Download file from url to dst_fpath."""
dst_file_path.parent.mkdir(parents=True, exist_ok=True)
print(f"Downloading {url} to {dst_file_path}")
response = requests.get(url, stream=True)
with tqdm.tqdm.wrapattr(
open(dst_file_path, "wb"),
"write",
miniters=1,
total=int(response.headers.get("content-length", 0)),
desc=f"Downloading {dst_file_path.name}",
) as f:
for chunk in response.iter_content(chunk_size=4096):
f.write(chunk)


def main() -> None:
"""Downloads all test assets."""

test_asset_dir: Final = Path(os.path.dirname(__file__))

for asset in test_assets:
target_file = test_asset_dir / asset
if not target_file.exists():
download_file(test_asset_base_url + asset, target_file)
else:
print(f'Skipping "{asset}" because it already exists.')


if __name__ == "__main__":
main()
File renamed without changes.
Loading