Skip to content

Commit

Permalink
Add a --use-cubed option to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Aug 14, 2024
1 parent a635ab4 commit da8657e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
collect_ignore_glob = ["benchmarks/**", "sgkit/io/vcf/*.py", ".github/scripts/*.py"]


def pytest_addoption(parser):
parser.addoption(
"--use-cubed", action="store_true", default=False, help="run with cubed"
)


def use_cubed():
import dask
import xarray as xr

# set xarray to use cubed by default
xr.set_options(chunk_manager="cubed")

# ensure that dask compute raises if it is ever called
class AlwaysRaiseScheduler:
def __call__(self, dsk, keys, **kwargs):
raise RuntimeError("Dask 'compute' was called")

dask.config.set(scheduler=AlwaysRaiseScheduler())


def pytest_configure(config) -> None: # type: ignore
# Add "gpu" marker
config.addinivalue_line("markers", "gpu:Run tests that run on GPU")

if config.getoption("--use-cubed"):
use_cubed()

0 comments on commit da8657e

Please sign in to comment.