Skip to content

Commit

Permalink
Merge pull request #179 from mattjala/windows_int_fix
Browse files Browse the repository at this point in the history
Windows compatibility fixes
  • Loading branch information
mattjala authored Apr 29, 2024
2 parents ef07ddd + 73c3dda commit fffac0b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions 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 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

0 comments on commit fffac0b

Please sign in to comment.