From 56f90bd39bf6058717d5d2426623b10c1e7169be Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:01:20 +0100 Subject: [PATCH 1/5] remove benchmark tests --- tests/benchmarks/__init__.py | 0 tests/benchmarks/test_cellfinder.py | 100 ---------------------------- 2 files changed, 100 deletions(-) delete mode 100644 tests/benchmarks/__init__.py delete mode 100644 tests/benchmarks/test_cellfinder.py diff --git a/tests/benchmarks/__init__.py b/tests/benchmarks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/benchmarks/test_cellfinder.py b/tests/benchmarks/test_cellfinder.py deleted file mode 100644 index c323aed0..00000000 --- a/tests/benchmarks/test_cellfinder.py +++ /dev/null @@ -1,100 +0,0 @@ -import json -import subprocess -from pathlib import Path - -import pytest -from asv import util - - -@pytest.fixture() -def asv_config_monkeypatched_path(tmp_path: Path) -> str: - """ - Create a monkeypatched asv.conf.json file - in a Pytest-generated temporary directory - and return its path - - Parameters - ---------- - tmp_path : Path - path to pytest-generated temporary directory - - Returns - ------- - str - Path to monkeypatched asv config file - """ - # read reference asv config - asv_original_path = Path(__file__).resolve().parents[3] / "asv.conf.json" - asv_monkeypatched_dict = util.load_json( - asv_original_path, js_comments=True - ) - - # change directories - for ky in ["env_dir", "results_dir", "html_dir"]: - asv_monkeypatched_dict[ky] = str( - Path(tmp_path) / asv_monkeypatched_dict[ky] - ) - - # change repo to URL rather than local - asv_monkeypatched_dict[ - "repo" - ] = "https://github.com/brainglobe/brainglobe-workflows.git" - - # define path to a temp json file to dump config data - asv_monkeypatched_path = tmp_path / "asv.conf.json" - - # save monkeypatched config data to json file - with open(asv_monkeypatched_path, "w") as js: - json.dump(asv_monkeypatched_dict, js) - - # check json file exists - assert asv_monkeypatched_path.is_file() - - return str(asv_monkeypatched_path) - - -@pytest.mark.skip(reason="focus of PR32") -def test_run_benchmarks(asv_config_monkeypatched_path): - # --- ideally monkeypatch an asv config so that results are in tmp_dir? - - # set up machine (env_dir, results_dir, html_dir) - asv_machine_output = subprocess.run( - [ - "asv", - "machine", - "--yes", - "--config", - asv_config_monkeypatched_path, - ] - ) - assert asv_machine_output.returncode == 0 - - # run benchmarks - asv_benchmark_output = subprocess.run( - [ - "asv", - "run", - "--config", - asv_config_monkeypatched_path, - # "--dry-run" - # # Do not save any results to disk? not truly testing then - ], - cwd=str( - Path(asv_config_monkeypatched_path).parent - ), # run from where asv config is - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - encoding="utf-8", - ) - # STDOUT: "· Cloning project\n· Fetching recent changes\n· - # Creating environments\n· No __init__.py file in 'benchmarks'\n" - - # check returncode - assert asv_benchmark_output.returncode == 0 - - # check logs? - - # delete directories? - # check teardown after yield: - # https://docs.pytest.org/en/6.2.x/fixture.html#yield-fixtures-recommended From 79eb3325e15b1112ee1df53471cdc206a7f8a373 Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:29:53 +0100 Subject: [PATCH 2/5] add benchmark check after tests --- .github/workflows/test_and_deploy.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index e8951731..a8433aa9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -60,7 +60,12 @@ jobs: - uses: neuroinformatics-unit/actions/test@v2 with: python-version: ${{ matrix.python-version }} - secret-codecov-token: ${{ secrets.CODECOV_TOKEN }} + + - name: Check benchmarks + run: | + pip install --upgrade pip + pip install asv + asv check -v -E existing build_sdist_wheels: name: Build source distribution From 9c38f8f8567cf17a083f3c2ded82297490b6b268 Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:57:31 +0100 Subject: [PATCH 3/5] recover codecov token --- .github/workflows/test_and_deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index a8433aa9..1d7f55a7 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -60,6 +60,7 @@ jobs: - uses: neuroinformatics-unit/actions/test@v2 with: python-version: ${{ matrix.python-version }} + secret-codecov-token: ${{ secrets.CODECOV_TOKEN }} - name: Check benchmarks run: | From b4d096c54942b13245413d70ece7c3567ef6a7ff Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:29:03 +0100 Subject: [PATCH 4/5] add a separate benchmarks checking job --- .github/workflows/test_and_deploy.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 1d7f55a7..83b90d79 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -62,11 +62,22 @@ jobs: python-version: ${{ matrix.python-version }} secret-codecov-token: ${{ secrets.CODECOV_TOKEN }} - - name: Check benchmarks + benchmarks: + name: Check benchmarks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + shell: bash run: | - pip install --upgrade pip - pip install asv - asv check -v -E existing + python -mpip install --upgrade pip + python -mpip install asv + - name: Run asv check + shell: bash + run: asv check -v -E existing build_sdist_wheels: name: Build source distribution From e097500e236093c38e42d03a8ce75e0a968c90d7 Mon Sep 17 00:00:00 2001 From: sfmig <33267254+sfmig@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:34:38 +0100 Subject: [PATCH 5/5] fix missing dependencies --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 83b90d79..f3a302c9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -74,7 +74,7 @@ jobs: shell: bash run: | python -mpip install --upgrade pip - python -mpip install asv + python -mpip install .[asv_version] - name: Run asv check shell: bash run: asv check -v -E existing