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

Windows compatibility fixes #179

Merged
merged 4 commits into from
Apr 29, 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
8 changes: 7 additions & 1 deletion h5pyd/_hl/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import time
import json
import pathlib

from .objectid import GroupID
from .group import Group
Expand Down Expand Up @@ -203,6 +204,11 @@ def __init__(
if not domain:
raise IOError(400, "no domain provided")

domain_path = pathlib.PurePath(domain)
if isinstance(domain_path, pathlib.PureWindowsPath):
# Standardize path root to POSIX-style path
domain = '/' + '/'.join(domain_path.parts[1:])

if domain[0] != "/":
raise IOError(400, "relative paths are not valid")

Expand All @@ -215,7 +221,7 @@ def __init__(
# remove the trailing slash on endpoint if it exists
if endpoint.endswith('/'):
endpoint = endpoint.strip('/')

if username is None:
if "H5SERV_USERNAME" in os.environ:
username = os.environ["H5SERV_USERNAME"]
Expand Down
5 changes: 4 additions & 1 deletion h5pyd/_hl/h5type.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def special_dtype(**kwds):
name, val = kwds.popitem()

if name == 'vlen':

return np.dtype('O', metadata={'vlen': val})

if name == 'enum':
Expand Down Expand Up @@ -441,6 +440,10 @@ def getTypeItem(dt):
type_info['length'] = 'H5T_VARIABLE'
type_info['charSet'] = 'H5T_CSET_UTF8'
type_info['strPad'] = 'H5T_STR_NULLTERM'
elif vlen_check == np.int32:
type_info['class'] = 'H5T_VLEN'
type_info['size'] = 'H5T_VARIABLE'
type_info['base'] = 'H5T_STD_I32'
elif vlen_check in (int, np.int64):
type_info['class'] = 'H5T_VLEN'
type_info['size'] = 'H5T_VARIABLE'
Expand Down
2 changes: 2 additions & 0 deletions h5pyd/_hl/httpconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,9 @@ def PUT(self, req, body=None, format="json", params=None, headers=None):
# binary write
data = body
else:
headers["Content-Type"] = "application/json"
data = json.dumps(body)

self.log.info("PUT: {} format: {} [{} bytes]".format(req, format, len(data)))

try:
Expand Down
16 changes: 13 additions & 3 deletions test/apps/load_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import sys
import config
import h5pyd

from platform import system
#
# Main
#
Expand Down Expand Up @@ -60,9 +60,19 @@
# wget from S3
http_path = test_file_http_path + filename
print("downloading:", http_path)
rc = os.system(f"wget -q https://s3.amazonaws.com/hdfgroup/data/hdf5test/{filename} -P {data_dir}")

if system() == "Windows":
get_cmd = f"curl.exe -o {filename}\
https://s3.amazonaws.com/hdfgroup/data/hdf5test/{filename}\
--create-dirs --output-dir {data_dir}"
else:
get_cmd = f"wget -q\
https://s3.amazonaws.com/hdfgroup/data/hdf5test/{filename}\
-P {data_dir}"

rc = os.system(f"{get_cmd}")
if rc != 0:
sys.exit("Failed to retreive test data file")
sys.exit(f"Failed to retreive test data file with error code {rc}")
# run hsload for each file
print(f"running hsload for {hdf5_path} to {test_folder}")
rc = os.system(f"python ../../h5pyd/_apps/hsload.py {hdf5_path} {test_folder}")
Expand Down