From bc1661f5864de4aaab00357c3503fb66c42b8131 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 10 Jan 2024 16:09:56 +0100 Subject: [PATCH 1/5] Rename `code-examples/roundtrips.py` to `compare_code_example_output.py` --- .github/workflows/contrib_rerun_py.yml | 4 ++-- .github/workflows/reusable_test_wheels.yml | 4 ++-- docs/code-examples/README.md | 4 ++-- .../{roundtrips.py => compare_code_example_output.py} | 2 +- noxfile.py | 2 +- scripts/fast_lint.py | 0 6 files changed, 8 insertions(+), 8 deletions(-) rename docs/code-examples/{roundtrips.py => compare_code_example_output.py} (99%) mode change 100644 => 100755 scripts/fast_lint.py diff --git a/.github/workflows/contrib_rerun_py.yml b/.github/workflows/contrib_rerun_py.yml index d960a1c2932c..d96baefa230c 100644 --- a/.github/workflows/contrib_rerun_py.yml +++ b/.github/workflows/contrib_rerun_py.yml @@ -112,13 +112,13 @@ jobs: run: | RUST_LOG=debug tests/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build - - name: Run docs/code-examples/roundtrips.py + - name: Run docs/code-example/compare_code_example_output.py shell: bash # --release so we can inherit from some of the artifacts that maturin has just built before # --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache… even though this is the target anyhow… # --no-py-build because rerun-sdk is already built and installed run: | - RUST_LOG=debug docs/code-examples/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build + RUST_LOG=debug docs/code-example/compare_code_example_output.py --release --target x86_64-unknown-linux-gnu --no-py-build - name: Cache RRD dataset id: dataset diff --git a/.github/workflows/reusable_test_wheels.yml b/.github/workflows/reusable_test_wheels.yml index 5fef8d6fca9e..a4119e10d682 100644 --- a/.github/workflows/reusable_test_wheels.yml +++ b/.github/workflows/reusable_test_wheels.yml @@ -195,11 +195,11 @@ jobs: run: | RUST_LOG=debug tests/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build - - name: Run docs/code-examples/roundtrips.py + - name: Run docs/code-example/compare_code_example_output.py if: ${{ inputs.PLATFORM != 'windows' }} shell: bash # --release so we can inherit from some of the artifacts that maturin has just built before # --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache… even though this is the target anyhow… # --no-py-build because rerun-sdk is already built and installed run: | - RUST_LOG=debug docs/code-examples/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build + RUST_LOG=debug docs/code-example/compare_code_example_output.py --release --target x86_64-unknown-linux-gnu --no-py-build diff --git a/docs/code-examples/README.md b/docs/code-examples/README.md index 0de54aef88dc..a741c44b9f0c 100644 --- a/docs/code-examples/README.md +++ b/docs/code-examples/README.md @@ -23,8 +23,8 @@ These tests check that A) all of our SDKs yield the exact same data when used th ### Usage -To run the roundtrip tests, check out `./docs/code-examples/roundtrips.py --help`. -`./docs/code-examples/roundtrips.py` is a valid invocation that will build all 3 SDKs and run all tests for all of them. +To run the roundtrip tests, check out `./docs/code-example/compare_code_example_output.py --help`. +`./docs/code-example/compare_code_example_output.py` is a valid invocation that will build all 3 SDKs and run all tests for all of them. ### Implementing new tests diff --git a/docs/code-examples/roundtrips.py b/docs/code-examples/compare_code_example_output.py similarity index 99% rename from docs/code-examples/roundtrips.py rename to docs/code-examples/compare_code_example_output.py index d5352dc4bf19..d81703fc335c 100755 --- a/docs/code-examples/roundtrips.py +++ b/docs/code-examples/compare_code_example_output.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -"""Run end-to-end cross-language roundtrip tests for all code examples.""" +"""Runs all our code-examples, for all our languages, and compares the .rrd they output.""" from __future__ import annotations diff --git a/noxfile.py b/noxfile.py index 1bc6c53b4430..63bd6ee60ad6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -68,6 +68,6 @@ def roundtrips(session: nox.Session) -> None: extra_args.extend(session.posargs) session.run("python", "tests/roundtrips.py", "--no-py-build", *extra_args) - session.run("python", "docs/code-examples/roundtrips.py", "--no-py-build", *extra_args) + session.run("python", "docs/code-example/compare_code_example_output.py", "--no-py-build", *extra_args) roundtrip_cpp_built = True diff --git a/scripts/fast_lint.py b/scripts/fast_lint.py old mode 100644 new mode 100755 From af61bfd024cbe0637567f1b6ae105f3e08f703b2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 10 Jan 2024 16:12:18 +0100 Subject: [PATCH 2/5] Remove dead code --- docs/code-examples/compare_code_example_output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/code-examples/compare_code_example_output.py b/docs/code-examples/compare_code_example_output.py index d81703fc335c..f807451d7b2e 100755 --- a/docs/code-examples/compare_code_example_output.py +++ b/docs/code-examples/compare_code_example_output.py @@ -13,7 +13,7 @@ from os.path import isfile, join sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../scripts/") -from roundtrip_utils import cmake_build, cmake_configure, cpp_build_dir, roundtrip_env, run, run_comparison # noqa +from roundtrip_utils import roundtrip_env, run, run_comparison # noqa # fmt: off From b2575873565a895bd0609ff3a3bfe8fe61f5fe94 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 11 Jan 2024 09:06:18 +0100 Subject: [PATCH 3/5] Update readme --- docs/code-examples/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/code-examples/README.md b/docs/code-examples/README.md index a741c44b9f0c..708032925555 100644 --- a/docs/code-examples/README.md +++ b/docs/code-examples/README.md @@ -14,20 +14,20 @@ You can run each example individually using the following: - **Python**: `python .py`, e.g. `python point3d_random.py`. - **Rust**: `cargo run -p code_examples -- [args]`, e.g. `cargo run -p code_examples -- point3d_random`. -## Roundtrips +## Comparison test -All API examples support cross-language roundtrip tests: i.e. we execute the same logging commands from all 3 SDKs, save the results to distinct rrd files, and finally compare these rrd files. +The script `compare_code_example_output.py` execute the same logging commands from all 3 SDKs, save the results to distinct rrd files, and finally compare these rrd files. These tests are then automatically run by the CI, which will loudly complain if the resulting rrd files don't match. These tests check that A) all of our SDKs yield the exact same data when used the same way and B) act as regression tests, relying on the fact that it is extremely unlikely that all supported languages break in the exact same way at the exact same time. ### Usage -To run the roundtrip tests, check out `./docs/code-example/compare_code_example_output.py --help`. -`./docs/code-example/compare_code_example_output.py` is a valid invocation that will build all 3 SDKs and run all tests for all of them. +To run the comparison tests, check out `./docs/code-examples/compare_code_example_output.py --help`. +`./docs/code-examples/compare_code_example_output.py` is a valid invocation that will build all 3 SDKs and run all tests for all of them. ### Implementing new tests Just pick a name for your test, and look at existing examples to get started. The `app_id` must be `rerun_example_`. -The roundtrip process is driven by file names, so make sure all 3 tests use the same name: `.rs`, `.cpp`, `.py`. +The comparison process is driven by file names, so make sure all 3 tests use the same name: `.rs`, `.cpp`, `.py`. From c3a71f528cc327be98f1d952a6e47911cf10de5c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 11 Jan 2024 09:09:29 +0100 Subject: [PATCH 4/5] Improve test output --- docs/code-examples/compare_code_example_output.py | 4 ++-- scripts/roundtrip_utils.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/code-examples/compare_code_example_output.py b/docs/code-examples/compare_code_example_output.py index f807451d7b2e..f344963efa98 100755 --- a/docs/code-examples/compare_code_example_output.py +++ b/docs/code-examples/compare_code_example_output.py @@ -126,7 +126,6 @@ def main() -> None: examples.sort() print("----------------------------------------------------------") - print(f"Running {len(examples)} examples…") active_languages = ["rust"] if not args.no_cpp: @@ -135,14 +134,15 @@ def main() -> None: active_languages.append("py") # Running CMake in parallel causes failures during rerun_sdk & arrow build. - # TODO(andreas): Tell cmake in a single command to build everything at once. if not args.no_cpp_build: + print(f"Running {len(examples)} C++ examples…") for example in examples: example_opt_out_entirely = opt_out_run.get(example, []) if "cpp" in example_opt_out_entirely: continue run_example(example, "cpp", args) + print(f"Running {len(examples)} Rust and Python examples…") with multiprocessing.Pool() as pool: jobs = [] for example in examples: diff --git a/scripts/roundtrip_utils.py b/scripts/roundtrip_utils.py index a45819985706..40d2cb517d82 100644 --- a/scripts/roundtrip_utils.py +++ b/scripts/roundtrip_utils.py @@ -19,9 +19,7 @@ def get_repo_root() -> str: else: get_rev_parse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True) assert get_rev_parse.returncode == 0 - repo_root = get_rev_parse.stdout.decode("utf-8").strip() - print("Repository root:", repo_root) - return repo_root + return get_rev_parse.stdout.decode("utf-8").strip() def run( From b1b638cab10537d5dd66b704e22edb3556d4997d Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 11 Jan 2024 11:04:20 +0100 Subject: [PATCH 5/5] typo --- .github/workflows/contrib_rerun_py.yml | 4 ++-- .github/workflows/reusable_test_wheels.yml | 4 ++-- noxfile.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/contrib_rerun_py.yml b/.github/workflows/contrib_rerun_py.yml index d96baefa230c..2ce3dcf86f2a 100644 --- a/.github/workflows/contrib_rerun_py.yml +++ b/.github/workflows/contrib_rerun_py.yml @@ -112,13 +112,13 @@ jobs: run: | RUST_LOG=debug tests/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build - - name: Run docs/code-example/compare_code_example_output.py + - name: Run docs/code-examples/compare_code_example_output.py shell: bash # --release so we can inherit from some of the artifacts that maturin has just built before # --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache… even though this is the target anyhow… # --no-py-build because rerun-sdk is already built and installed run: | - RUST_LOG=debug docs/code-example/compare_code_example_output.py --release --target x86_64-unknown-linux-gnu --no-py-build + RUST_LOG=debug docs/code-examples/compare_code_example_output.py --release --target x86_64-unknown-linux-gnu --no-py-build - name: Cache RRD dataset id: dataset diff --git a/.github/workflows/reusable_test_wheels.yml b/.github/workflows/reusable_test_wheels.yml index a4119e10d682..dffce6e91b9a 100644 --- a/.github/workflows/reusable_test_wheels.yml +++ b/.github/workflows/reusable_test_wheels.yml @@ -195,11 +195,11 @@ jobs: run: | RUST_LOG=debug tests/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build - - name: Run docs/code-example/compare_code_example_output.py + - name: Run docs/code-examples/compare_code_example_output.py if: ${{ inputs.PLATFORM != 'windows' }} shell: bash # --release so we can inherit from some of the artifacts that maturin has just built before # --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache… even though this is the target anyhow… # --no-py-build because rerun-sdk is already built and installed run: | - RUST_LOG=debug docs/code-example/compare_code_example_output.py --release --target x86_64-unknown-linux-gnu --no-py-build + RUST_LOG=debug docs/code-examples/compare_code_example_output.py --release --target x86_64-unknown-linux-gnu --no-py-build diff --git a/noxfile.py b/noxfile.py index 63bd6ee60ad6..ca52b8948568 100644 --- a/noxfile.py +++ b/noxfile.py @@ -68,6 +68,6 @@ def roundtrips(session: nox.Session) -> None: extra_args.extend(session.posargs) session.run("python", "tests/roundtrips.py", "--no-py-build", *extra_args) - session.run("python", "docs/code-example/compare_code_example_output.py", "--no-py-build", *extra_args) + session.run("python", "docs/code-examples/compare_code_example_output.py", "--no-py-build", *extra_args) roundtrip_cpp_built = True