Skip to content

Commit bdc1a3a

Browse files
TomNicholasclaude
andauthored
Mark lithops tests as flaky, run in separate CI job (#934)
* add empty release notes * Mark lithops tests as flaky and run them in a separate CI job Lithops tests intermittently fail with an ImportError due to lithops' module shipping mechanism producing incomplete copies of virtualizarr in subprocess workers. See https://github.com/zarr-developers/VirtualiZarr/issues/XXX - Add --run-flaky pytest option (matching xarray's approach) - Mark lithops tests with @pytest.mark.flaky so they're skipped by default - Add a separate flaky-tests CI job with continue-on-error: true Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 565ee88 commit bdc1a3a

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ jobs:
5959
fail_ci_if_error: false
6060
token: ${{ secrets.CODECOV_TOKEN }}
6161

62+
flaky:
63+
name: flaky-tests
64+
runs-on: ubuntu-latest
65+
continue-on-error: true
66+
defaults:
67+
run:
68+
shell: bash -l {0}
69+
steps:
70+
- uses: actions/checkout@v4
71+
- uses: prefix-dev/setup-pixi@v0.9.3
72+
with:
73+
pixi-version: v0.59.0
74+
environments: test-py311
75+
76+
- name: Running Flaky Tests
77+
run: |
78+
pixi run -e test-py311 run-flaky-tests
79+
6280
check-docs:
6381
name: check-docs
6482
runs-on: ubuntu-latest

conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def pytest_addoption(parser):
4040
action="store_true",
4141
help="runs tests requiring docker and minio",
4242
)
43+
parser.addoption(
44+
"--run-flaky",
45+
action="store_true",
46+
help="runs flaky tests",
47+
)
4348

4449

4550
def pytest_runtest_setup(item):
@@ -52,6 +57,8 @@ def pytest_runtest_setup(item):
5257
pytest.skip("set --run-minio-tests to run tests requiring docker and minio")
5358
if "slow" in item.keywords and not item.config.getoption("--run-slow-tests"):
5459
pytest.skip("set --run-slow-tests to run slow tests")
60+
if "flaky" in item.keywords and not item.config.getoption("--run-flaky"):
61+
pytest.skip("set --run-flaky to run flaky tests")
5562

5663

5764
def _xarray_subset():

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ run-tests-no-network = { cmd = "pytest -n auto --dist loadscope --verbose" }
206206
run-tests-cov = { cmd = "pytest -n auto --dist loadscope --run-network-tests --verbose --cov=virtualizarr --cov=term-missing" }
207207
run-tests-xml-cov = { cmd = "pytest -n auto --dist loadscope --run-network-tests --verbose --cov=virtualizarr --cov-report=xml" }
208208
run-tests-html-cov = { cmd = "pytest -n auto --dist loadscope --run-network-tests --verbose --cov=virtualizarr --cov-report=html" }
209+
run-flaky-tests = { cmd = "pytest -m flaky --run-flaky --run-network-tests --verbose" }
209210

210211
# Define which features and groups to include in different pixi (similar to conda) environments)
211212
[tool.pixi.environments]
@@ -331,11 +332,7 @@ addopts = ["--doctest-modules", "--ignore=examples"]
331332
timeout = 300
332333
asyncio_default_fixture_loop_scope = "session"
333334
markers = [
334-
# Although we may not use pytest.mark.flaky, some of our test modules import
335-
# from xarray.tests, and xarray.tests.__init__.py references pytest.mark.flaky.
336-
# Therefore, without the "flaky" marker below, during test execution, we see
337-
# this warning: "PytestUnknownMarkWarning: Unknown pytest.mark.flaky"
338-
"flaky: flaky tests",
335+
"flaky: flaky tests (skipped by default, run with '--run-flaky')",
339336
"network: marks test requiring internet (select with '--run-network-tests')",
340337
"slow: marks test as slow (select with '--run-slow-tests')",
341338
"minio: marks test requiring docker and minio (select with '--run-minio-tests')",

virtualizarr/tests/test_parallel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from virtualizarr.tests import requires_lithops
77

88

9+
@pytest.mark.flaky
910
@requires_lithops
1011
def test_lithops_executor_with_multiple_args():
1112
with LithopsEagerFunctionExecutor() as exec:
@@ -14,6 +15,7 @@ def test_lithops_executor_with_multiple_args():
1415
assert tuple(results) == (5, 7, 9)
1516

1617

18+
@pytest.mark.flaky
1719
@requires_lithops
1820
def test_lithops_executor_with_partial():
1921
from functools import partial

0 commit comments

Comments
 (0)