From bef839f7cb6032772e860e0c3ac70afb0e0935e2 Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Sat, 31 Aug 2024 18:35:53 -0600 Subject: [PATCH 1/9] test: adding tests for the tpch queries --- pyproject.toml | 1 + tpch/requirements-tpch.txt | 7 +++++++ tpch/tests/__init__.py | 0 tpch/tests/test_queries.py | 27 +++++++++++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 tpch/requirements-tpch.txt create mode 100644 tpch/tests/__init__.py create mode 100644 tpch/tests/test_queries.py diff --git a/pyproject.toml b/pyproject.toml index ab7ff24ab2..fa1caa2154 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ lint.ignore = [ [tool.ruff.lint.per-file-ignores] "tests/*" = ["S101"] +"tpch/tests/*" = ["S101"] "utils/*" = ["S311", "PTH123"] "tpch/execute/*" = ["T201"] diff --git a/tpch/requirements-tpch.txt b/tpch/requirements-tpch.txt new file mode 100644 index 0000000000..7d321464ef --- /dev/null +++ b/tpch/requirements-tpch.txt @@ -0,0 +1,7 @@ +duckdb +pyarrow +polars +pandas +dask[dataframe] +tqdm +narwhals \ No newline at end of file diff --git a/tpch/tests/__init__.py b/tpch/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tpch/tests/test_queries.py b/tpch/tests/test_queries.py new file mode 100644 index 0000000000..b80bf9b5ec --- /dev/null +++ b/tpch/tests/test_queries.py @@ -0,0 +1,27 @@ +import os +import subprocess +import sys +import unittest +from pathlib import Path + + +class TestQueries(unittest.TestCase): + def test_execute_scripts(self) -> None: + root = Path(__file__).resolve().parent.parent + # directory containing all the queries + execute_dir = root / "execute" + + env = os.environ.copy() + env["PYTHONPATH"] = str(root) + + for script_path in execute_dir.glob("q[1-9]*.py"): + result = subprocess.run( # noqa: S603 + [sys.executable, str(script_path)], + capture_output=True, + text=True, + env=env, + cwd=root, + check=False, + shell=False, + ) + assert result.returncode == 0 From a3306f5b9e1c21b0d044ef90e0dd151f847b4acd Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Sat, 31 Aug 2024 18:38:17 -0600 Subject: [PATCH 2/9] ci: workflow for the queries validation --- .github/workflows/check_tpch_queries.yml | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/check_tpch_queries.yml diff --git a/.github/workflows/check_tpch_queries.yml b/.github/workflows/check_tpch_queries.yml new file mode 100644 index 0000000000..5e307bd227 --- /dev/null +++ b/.github/workflows/check_tpch_queries.yml @@ -0,0 +1,27 @@ +name: Tests for TPCH Queries + +on: + pull_request: + push: + branches: [main, dev/queries_validation] +jobs: + validate-queries: + strategy: + matrix: + python-version: ["3.12"] + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: install-reqs + run: uv pip install --upgrade -r tpch/requirements-tpch.txt --system + - name: generate-data + run: python -m tpch.generate_data + - name: tpch-tests + run: python -m unittest discover -s 'tpch/tests' \ No newline at end of file From 4d0611efdaa7e8500819df0ad398410578adcb19 Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Sat, 31 Aug 2024 18:42:28 -0600 Subject: [PATCH 3/9] test: add description of the queries exceptions --- tpch/tests/test_queries.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tpch/tests/test_queries.py b/tpch/tests/test_queries.py index b80bf9b5ec..4b7cdd8665 100644 --- a/tpch/tests/test_queries.py +++ b/tpch/tests/test_queries.py @@ -24,4 +24,6 @@ def test_execute_scripts(self) -> None: check=False, shell=False, ) - assert result.returncode == 0 + assert ( + result.returncode == 0 + ), f"Script {script_path} failed with error: {result.stderr}" From 724492fcde9b0fc0e5f928352eed4ed0b43bd7a4 Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Sat, 31 Aug 2024 18:44:29 -0600 Subject: [PATCH 4/9] ci: generate queries data in the correct directory --- .github/workflows/check_tpch_queries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_tpch_queries.yml b/.github/workflows/check_tpch_queries.yml index 5e307bd227..c083cce396 100644 --- a/.github/workflows/check_tpch_queries.yml +++ b/.github/workflows/check_tpch_queries.yml @@ -22,6 +22,6 @@ jobs: - name: install-reqs run: uv pip install --upgrade -r tpch/requirements-tpch.txt --system - name: generate-data - run: python -m tpch.generate_data + run: cd tpch && python generate_data.py - name: tpch-tests run: python -m unittest discover -s 'tpch/tests' \ No newline at end of file From 2126c511aa250cc91ccb4b7b8a7b56c7fb00749e Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Mon, 2 Sep 2024 22:32:55 -0600 Subject: [PATCH 5/9] ci: add full-test label trigger for TPCH query validation workflow --- .github/workflows/check_tpch_queries.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_tpch_queries.yml b/.github/workflows/check_tpch_queries.yml index c083cce396..68d00e6988 100644 --- a/.github/workflows/check_tpch_queries.yml +++ b/.github/workflows/check_tpch_queries.yml @@ -2,10 +2,13 @@ name: Tests for TPCH Queries on: pull_request: + types: [labeled] push: - branches: [main, dev/queries_validation] + branches: [main] + jobs: validate-queries: + if: ${{ github.event.label.name == 'full-test' }} strategy: matrix: python-version: ["3.12"] From ff79a1a873b64809e4e625bfbf4d31641a921cd9 Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Tue, 3 Sep 2024 00:21:36 -0600 Subject: [PATCH 6/9] ci: Update TPCH query validation workflow to trigger only on labeled pull requests --- .github/workflows/check_tpch_queries.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/check_tpch_queries.yml b/.github/workflows/check_tpch_queries.yml index 68d00e6988..79852ea742 100644 --- a/.github/workflows/check_tpch_queries.yml +++ b/.github/workflows/check_tpch_queries.yml @@ -3,8 +3,6 @@ name: Tests for TPCH Queries on: pull_request: types: [labeled] - push: - branches: [main] jobs: validate-queries: From fd1d1dcff42683efa6c3a65ac9feb70025eec586 Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Wed, 4 Sep 2024 00:05:50 -0600 Subject: [PATCH 7/9] ci: install locally narwhals --- .github/workflows/check_tpch_queries.yml | 4 +++- tpch/requirements-tpch.txt | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 tpch/requirements-tpch.txt diff --git a/.github/workflows/check_tpch_queries.yml b/.github/workflows/check_tpch_queries.yml index 79852ea742..397163091b 100644 --- a/.github/workflows/check_tpch_queries.yml +++ b/.github/workflows/check_tpch_queries.yml @@ -21,7 +21,9 @@ jobs: - name: Install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: install-reqs - run: uv pip install --upgrade -r tpch/requirements-tpch.txt --system + run: uv pip install --upgrade -r requirements-dev.txt --system + - name: local-install + run: uv pip install -e . --system - name: generate-data run: cd tpch && python generate_data.py - name: tpch-tests diff --git a/tpch/requirements-tpch.txt b/tpch/requirements-tpch.txt deleted file mode 100644 index 7d321464ef..0000000000 --- a/tpch/requirements-tpch.txt +++ /dev/null @@ -1,7 +0,0 @@ -duckdb -pyarrow -polars -pandas -dask[dataframe] -tqdm -narwhals \ No newline at end of file From 8d6a1f1d7471d9358c81d8f18d64479d0de86a27 Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Wed, 4 Sep 2024 00:12:56 -0600 Subject: [PATCH 8/9] ci: add tqdm to the dev dependencies --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 213fcdcb89..2b79fe94b8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,3 +10,4 @@ pytest-env hypothesis scikit-learn dask[dataframe]; python_version >= '3.9' +tqdm From 321f429c8167c3fea6c476cdca4eef635669afea Mon Sep 17 00:00:00 2001 From: Isaias Gutierrez Cruz Date: Wed, 4 Sep 2024 00:23:56 -0600 Subject: [PATCH 9/9] fix: correction in the req-dev.txt syntax --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2b79fe94b8..23ff1757e6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ +tqdm covdefaults duckdb pandas @@ -10,4 +11,3 @@ pytest-env hypothesis scikit-learn dask[dataframe]; python_version >= '3.9' -tqdm