Skip to content

Commit

Permalink
Treat warnings as errors when running tests (#458)
Browse files Browse the repository at this point in the history
* Treat user warnings as errors when running tests

* Fix Modal deprecation (Stub is now App)

* Dask test workflow should use dask distributed
  • Loading branch information
tomwhite committed May 7, 2024
1 parent 52171c1 commit ff2f23a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dask-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install -e '.[test-dask]'
python -m pip install -e '.[test-dask-distributed]'
- name: Run tests
run: |
Expand Down
8 changes: 4 additions & 4 deletions cubed/runtime/executors/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

RUNTIME_MEMORY_MIB = 2000

stub = modal.Stub("cubed-stub")
app = modal.App("cubed-app")

requirements_file = os.getenv("CUBED_MODAL_REQUIREMENTS_FILE")

Expand Down Expand Up @@ -72,7 +72,7 @@ def check_runtime_memory(spec):
)


@stub.function(
@app.function(
image=aws_image,
secrets=[modal.Secret.from_name("my-aws-secret")],
memory=RUNTIME_MEMORY_MIB,
Expand All @@ -87,7 +87,7 @@ def run_remotely(input, func=None, config=None, name=None, compute_id=None):


# For GCP we need to use a class so we can set up credentials by hooking into the container lifecycle
@stub.cls(
@app.cls(
image=gcp_image,
secrets=[modal.Secret.from_name("my-googlecloud-secret")],
memory=RUNTIME_MEMORY_MIB,
Expand Down Expand Up @@ -205,7 +205,7 @@ async def async_execute_dag(
) -> None:
if spec is not None:
check_runtime_memory(spec)
async with stub.run():
async with app.run():
cloud = cloud or "aws"
if cloud == "aws":
app_function = run_remotely
Expand Down
10 changes: 5 additions & 5 deletions cubed/tests/runtime/test_modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tmp_path = "s3://cubed-unittest/map_unordered"


stub = modal.Stub("cubed-test-stub")
app = modal.App("cubed-test-app")

image = modal.Image.debian_slim().pip_install(
[
Expand All @@ -33,7 +33,7 @@
)


@stub.function(
@app.function(
image=image,
secrets=[modal.Secret.from_name("my-aws-secret")],
retries=2,
Expand All @@ -43,14 +43,14 @@ def deterministic_failure_modal(i, path=None, timing_map=None, *, name=None):
return deterministic_failure(path, timing_map, i, name=name)


@stub.function(
@app.function(
image=image, secrets=[modal.Secret.from_name("my-aws-secret")], timeout=10
)
def deterministic_failure_modal_no_retries(i, path=None, timing_map=None, *, name=None):
return deterministic_failure(path, timing_map, i, name=name)


@stub.function(
@app.function(
image=image,
secrets=[modal.Secret.from_name("my-aws-secret")],
retries=2,
Expand All @@ -64,7 +64,7 @@ def deterministic_failure_modal_long_timeout(

async def run_test(app_function, input, use_backups=False, batch_size=None, **kwargs):
outputs = set()
async with stub.run():
async with app.run():
async for output in map_unordered(
app_function,
input,
Expand Down
2 changes: 0 additions & 2 deletions cubed/tests/test_executor_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ def test_compute_arrays_in_parallel_modal(modal_executor, compute_arrays_in_para


def test_check_runtime_memory_dask(spec, executor):
pytest.importorskip("dask.distributed")
if executor.name != "dask":
pytest.skip(f"{executor.name} executor does not support check_runtime_memory")

Expand All @@ -228,7 +227,6 @@ def test_check_runtime_memory_dask(spec, executor):


def test_check_runtime_memory_dask_no_workers(spec, executor):
pytest.importorskip("dask.distributed")
if executor.name != "dask":
pytest.skip(f"{executor.name} executor does not support check_runtime_memory")

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ test-modal = [
homepage = "https://github.com/cubed-dev/cubed"
documentation = "https://tomwhite.github.io/cubed"
repository = "https://github.com/cubed-dev/cubed"

[tool.pytest.ini_options]
filterwarnings = [
"error::UserWarning",
]

0 comments on commit ff2f23a

Please sign in to comment.