From 32d92d79b9f736b32dabdd7a1d63cafcb4d37486 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 19:44:31 +1300 Subject: [PATCH 01/39] Setup Continuous Benchmarking workflow with pytest-codspeed Measuring the execution speed of tests to track performance of PyGMT functions over time. Using pytest-codspeed, see https://docs.codspeed.io/benchmarks/python#running-the-benchmarks-in-your-ci. Decorated a couple of unit tests with @pytest.mark.benchmark to see if the benchmarking works. --- .github/workflows/benchmarks.yml | 73 ++++++++++++++++++++++++++++++++ pygmt/tests/test_blockm.py | 1 + pygmt/tests/test_grd2xyz.py | 1 + 3 files changed, 75 insertions(+) create mode 100644 .github/workflows/benchmarks.yml diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 00000000000..b8a94753ff8 --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,73 @@ +# Run performance benchmarks +# +# Continuous benchmarking using pytest-codspeed. Measures the execution speed +# of tests marked with @pytest.mark.benchmark decorator. + +name: Benchmarks + +on: + # Run on pushes to the main branch + push: + branches: [ main ] + # Uncomment the 'pull_request' line below to trigger the workflow in PR + pull_request: + # `workflow_dispatch` allows CodSpeed to trigger backtest + # performance analysis in order to generate initial data. + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + benchmarks: + runs-on: ubuntu-22.04 + defaults: + run: + shell: bash -l {0} + + steps: + # Checkout current git repository + - name: Checkout + uses: actions/checkout@v4.1.1 + + # Install Micromamba with conda-forge dependencies + - name: Setup Micromamba + uses: mamba-org/setup-micromamba@v1.7.3 + with: + environment-name: pygmt + condarc: | + channels: + - conda-forge + - nodefaults + cache-downloads: true + cache-environment: true + create-args: >- + python=3.12 + gmt=6.4.0 + numpy=${{ matrix.numpy-version }} + pandas + xarray + netCDF4 + packaging + pytest + pytest-benchmark + + # Install dependencies from PyPI + - name: Install dependencies + run: | + python -m pip install pytest-codspeed + + # Show installed pkg information for postmortem diagnostic + - name: List installed packages + run: micromamba list + + # Install the package that we want to test + - name: Install the package + run: make install + + # Run the benchmark tests + - name: Run benchmarks + uses: CodSpeedHQ/action@v2.0.2 + with: + run: make test PYTEST_EXTRA="-r P --codspeed" diff --git a/pygmt/tests/test_blockm.py b/pygmt/tests/test_blockm.py index c75de7673c0..9b4acb95cd6 100644 --- a/pygmt/tests/test_blockm.py +++ b/pygmt/tests/test_blockm.py @@ -22,6 +22,7 @@ def fixture_dataframe(): return load_sample_data(name="bathymetry") +@pytest.mark.benchmark def test_blockmean_input_dataframe(dataframe): """ Run blockmean by passing in a pandas.DataFrame as input. diff --git a/pygmt/tests/test_grd2xyz.py b/pygmt/tests/test_grd2xyz.py index d53993388c2..2cd555d6d5f 100644 --- a/pygmt/tests/test_grd2xyz.py +++ b/pygmt/tests/test_grd2xyz.py @@ -20,6 +20,7 @@ def fixture_grid(): return load_static_earth_relief() +@pytest.mark.benchmark def test_grd2xyz(grid): """ Make sure grd2xyz works as expected. From 2fabfb873a3ae1e64788a444bb807b17f8d57f97 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 19:53:49 +1300 Subject: [PATCH 02/39] Try fetching all history for setuptools-scm --- .github/workflows/benchmarks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b8a94753ff8..4e34709075f 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -30,6 +30,9 @@ jobs: # Checkout current git repository - name: Checkout uses: actions/checkout@v4.1.1 + with: + # fetch all history so that setuptools-scm works + fetch-depth: 0 # Install Micromamba with conda-forge dependencies - name: Setup Micromamba From bf5499c96198dbd9cadb94b076eab1f1979c7786 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 20:02:33 +1300 Subject: [PATCH 03/39] List installed packages after make install step To debug why import pygmt doesn't work. --- .github/workflows/benchmarks.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 4e34709075f..37b10a785a4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -61,14 +61,14 @@ jobs: run: | python -m pip install pytest-codspeed - # Show installed pkg information for postmortem diagnostic - - name: List installed packages - run: micromamba list - # Install the package that we want to test - name: Install the package run: make install + # Show installed pkg information for postmortem diagnostic + - name: List installed packages + run: micromamba list + # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 From fde104800d4ff495ba0f03241949f891195eabe8 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 20:14:07 +1300 Subject: [PATCH 04/39] Try bash -el -c which python Might need to launch into the correct shell first. Also running pip list to double check if dependencies are installed ok. --- .github/workflows/benchmarks.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 37b10a785a4..6043c238ba7 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -67,10 +67,14 @@ jobs: # Show installed pkg information for postmortem diagnostic - name: List installed packages - run: micromamba list + run: | + micromamba list + pip list # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: - run: make test PYTEST_EXTRA="-r P --codspeed" + run: | + bash -el -c which python + make test PYTEST_EXTRA="-r P --codspeed" From f39abfb683bccdb8f4ce5fb8dd4b8e12aa004041 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 20:40:15 +1300 Subject: [PATCH 05/39] Try using mostly PyPI packages, with GMT from conda-forge Seeing if it's possible to avoid using conda shell. --- .github/workflows/benchmarks.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 6043c238ba7..94bde3755fe 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -48,18 +48,12 @@ jobs: create-args: >- python=3.12 gmt=6.4.0 - numpy=${{ matrix.numpy-version }} - pandas - xarray - netCDF4 - packaging - pytest - pytest-benchmark # Install dependencies from PyPI - name: Install dependencies run: | - python -m pip install pytest-codspeed + python -m pip install numpy pandas xarray netCDF4 packaging \ + pytest pytest-benchmark pytest-codspeed # Install the package that we want to test - name: Install the package @@ -70,11 +64,15 @@ jobs: run: | micromamba list pip list + which gmt + echo ${{ github.workspace }} # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: run: | - bash -el -c which python + python -m pip list make test PYTEST_EXTRA="-r P --codspeed" + env: + GMT_LIBRARY_PATH: ${{ github.workspace }}/micromamba/envs/pygmt/lib/ From 6eddb0bdebea2ef695135dfbf3792f943b7ee90d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 20:49:20 +1300 Subject: [PATCH 06/39] Just install pygmt and dependencies in the benchmark step Do everything in the same shell, but point to the GMT installation in /home/runner/micromamba/envs/pygmt/lib/ --- .github/workflows/benchmarks.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 94bde3755fe..38a84b24859 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -49,21 +49,10 @@ jobs: python=3.12 gmt=6.4.0 - # Install dependencies from PyPI - - name: Install dependencies - run: | - python -m pip install numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark pytest-codspeed - - # Install the package that we want to test - - name: Install the package - run: make install - # Show installed pkg information for postmortem diagnostic - name: List installed packages run: | micromamba list - pip list which gmt echo ${{ github.workspace }} @@ -72,7 +61,9 @@ jobs: uses: CodSpeedHQ/action@v2.0.2 with: run: | - python -m pip list + python -m pip install numpy pandas xarray netCDF4 packaging \ + pytest pytest-benchmark pytest-codspeed + make install make test PYTEST_EXTRA="-r P --codspeed" env: - GMT_LIBRARY_PATH: ${{ github.workspace }}/micromamba/envs/pygmt/lib/ + GMT_LIBRARY_PATH: /home/runner/micromamba/envs/pygmt/lib/ From 7d431b4de0c3da5bc83f29d236fbc870c4846d03 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 20:57:38 +1300 Subject: [PATCH 07/39] Install setuptools Try to prevent `ERROR: Project file:///home/runner/work/pygmt/pygmt has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660`. --- .github/workflows/benchmarks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 38a84b24859..ccfb8e20261 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -62,7 +62,9 @@ jobs: with: run: | python -m pip install numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark pytest-codspeed + pytest pytest-benchmark pytest-codspeed \ + setuptools + python -m pip list make install make test PYTEST_EXTRA="-r P --codspeed" env: From b527c9d54aaeab599684748950bd017c81c5b213 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 21:01:45 +1300 Subject: [PATCH 08/39] Upgrade version of pip and setuptools Need newer setuptools greater than 64. --- .github/workflows/benchmarks.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index ccfb8e20261..cc0f1df7d01 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -51,19 +51,17 @@ jobs: # Show installed pkg information for postmortem diagnostic - name: List installed packages - run: | - micromamba list - which gmt - echo ${{ github.workspace }} + run: micromamba list # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: run: | - python -m pip install numpy pandas xarray netCDF4 packaging \ + python -m pip install -U pip + python -m pip install -U numpy pandas xarray netCDF4 packaging \ pytest pytest-benchmark pytest-codspeed \ - setuptools + 'setuptools>64' python -m pip list make install make test PYTEST_EXTRA="-r P --codspeed" From 31a7567b23fd15d8b563f3f495e34ba23e515861 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 21:06:11 +1300 Subject: [PATCH 09/39] Try plain setuptools Action might not like the single quotes. --- .github/workflows/benchmarks.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index cc0f1df7d01..2161a5e7452 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -58,10 +58,9 @@ jobs: uses: CodSpeedHQ/action@v2.0.2 with: run: | - python -m pip install -U pip python -m pip install -U numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark pytest-codspeed \ - 'setuptools>64' + pip pytest pytest-benchmark pytest-codspeed \ + setuptools python -m pip list make install make test PYTEST_EXTRA="-r P --codspeed" From 5ca4565c95635117ef324dd0b9d8d459daece24f Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 21:21:19 +1300 Subject: [PATCH 10/39] Try to find GMT install path Should be /home/runner/micromamba/envs/pygmt/lib/, but don't know what's happening in the CodSpeedHQ/action shell. --- .github/workflows/benchmarks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 2161a5e7452..7109dfb69be 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -63,6 +63,7 @@ jobs: setuptools python -m pip list make install + which gmt make test PYTEST_EXTRA="-r P --codspeed" env: GMT_LIBRARY_PATH: /home/runner/micromamba/envs/pygmt/lib/ From 1ad03e94261deb646438e571f91704df75cee21b Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 21:34:57 +1300 Subject: [PATCH 11/39] Try installing GMT with bundled conda Maybe best to use the bundled conda with GitHub Actions? --- .github/workflows/benchmarks.yml | 33 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 7109dfb69be..52e80af1ac4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -34,26 +34,22 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 - # Install Micromamba with conda-forge dependencies - - name: Setup Micromamba - uses: mamba-org/setup-micromamba@v1.7.3 + # Install Miniconda with conda-forge dependencies + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3.0.1 with: - environment-name: pygmt - condarc: | - channels: - - conda-forge - - nodefaults - cache-downloads: true - cache-environment: true - create-args: >- - python=3.12 - gmt=6.4.0 + activate-environment: pygmt + python-version: '3.12' + channels: conda-forge,nodefaults + channel-priority: strict - # Show installed pkg information for postmortem diagnostic - - name: List installed packages - run: micromamba list + # Install GMT from conda-forge + - name: Install GMT + run: | + conda install --solver=libmamba gmt=6.4.0 + which gmt - # Run the benchmark tests + # Install dependencies from PyPI and run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: @@ -63,7 +59,6 @@ jobs: setuptools python -m pip list make install - which gmt make test PYTEST_EXTRA="-r P --codspeed" env: - GMT_LIBRARY_PATH: /home/runner/micromamba/envs/pygmt/lib/ + GMT_LIBRARY_PATH: /home/runner/miniconda/envs/pygmt/lib/ From 1b67ca7b482d030bbad0017cf229278445ac46d5 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 23 Dec 2023 21:37:30 +1300 Subject: [PATCH 12/39] Update GMT_LIBRARY_PATH to /usr/share/miniconda/envs/pygmt/lib New place where GMT is installed by miniconda. --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 52e80af1ac4..60a568316e4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -61,4 +61,4 @@ jobs: make install make test PYTEST_EXTRA="-r P --codspeed" env: - GMT_LIBRARY_PATH: /home/runner/miniconda/envs/pygmt/lib/ + GMT_LIBRARY_PATH: /usr/share/miniconda/envs/pygmt/lib/ From 6d2fb3266f50c1dcd69283fc5a77529911471634 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:20:49 +1300 Subject: [PATCH 13/39] List contents of /usr/share/miniconda/envs/pygmt/lib/ See if libgmt.so is in this folder. --- .github/workflows/benchmarks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 60a568316e4..5e9258c96c4 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -54,6 +54,7 @@ jobs: uses: CodSpeedHQ/action@v2.0.2 with: run: | + ls -lh /usr/share/miniconda/envs/pygmt/lib/ python -m pip install -U numpy pandas xarray netCDF4 packaging \ pip pytest pytest-benchmark pytest-codspeed \ setuptools From 8bb16659fe792b8a38ceeeead3267e683553674e Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:30:41 +1300 Subject: [PATCH 14/39] Back to installing dependencies with conda instead of pip Trying to workaround `Error loading GMT shared library at '/usr/share/miniconda/envs/pygmt/lib/libgmt.so'. /lib/x86_64-linux-gnu/libcrypto.so.3: version `OPENSSL_3.2.0' not found (required by /usr/share/miniconda/envs/pygmt/lib/././libssl.so.3)` --- .github/workflows/benchmarks.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 5e9258c96c4..ed72049f1d9 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -43,11 +43,12 @@ jobs: channels: conda-forge,nodefaults channel-priority: strict - # Install GMT from conda-forge - - name: Install GMT + # Install GMT and dependencies from conda-forge + - name: Install dependencies run: | - conda install --solver=libmamba gmt=6.4.0 - which gmt + conda install --solver=libmamba gmt=6.4.0 \ + numpy pandas xarray netCDF4 packaging \ + pytest pytest-benchmark pytest-codspeed setuptools # Install dependencies from PyPI and run the benchmark tests - name: Run benchmarks @@ -55,10 +56,6 @@ jobs: with: run: | ls -lh /usr/share/miniconda/envs/pygmt/lib/ - python -m pip install -U numpy pandas xarray netCDF4 packaging \ - pip pytest pytest-benchmark pytest-codspeed \ - setuptools - python -m pip list make install make test PYTEST_EXTRA="-r P --codspeed" env: From 351f8f2370656ff0eeaae4974953ee9a479a7cc4 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:34:09 +1300 Subject: [PATCH 15/39] Still need to install pytest-codspeed from PyPI Missing conda-forge package for pytest-codspeed. --- .github/workflows/benchmarks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index ed72049f1d9..f8812655881 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -46,9 +46,12 @@ jobs: # Install GMT and dependencies from conda-forge - name: Install dependencies run: | + which conda + echo $CONDA conda install --solver=libmamba gmt=6.4.0 \ numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark pytest-codspeed setuptools + pytest pytest-benchmark setuptools + $CONDA/bin/python -m pip install pytest-codspeed # Install dependencies from PyPI and run the benchmark tests - name: Run benchmarks From e66497354fa7658c98d583b3859488513b761175 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:38:38 +1300 Subject: [PATCH 16/39] Activate base environment rather than pygmt environment --- .github/workflows/benchmarks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index f8812655881..97849d44bf0 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -38,7 +38,8 @@ jobs: - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v3.0.1 with: - activate-environment: pygmt + auto-activate-base: true + activate-environment: "" # base environment python-version: '3.12' channels: conda-forge,nodefaults channel-priority: strict From 992f914151001900952e93e0aeb6b078dd044f66 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:41:16 +1300 Subject: [PATCH 17/39] Just use default python from setup-miniconda Instead of setting Python 3.12 explicitly. --- .github/workflows/benchmarks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 97849d44bf0..04476fe1cc6 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -40,7 +40,6 @@ jobs: with: auto-activate-base: true activate-environment: "" # base environment - python-version: '3.12' channels: conda-forge,nodefaults channel-priority: strict From 2d38ecb4352b90223754549539df6d84063332dd Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:45:38 +1300 Subject: [PATCH 18/39] Install setuptools via PyPI and use GMT_LIBRARY_PATH from base env --- .github/workflows/benchmarks.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 04476fe1cc6..c41eb49d261 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -50,16 +50,16 @@ jobs: echo $CONDA conda install --solver=libmamba gmt=6.4.0 \ numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark setuptools - $CONDA/bin/python -m pip install pytest-codspeed + pytest pytest-benchmarks + $CONDA/bin/python -m pip install pytest-codspeed setuptools # Install dependencies from PyPI and run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: run: | - ls -lh /usr/share/miniconda/envs/pygmt/lib/ + ls -lh /usr/share/miniconda/lib/ make install make test PYTEST_EXTRA="-r P --codspeed" env: - GMT_LIBRARY_PATH: /usr/share/miniconda/envs/pygmt/lib/ + GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From 44533a54bc28e4286eed5ff94843a427f14ed9fc Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:48:10 +1300 Subject: [PATCH 19/39] Typo --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index c41eb49d261..aba804e8755 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -50,7 +50,7 @@ jobs: echo $CONDA conda install --solver=libmamba gmt=6.4.0 \ numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmarks + pytest pytest-benchmark $CONDA/bin/python -m pip install pytest-codspeed setuptools # Install dependencies from PyPI and run the benchmark tests From f0aba1a3bd07f2a0c08bd40a69460fd001c7eddc Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:52:14 +1300 Subject: [PATCH 20/39] Still need to upgrade setuptools version --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index aba804e8755..d47a4eb78d9 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -51,7 +51,7 @@ jobs: conda install --solver=libmamba gmt=6.4.0 \ numpy pandas xarray netCDF4 packaging \ pytest pytest-benchmark - $CONDA/bin/python -m pip install pytest-codspeed setuptools + $CONDA/bin/python -m pip install -U pytest-codspeed setuptools # Install dependencies from PyPI and run the benchmark tests - name: Run benchmarks From c5a8338d059689b871a79d99824a38f7d99f001d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 16:59:18 +1300 Subject: [PATCH 21/39] Try using conda's python rather than system python --- .github/workflows/benchmarks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index d47a4eb78d9..57f742d2034 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -59,7 +59,8 @@ jobs: with: run: | ls -lh /usr/share/miniconda/lib/ - make install + which python + $CONDA/bin/python -m pip install --no-deps -e . make test PYTEST_EXTRA="-r P --codspeed" env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From c4cef5caa3a8815fe67f85b659cdfc9a85105ca4 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:06:17 +1300 Subject: [PATCH 22/39] Run tests with conda python instead of system python Don't use `make test`, which seems to use the system python in `/usr/bin/python` rather than `/usr/share/miniconda/bin/python`. --- .github/workflows/benchmarks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 57f742d2034..f4da48a9c10 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -59,8 +59,8 @@ jobs: with: run: | ls -lh /usr/share/miniconda/lib/ - which python $CONDA/bin/python -m pip install --no-deps -e . - make test PYTEST_EXTRA="-r P --codspeed" + $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" + PYGMT_USE_EXTERNAL_DISPLAY="false" pytest -r P --codspeed env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From b91c1dff15c9128b4c559c92b56874639d3084b6 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:12:26 +1300 Subject: [PATCH 23/39] Actually use conda python to run pytest Also split the PyGMT build step into a separate step, now that we're confident all the packages are installed using conda's python/pip. --- .github/workflows/benchmarks.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index f4da48a9c10..b2a8455d14d 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -53,14 +53,16 @@ jobs: pytest pytest-benchmark $CONDA/bin/python -m pip install -U pytest-codspeed setuptools + # Install the package that we want to test + - name: Install the package + run: $CONDA/bin/python -m pip install --no-deps -e . + # Install dependencies from PyPI and run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: run: | - ls -lh /usr/share/miniconda/lib/ - $CONDA/bin/python -m pip install --no-deps -e . $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" - PYGMT_USE_EXTERNAL_DISPLAY="false" pytest -r P --codspeed + PYGMT_USE_EXTERNAL_DISPLAY="false" $CONDA/bin/python -m pytest -r P --codspeed env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From a566eb818501c109e332387ff9799d8f0243671b Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:16:56 +1300 Subject: [PATCH 24/39] Install pytest-mpl from conda-forge Also tidy up some stray bits --- .github/workflows/benchmarks.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b2a8455d14d..9dfd59b56ef 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -46,18 +46,16 @@ jobs: # Install GMT and dependencies from conda-forge - name: Install dependencies run: | - which conda - echo $CONDA conda install --solver=libmamba gmt=6.4.0 \ numpy pandas xarray netCDF4 packaging \ - pytest pytest-benchmark + pytest pytest-benchmark pytest-mpl $CONDA/bin/python -m pip install -U pytest-codspeed setuptools # Install the package that we want to test - name: Install the package run: $CONDA/bin/python -m pip install --no-deps -e . - # Install dependencies from PyPI and run the benchmark tests + # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: From 3df918ff093fab65a63b5151a533ff06dae822eb Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:27:15 +1300 Subject: [PATCH 25/39] Run pytest with --pyargs pygmt Try to avoid collecting tests in the examples/ folder. --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 9dfd59b56ef..c2c21686ec7 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -61,6 +61,6 @@ jobs: with: run: | $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" - PYGMT_USE_EXTERNAL_DISPLAY="false" $CONDA/bin/python -m pytest -r P --codspeed + PYGMT_USE_EXTERNAL_DISPLAY="false" $CONDA/bin/python -m pytest -r P --pyargs pygmt --codspeed env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From 4a0af5e259c202c017b4a8bb292cb70d5eef6248 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:46:57 +1300 Subject: [PATCH 26/39] Pin to Python 3.12 --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index c2c21686ec7..6d55b6cfebe 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -46,7 +46,7 @@ jobs: # Install GMT and dependencies from conda-forge - name: Install dependencies run: | - conda install --solver=libmamba gmt=6.4.0 \ + conda install --solver=libmamba gmt=6.4.0 python=3.12 \ numpy pandas xarray netCDF4 packaging \ pytest pytest-benchmark pytest-mpl $CONDA/bin/python -m pip install -U pytest-codspeed setuptools From cd6884aa254f1bb2357f7e04ebf05aa492c8548d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:52:39 +1300 Subject: [PATCH 27/39] Try using CodSpeedHQ/action@v2 instead of 2.0.2 --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 6d55b6cfebe..dccc91ab2ca 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -57,7 +57,7 @@ jobs: # Run the benchmark tests - name: Run benchmarks - uses: CodSpeedHQ/action@v2.0.2 + uses: CodSpeedHQ/action@v2 with: run: | $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" From 1b9316ff5b9a86ce00d362b5ced2fca873abbac2 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 24 Dec 2023 21:15:53 +1300 Subject: [PATCH 28/39] Add shield.io badge for CodSpeed --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 9c013253999..a56aee69c13 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,9 @@ PyGMT .. image:: https://codecov.io/gh/GenericMappingTools/pygmt/branch/main/graph/badge.svg?token=78Fu4EWstx :alt: Test coverage status :target: https://app.codecov.io/gh/GenericMappingTools/pygmt +.. image:: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json + :alt: CodSpeed Performance Benchmarks + :target: https://codspeed.io/GenericMappingTools/pygmt .. image:: https://img.shields.io/pypi/pyversions/pygmt.svg?style=flat-square :alt: Compatible Python versions. :target: https://pypi.python.org/pypi/pygmt From 37015d750d1b332e781bdb6659c7a14090cc4005 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:01:56 +1300 Subject: [PATCH 29/39] Set CODSPEED_TOKEN Co-authored-by: Dongdong Tian --- .github/workflows/benchmarks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index dccc91ab2ca..7363e521226 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -59,6 +59,7 @@ jobs: - name: Run benchmarks uses: CodSpeedHQ/action@v2 with: + token: ${{ secrets.CODSPEED_TOKEN }} run: | $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" PYGMT_USE_EXTERNAL_DISPLAY="false" $CONDA/bin/python -m pytest -r P --pyargs pygmt --codspeed From f11520675fc4bb1ac74d8ae1f38c9650b6f51dd0 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:10:14 +1300 Subject: [PATCH 30/39] Revert setup CODSPEED_TOKEN --- .github/workflows/benchmarks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 7363e521226..dccc91ab2ca 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -59,7 +59,6 @@ jobs: - name: Run benchmarks uses: CodSpeedHQ/action@v2 with: - token: ${{ secrets.CODSPEED_TOKEN }} run: | $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" PYGMT_USE_EXTERNAL_DISPLAY="false" $CONDA/bin/python -m pytest -r P --pyargs pygmt --codspeed From c92fcb27597d4a4a803de2c9fb1fe08d75491699 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:50:04 +1300 Subject: [PATCH 31/39] Document benchmarks.yml workflow in docs/maintenance.md --- doc/maintenance.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/maintenance.md b/doc/maintenance.md index cc861eba5b2..f0615c556dd 100644 --- a/doc/maintenance.md +++ b/doc/maintenance.md @@ -104,6 +104,8 @@ workflow files for more details. 12. `format-command.yml`: Format the codes using slash command 13. `dvc-diff.yml`: Report changes in test images 14. `slash-command-dispatch.yml`: Support slash commands in pull requests +15. `benchmarks.yml`: Benchmarks the execution speed of tests to track performance of PyGMT functions + ## Continuous Documentation From c8d19656a4d5396b44ab48103eab2bbb52f02b91 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:52:26 +1300 Subject: [PATCH 32/39] Run benchmarks when a release is published --- .github/workflows/benchmarks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index dccc91ab2ca..85364bd2e69 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -14,6 +14,9 @@ on: # `workflow_dispatch` allows CodSpeed to trigger backtest # performance analysis in order to generate initial data. workflow_dispatch: + release: + types: + - published concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 7bf09b9f9c7bf20ebace952542ed8e339bd3986f Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:53:40 +1300 Subject: [PATCH 33/39] Add benchmarks.yml to bump_gmt_checklist.md --- .github/ISSUE_TEMPLATE/bump_gmt_checklist.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bump_gmt_checklist.md b/.github/ISSUE_TEMPLATE/bump_gmt_checklist.md index 014c093a886..146d9f42c04 100644 --- a/.github/ISSUE_TEMPLATE/bump_gmt_checklist.md +++ b/.github/ISSUE_TEMPLATE/bump_gmt_checklist.md @@ -19,6 +19,7 @@ assignees: '' - [ ] Bump the GMT version in CI (1 PR) - [ ] Update `environment.yml` - [ ] Update `ci/requirements/docs.yml` + - [ ] Update `.github/workflows/benchmarks.yml` - [ ] Update `.github/workflows/cache_data.yaml` - [ ] Update `.github/workflows/ci_doctests.yaml` - [ ] Update `.github/workflows/ci_docs.yml` From 31eb3da573c85c35d4429e5debd3f48c1714c23d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 11:55:14 +1300 Subject: [PATCH 34/39] Pin to CodSpeedHQ/action@v2.0.2 Co-Authored-By: Dongdong Tian --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 85364bd2e69..35f8e125413 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -60,7 +60,7 @@ jobs: # Run the benchmark tests - name: Run benchmarks - uses: CodSpeedHQ/action@v2 + uses: CodSpeedHQ/action@v2.0.2 with: run: | $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" From 9c04e3fd75d4088cfca3436897e430a07178eada Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 12:45:11 +1300 Subject: [PATCH 35/39] Only benchmark test_basemap for now Remove markers for test_blockmean_input_dataframe and test_grd2xyz. --- pygmt/tests/test_basemap.py | 1 + pygmt/tests/test_blockm.py | 1 - pygmt/tests/test_grd2xyz.py | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/tests/test_basemap.py b/pygmt/tests/test_basemap.py index a78d909cd40..69f6bacf8a5 100644 --- a/pygmt/tests/test_basemap.py +++ b/pygmt/tests/test_basemap.py @@ -5,6 +5,7 @@ from pygmt import Figure +@pytest.mark.benchmark @pytest.mark.mpl_image_compare def test_basemap(): """ diff --git a/pygmt/tests/test_blockm.py b/pygmt/tests/test_blockm.py index 9b4acb95cd6..c75de7673c0 100644 --- a/pygmt/tests/test_blockm.py +++ b/pygmt/tests/test_blockm.py @@ -22,7 +22,6 @@ def fixture_dataframe(): return load_sample_data(name="bathymetry") -@pytest.mark.benchmark def test_blockmean_input_dataframe(dataframe): """ Run blockmean by passing in a pandas.DataFrame as input. diff --git a/pygmt/tests/test_grd2xyz.py b/pygmt/tests/test_grd2xyz.py index 2cd555d6d5f..d53993388c2 100644 --- a/pygmt/tests/test_grd2xyz.py +++ b/pygmt/tests/test_grd2xyz.py @@ -20,7 +20,6 @@ def fixture_grid(): return load_static_earth_relief() -@pytest.mark.benchmark def test_grd2xyz(grid): """ Make sure grd2xyz works as expected. From f45b727ce0c389d022398314a84464b4977cb330 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 12:55:01 +1300 Subject: [PATCH 36/39] Preprend $CONDA/bin to $GITHUB_PATH See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path and https://github.com/actions/starter-workflows/blob/c31fe3d5d44d7cb4c912f4c3213f7b4610f13ea2/ci/python-package-conda.yml#L19-L20 --- .github/workflows/benchmarks.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 35f8e125413..fdbb16252c3 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -49,21 +49,24 @@ jobs: # Install GMT and dependencies from conda-forge - name: Install dependencies run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + # Preprend $CONDA/bin to $PATH so that conda's python is used over system python + echo $CONDA/bin >> $GITHUB_PATH conda install --solver=libmamba gmt=6.4.0 python=3.12 \ numpy pandas xarray netCDF4 packaging \ pytest pytest-benchmark pytest-mpl - $CONDA/bin/python -m pip install -U pytest-codspeed setuptools + python -m pip install -U pytest-codspeed setuptools # Install the package that we want to test - name: Install the package - run: $CONDA/bin/python -m pip install --no-deps -e . + run: python -m pip install --no-deps -e . # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: run: | - $CONDA/bin/python -c "import pygmt; pygmt.show_versions()" - PYGMT_USE_EXTERNAL_DISPLAY="false" $CONDA/bin/python -m pytest -r P --pyargs pygmt --codspeed + python -c "import pygmt; pygmt.show_versions()" + PYGMT_USE_EXTERNAL_DISPLAY="false" python -m pytest -r P --pyargs pygmt --codspeed env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From 514564927753b6f6e4aed6e2a38643bc7fbdd678 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 13:00:06 +1300 Subject: [PATCH 37/39] Use make commands instead of calling $CONDA/bin/python The default Python used now should be the conda one instead of the system one. --- .github/workflows/benchmarks.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index fdbb16252c3..dfb324d240c 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -59,14 +59,12 @@ jobs: # Install the package that we want to test - name: Install the package - run: python -m pip install --no-deps -e . + run: make install # Run the benchmark tests - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: - run: | - python -c "import pygmt; pygmt.show_versions()" - PYGMT_USE_EXTERNAL_DISPLAY="false" python -m pytest -r P --pyargs pygmt --codspeed + run: make test PYTEST_EXTRA="-r P --codspeed" env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From 0a254f88748f2e1a6b6cc1e49612830eb6408e32 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 13:12:15 +1300 Subject: [PATCH 38/39] Revert back to using python -m pytest Default `make test` requires the use of pytest-cov and pytest-doctestplus --- .github/workflows/benchmarks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index dfb324d240c..c9b93da6c54 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -65,6 +65,8 @@ jobs: - name: Run benchmarks uses: CodSpeedHQ/action@v2.0.2 with: - run: make test PYTEST_EXTRA="-r P --codspeed" + run: | + python -c "import pygmt; pygmt.show_versions()" + PYGMT_USE_EXTERNAL_DISPLAY="false" python -m pytest -r P --pyargs pygmt --codspeed env: GMT_LIBRARY_PATH: /usr/share/miniconda/lib/ From dedfa7af7250762f473a81928a609b04198d11b1 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 25 Dec 2023 18:55:20 +1300 Subject: [PATCH 39/39] Only run when non-test PyGMT source files and benchmarks.yml is modified Trigger the benchmark run when files in `pygmt/clib`, `pygmt/datasets`, `pygmt/helpers`, `pygmt/src` and `pygmt/*.py` are modified (i.e. except `pygmt/tests/**`), and also when .github/workflows/benchmarks.yml is modified. --- .github/workflows/benchmarks.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index c9b93da6c54..2b562e9aa46 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -9,8 +9,15 @@ on: # Run on pushes to the main branch push: branches: [ main ] - # Uncomment the 'pull_request' line below to trigger the workflow in PR + paths: + - 'pygmt/**/*.py' + - '!pygmt/tests/**' + - '.github/workflows/benchmarks.yml' pull_request: + paths: + - 'pygmt/**/*.py' + - '!pygmt/tests/**' + - '.github/workflows/benchmarks.yml' # `workflow_dispatch` allows CodSpeed to trigger backtest # performance analysis in order to generate initial data. workflow_dispatch: