Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make test optional when adls is not installed #110

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Keep it human-readable, your future self will thank you!

## [Unreleased](https://github.com/ecmwf/anemoi-datasets/compare/0.5.8...HEAD)

### Changed
- make test optional when adls is not installed Pull request #110

## [0.5.8](https://github.com/ecmwf/anemoi-datasets/compare/0.5.7...0.5.8) - 2024-10-26

### Changed
Expand Down
20 changes: 20 additions & 0 deletions tests/create/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import hashlib
import json
import os
import sys
from functools import wraps
from unittest.mock import patch

Expand All @@ -37,6 +38,24 @@
assert NAMES, "No yaml files found in " + HERE


def is_ubuntu():
if os.path.isfile("/etc/os-release"):
with open("/etc/os-release") as f:
return "Ubuntu" in f.read()
return False


def is_darwin():
if os.path.isfile("/etc/os-release"):
with open("/etc/os-release") as f:
return "Darwin" in f.read()
return False


# run extensive tests only on Ubuntu and Darwin, and not on Python 3.9 and 3.11
extensive_tests = (sys.version_info[:2] not in [(3, 9), (3, 11)]) and (is_ubuntu() or is_darwin())


def mockup_from_source(func):
@wraps(func)
def wrapper(*args, **kwargs):
Expand Down Expand Up @@ -233,6 +252,7 @@ def compare(self):


@pytest.mark.parametrize("name", NAMES)
@pytest.mark.skipif(not extensive_tests, reason="Skipping to run the test faster")
@mockup_from_source
def test_run(name):
config = os.path.join(HERE, name + ".yaml")
Expand Down
9 changes: 9 additions & 0 deletions tests/xarray/test_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
# nor does it submit to any jurisdiction.


import pytest
import xarray as xr

from anemoi.datasets.create.functions.sources.xarray import XarrayFieldList
from anemoi.datasets.data.stores import name_to_zarr_store
from anemoi.datasets.testing import assert_field_list

try:
import adlfs # noqa: F401

HAS_ADLS = True
except ImportError:
HAS_ADLS = False


def test_arco_era5_1():

Expand Down Expand Up @@ -118,6 +126,7 @@ def test_noaa_replay():
)


@pytest.mark.skipif(not HAS_ADLS, reason="package adlfs not installed")
def test_planetary_computer_conus404():
url = "https://planetarycomputer.microsoft.com/api/stac/v1/collections/conus404"
ds = xr.open_zarr(**name_to_zarr_store(url))
Expand Down
Loading