Skip to content

Commit 3d9003c

Browse files
committed
hsds writer updates
1 parent 9773e2c commit 3d9003c

File tree

12 files changed

+263
-110
lines changed

12 files changed

+263
-110
lines changed

src/h5json/apps/h5tohs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
from h5json.hsdsstore.hsds_writer import HSDSWriter
1818
from h5json.h5pystore.h5py_reader import H5pyReader
1919

20+
2021
def usage():
2122
print(f"usage: {sys.argv[0]} [-h] [--nodata] <hdf5_file> <hsds_domain>")
2223
sys.exit(0)
2324

25+
2426
def main():
2527
no_data = False
2628
filename = None
@@ -59,5 +61,6 @@ def main():
5961

6062
db.close() # close will trigger write to HSDS
6163

64+
6265
if __name__ == "__main__":
6366
main()

src/h5json/h5pystore/h5py_reader.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ def open(self):
177177
self._id_map[self._root_id] = f
178178
addr = h5py.h5o.get_info(f.id).addr
179179
self._addr_map[addr] = self._root_id
180-
#f.visititems(self.visit)
181-
182-
print("h5py_reader keys:", list(self.db.db.keys()))
183180

184181
return self._root_id
185182

@@ -268,7 +265,6 @@ def getAttribute(self, obj_id, name, include_data=True):
268265
else:
269266
pass # no data
270267

271-
272268
item['created'] = time.time() # TBD: get attribute creation time from h5py?
273269
return item
274270

@@ -314,7 +310,7 @@ def _getLink(self, parent, link_name):
314310
item["id"] = None
315311
else:
316312
item["id"] = self._addr_map[addr]
317-
313+
318314
item['created'] = time.time() # TBD: get the link creation time from h5py?
319315

320316
return item
@@ -435,11 +431,11 @@ def _getHDF5DatasetCreationProperties(self, dset, type_class):
435431
return creationProps
436432

437433
def _getDataset(self, dset):
434+
""" return json representation of the given dataset """
435+
438436
self.log.info(f"getDataset alias: [{dset.name}]")
439437

440438
item = {"alias": dset.name}
441-
print("dset:", dset)
442-
print("dset type:", type(dset))
443439
typeid = dset.id.get_type()
444440
if h5py.h5t.TypeID.committed(typeid):
445441
type_uuid = None
@@ -479,7 +475,7 @@ def _getDataset(self, dset):
479475
item["cpl"] = self._getHDF5DatasetCreationProperties(dset, type_item["class"])
480476

481477
return item
482-
478+
483479
def _getHardLinkIds(self, parent):
484480
""" create any ids for hard links of the group """
485481

@@ -518,21 +514,18 @@ def getObjectById(self, obj_id, include_attrs=True, include_links=True):
518514
if obj_id not in self._id_map:
519515
raise KeyError(f"{obj_id} not found")
520516
h5obj = self._id_map[obj_id]
521-
print("h5obj:", h5obj)
522-
print("h5obj.name:", h5obj.name)
523-
print("h5obj type:", type(h5obj))
524517
if isinstance(h5obj, h5py.Group):
525518
self._getHardLinkIds(h5obj)
526519
obj_json = self._getGroup(h5obj, include_links=include_links)
527520
elif isinstance(h5obj, h5py.Dataset):
528521
obj_json = self._getDataset(h5obj)
529522
elif isinstance(h5obj, h5py.Datatype):
530-
obj_json = self._getDataset(h5obj)
523+
obj_json = self._getDatatype(h5obj)
531524
else:
532525
msg = f"unexpected object type: {type(h5obj)}"
533526
self.log.error(msg)
534527
raise TypeError(msg)
535-
528+
536529
if include_attrs:
537530
attributes = self.getAttributes(obj_id)
538531
obj_json["attributes"] = attributes

src/h5json/h5pystore/h5py_writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ def updateAttributes(self, obj_id, obj):
388388
continue
389389
self.createAttribute(obj, name, attr_json)
390390

391-
392391
def flush(self):
393392
""" Write dirty items """
394393
if self.closed:

src/h5json/h5writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def no_data(self):
6767
@abstractmethod
6868
def open(self):
6969
""" open storage handle, return root_id"""
70-
return None
70+
pass
7171

7272
@abstractmethod
7373
def flush(self):

0 commit comments

Comments
 (0)