diff --git a/compliance_checker/protocols/zarr.py b/compliance_checker/protocols/zarr.py index f111624c..517ce9e1 100644 --- a/compliance_checker/protocols/zarr.py +++ b/compliance_checker/protocols/zarr.py @@ -1,3 +1,4 @@ +import platform import zipfile from pathlib import Path from urllib.parse import urlparse @@ -6,7 +7,11 @@ from compliance_checker.protocols import netcdf -# + +def _fix_windows_slashes(zarr_url): + if platform.system() == "Windows": + zarr_url = zarr_url.replace("///", "//") + return zarr_url def is_zarr(url): @@ -55,10 +60,9 @@ def as_zarr(url): pr = urlparse(str(url)) if "mode=nczarr" in pr.fragment: - if pr.netloc: - return str(url) # already valid nczarr url - elif pr.scheme == "file": - return str(url) # already valid nczarr url + if pr.netloc or pr.scheme == "file": + url = _fix_windows_slashes(url) + return url zarr_url = Path( url2pathname(pr.path), @@ -78,4 +82,5 @@ def as_zarr(url): url_base = url if mode == "s3" else zarr_url.as_uri() zarr_url = f"{url_base}#mode=nczarr,{mode}" + zarr_url = _fix_windows_slashes(zarr_url) return zarr_url diff --git a/compliance_checker/suite.py b/compliance_checker/suite.py index 6b534f5f..6a4281e2 100644 --- a/compliance_checker/suite.py +++ b/compliance_checker/suite.py @@ -6,7 +6,6 @@ import inspect import itertools import os -import platform import re import subprocess import sys @@ -893,10 +892,6 @@ def load_local_dataset(self, ds_str): ds_str = self.generate_dataset(ds_str) if zarr.is_zarr(ds_str): - if platform.system() != "Linux": - print( - f"WARNING: {platform.system()} OS detected. NCZarr is not officially supported for your OS as of when this API was written. Your mileage may vary.", - ) return Dataset(zarr.as_zarr(ds_str)) if netcdf.is_netcdf(ds_str): diff --git a/compliance_checker/tests/test_cli.py b/compliance_checker/tests/test_cli.py index 6452eff4..b77b565d 100644 --- a/compliance_checker/tests/test_cli.py +++ b/compliance_checker/tests/test_cli.py @@ -20,8 +20,10 @@ from .conftest import datadir, static_files -if platform.system() == "Windows": - ncconfig = ["bash", f"{os.environ['CONDA_PREFIX']}\\Library\\bin\\nc-config"] +on_windows = platform.system() == "Windows" + +if on_windows: + ncconfig = ["sh", f"{os.environ['CONDA_PREFIX']}\\Library\\bin\\nc-config"] else: ncconfig = ["nc-config"] @@ -236,18 +238,9 @@ def _check_libnetcdf_version(): < 8.0 ) - # TODO uncomment the third parameter once S3 support is working - @pytest.mark.skipif( - _check_libnetcdf_version(), - reason="NCZarr support was not available until netCDF version 4.8.0. Please upgrade to the latest libnetcdf version to test this functionality", - ) @pytest.mark.skipif( subprocess.check_output(ncconfig + ["--has-nczarr"]) != b"yes\n", - reason="NCZarr is not officially supported for your OS as of when this API was written", - ) - @pytest.mark.skipif( - subprocess.check_output(["nc-config", "--has-nczarr"]) != b"yes\n", - reason="NCZarr support was not built with this netCDF version", + reason="NCZarr is not available.", ) @pytest.mark.parametrize( "zarr_url", @@ -256,7 +249,12 @@ def _check_libnetcdf_version(): str(datadir / "zip.zarr"), # "s3://hrrrzarr/sfc/20210408/20210408_10z_anl.zarr#mode=nczarr,s3" ], - ids=["local_file", "zip_file"], # ,'s3_url' + ids=[ + "local_file", + "zip_file", + # TODO uncomment once S3 support is working. + # "s3_url", + ], ) def test_nczarr_pass_through(self, zarr_url): """