Skip to content

Commit

Permalink
re-enable windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Aug 15, 2024
1 parent 3422fcf commit 61d9cc7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
14 changes: 9 additions & 5 deletions compliance_checker/protocols/zarr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import zipfile
from pathlib import Path
from urllib.parse import urlparse
Expand All @@ -6,7 +7,10 @@

from compliance_checker.protocols import netcdf

#

def _fix_windows_slashes(zarr_url):
if platform.system() == "Windows":
return zarr_url.replace("///", "//")

Check warning on line 13 in compliance_checker/protocols/zarr.py

View check run for this annotation

Codecov / codecov/patch

compliance_checker/protocols/zarr.py#L13

Added line #L13 was not covered by tests


def is_zarr(url):
Expand Down Expand Up @@ -55,10 +59,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":
zarr_url = _fix_windows_slashes(url)
return zarr_url

zarr_url = Path(
url2pathname(pr.path),
Expand All @@ -78,4 +81,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
7 changes: 1 addition & 6 deletions compliance_checker/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import inspect
import itertools
import os
import platform
import re
import subprocess
import sys
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions compliance_checker/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down

0 comments on commit 61d9cc7

Please sign in to comment.