From d762a0c5e5b9561dd92f74962a42e78ed534fc78 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Thu, 15 Aug 2024 19:08:05 +0200 Subject: [PATCH] re-enable windows --- compliance_checker/protocols/zarr.py | 15 ++++++++++----- compliance_checker/suite.py | 7 +------ compliance_checker/tests/test_cli.py | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) 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 66ff12dc..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,11 +892,7 @@ 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(ds_str) + return Dataset(zarr.as_zarr(ds_str)) if netcdf.is_netcdf(ds_str): return Dataset(ds_str) diff --git a/compliance_checker/tests/test_cli.py b/compliance_checker/tests/test_cli.py index 19bd9b16..b77b565d 100644 --- a/compliance_checker/tests/test_cli.py +++ b/compliance_checker/tests/test_cli.py @@ -246,12 +246,12 @@ def _check_libnetcdf_version(): "zarr_url", [ f"{(datadir / 'trajectory.zarr').as_uri()}#mode=nczarr,file", - # str(datadir / "zip.zarr"), + str(datadir / "zip.zarr"), # "s3://hrrrzarr/sfc/20210408/20210408_10z_anl.zarr#mode=nczarr,s3" ], ids=[ "local_file", - # "zip_file", + "zip_file", # TODO uncomment once S3 support is working. # "s3_url", ],