Skip to content

Commit

Permalink
upload_assets: run random-subset filtering as late as possible
Browse files Browse the repository at this point in the history
Other selection/filter mechanisms (e.g. standard `-k`) should come before final sampling (typically just 1 sample)
  • Loading branch information
soxofaan committed Jul 26, 2024
1 parent 5dddfa9 commit 610315d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
mkdir tmp_path_root
pytest \
-vv \
--random-subset=1 \
-k max_ndvi_fail_intentionally \
--log-cli-level=INFO \
--html report/report.html --self-contained-html \
Expand Down
7 changes: 5 additions & 2 deletions qa/benchmarks/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,22 @@ def pytest_ignore_collect(collection_path, config):
return None


@pytest.hookimpl(trylast=True)
def pytest_collection_modifyitems(session, config, items):
"""
Pytest hook to filter/reorder collected test items.
"""

# Optionally, select a random subset of benchmarks to run.
# based on https://alexwlchan.net/til/2024/run-random-subset-of-tests-in-pytest/
# Note that with current pytest versions the collection/summary stats might be messed up,
# see https://github.com/pytest-dev/pytest/issues/12663
subset_size = config.getoption("--random-subset")
if subset_size >= 0:
_log.warning(
f"Selecting random subset of {subset_size} from {len(items)} benchmarks."
)
items[:] = random.sample(items, k=subset_size)
if subset_size < len(items):
items[:] = random.sample(items, k=subset_size)


def _get_client_credentials_env_var(url: str) -> str:
Expand Down

0 comments on commit 610315d

Please sign in to comment.