GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CI: Add pytest plugins pytest-xdist and pytest-rerunfailures by seisman · Pull Request #3193 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Apr 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Our "Tests" workflow sometimes fails due to a few crashed tests, especially on Windows and macOS. The crashes are likely caused by unfixed upstream bugs, and they cause the CI to fail immediately, so other tests are not executed at all, which is very annoying.

Inspired by this post (https://stackoverflow.com/a/32140354), we can use the pytest-xdist to let other tests continue even if one or more tests crash (https://pytest-xdist.readthedocs.io/en/stable/crash.html). The crashed tests are marked as failures.

In addition to pytest-xdist, we can also use the pytest-rerunfailures plugin, which can rerun failing tests multiple times. So, if a test crashes but passes when rerun, then the test should be good.

Initially, I thought we have to use -n 1 to run the tests using one process because PyGMT uses a single global session and can't be run parallel without import pygmt in each process (xref #217). However, it turns out -n auto works, which is unexpected. Here, -n auto means using as many processes as the number of cores (2 for Linux/Windows and 3 for macOS with the GitHub-hosted agents), which speed up the CI runs significantly.

Here is the comparison of the "Run tests" step of the latest runs of the main branch (https://github.com/GenericMappingTools/pygmt/actions/runs/8825374546) and this PR (https://github.com/GenericMappingTools/pygmt/actions/runs/8825127559):

Job Main Branch This PR
Linux Python 3.10 84 s 54 s
Linux Python 3.12 100 s 64 s
macOS Python 3.10 90 s 37 s
macOS Python 3.12 100 s 50 s
Windows Python 3.10 230 s 135 s
Windows Python 3.12 crash at 150 s 180 s

Looking at the detailed log in https://github.com/GenericMappingTools/pygmt/actions/runs/8825127559/job/24228863150, we can see that the test_tilemap_no_clip test crashed but passed in rerun, so the CI run still passes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman
seisman marked this pull request as ready for review April 23, 2024 10:36
@seisman
seisman force-pushed the pytest/xdist branch 3 times, most recently from d4cd959 to d451df7 Compare April 24, 2024 01:35
@seisman seisman mentioned this pull request Apr 24, 2024
Use unique earth_age tiles in test_dataset_to_strings_with_none_values #3200
Merged
seisman added 3 commits April 24, 2024 19:28
@seisman
Add pytest-xdist and pytest-rerunfailures to environment.yml
466bc0d
@seisman
Add pytest-xdist and pytest-rerunfailed to ci_tests.yaml
485f9f7
@seisman
Add option -n auto
04f273f
@seisman
seisman force-pushed the pytest/xdist branch from 2a15fb2 to 04f273f Compare April 24, 2024 11:29
@seisman
Add option --reruns 5
1a49f0d
@seisman seisman changed the title WIP: Use the pytest-xdist plugin WIP: Add pytest plugins pytest-xdist and pytest-rerunfailures Apr 25, 2024
@seisman
Merge branch 'main' into pytest/xdist
7d4ce18
@seisman seisman changed the title WIP: Add pytest plugins pytest-xdist and pytest-rerunfailures POC: Add pytest plugins pytest-xdist and pytest-rerunfailures Apr 25, 2024
@seisman seisman added maintenance Boring but important stuff for the core devs needs review This PR has higher priority and needs review. labels Apr 25, 2024
@seisman seisman added this to the 0.12.0 milestone Apr 25, 2024
@seisman

seisman commented Apr 25, 2024

Copy link
Copy Markdown
Member Author

Ping @GenericMappingTools/pygmt-maintainers for comments on adding two more pytest plugins. If agreed, then maybe we should also add them to other workflows, like:

  • .github/workflows/ci_tests_legacy.yaml
  • .github/workflows/ci_tests_dev.yaml
  • .github/workflows/ci_doctests.yaml
  • .github/workflows/benchmarks.yml
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

seisman added 2 commits April 28, 2024 15:13
@seisman
Merge branch 'main' into pytest/xdist
20f2e71
@seisman
Add pytest-xdist and pytest-rerunfailures to other workflows
e98b9a1
@seisman seisman added run/benchmark Trigger the benchmark workflow in PRs run/test-gmt-dev Trigger the GMT Dev Tests workflow in PR labels Apr 28, 2024
@seisman

seisman commented Apr 28, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Doesn't work well in the Benchmarks workflow (https://github.com/GenericMappingTools/pygmt/actions/runs/8866542049/job/24344321212).

Edit: Works after the patch PR #3241.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman removed the needs review This PR has higher priority and needs review. label Apr 28, 2024
@seisman seisman removed this from the 0.12.0 milestone Apr 28, 2024
seisman added 6 commits April 30, 2024 10:58
@seisman
Merge branch 'main' into pytest/xdist
bcc55c8
@seisman
Merge branch 'main' into pytest/xdist
943b68b
@seisman
Merge branch 'main' into pytest/xdist
6c023b2
@seisman
Merge branch 'main' into pytest/xdist
54a7c24
@seisman
Revert the changes in ci_doctests.yaml and ci_tests_legacy.yaml.
83f6d0c
@seisman
Debug benchmarks
0c6cc85
@codspeed

codspeed Bot commented May 10, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #3193 will improve performances by ×3.4

Comparing pytest/xdist (a2e85cd) with main (5787a34)

Summary

⚡ 5 improvements
✅ 94 untouched benchmarks

Benchmarks breakdown

Benchmark main pytest/xdist Change
⚡ test_contour_matrix[DataFrame] 274.5 ms 82.9 ms ×3.3
⚡ test_contour_matrix[Dataset] 287 ms 95.4 ms ×3
⚡ test_contour_matrix[array] 272.3 ms 80.6 ms ×3.4
⚡ test_grdlandmask_no_outgrid 763.8 ms 342.1 ms ×2.2
⚡ test_sph2grd_no_outgrid 2.3 s 1.6 s +46.54%
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

seisman
seisman commented May 11, 2024
View reviewed changes
Comment thread .github/workflows/benchmarks.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seisman
Update .github/workflows/benchmarks.yml
346e985
@seisman seisman mentioned this pull request May 11, 2024
CI: Set PROJ_LIB in the Benchmarks workflow to fix the proj_create_from_database error #3241
Merged
@seisman seisman added this to the 0.13.0 milestone May 11, 2024
@seisman
Merge branch 'main' into pytest/xdist
b9b94e9
@seisman

seisman commented May 11, 2024

Copy link
Copy Markdown
Member Author

The two pytest plugins are only installed to the "Benchmarks", "Tests" and "Dev Tests" workflows, because we only care about the speed of these three workflows.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman
Merge branch 'main' into pytest/xdist
1ecec65
@seisman seisman changed the title POC: Add pytest plugins pytest-xdist and pytest-rerunfailures CI: Add pytest plugins pytest-xdist and pytest-rerunfailures May 13, 2024
@seisman seisman added the needs review This PR has higher priority and needs review. label May 13, 2024
seisman added 3 commits May 15, 2024 08:14
@seisman
Merge branch 'main' into pytest/xdist
fd36c6a
@seisman
Merge branch 'main' into pytest/xdist
e4e2ab9
@seisman
Merge branch 'main' into pytest/xdist
a2e85cd
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels May 18, 2024
@seisman
seisman requested a review from a team May 18, 2024 02:57
@seisman
seisman merged commit 861f454 into main May 19, 2024
@seisman
seisman deleted the pytest/xdist branch May 19, 2024 01:40
@seisman seisman removed final review call This PR requires final review and approval from a second reviewer run/benchmark Trigger the benchmark workflow in PRs run/test-gmt-dev Trigger the GMT Dev Tests workflow in PR labels May 19, 2024
@seisman seisman mentioned this pull request May 22, 2024
CI: Remove pytest-xdist and pytest-rerunfailures options from addopts and only add them in CI jobs #3267
Merged
@seisman seisman mentioned this pull request Jul 7, 2024
CI: Remove the pytest-xdist and pytest-rerunfailures plugins from the Benchmarks workflow #3314
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

maintenance Boring but important stuff for the core devs

Projects

None yet

Milestone

0.13.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@seisman
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.