Skip to content

Commit ca8920c

Browse files
committed
[rename] renamed protected attrs in hdf5
1 parent f5a9276 commit ca8920c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/oqd_dataschema/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def names(cls):
6666

6767
########################################################################################
6868

69-
invalid_attrs = ["_model_signature", "_model_json"]
69+
invalid_attrs = ["_datastore_signature", "_group_json"]
7070

7171

7272
def _valid_attr_key(value):

src/oqd_dataschema/datastore.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def model_dump_hdf5(self, filepath: pathlib.Path, mode: Literal["w", "a"] = "w")
9595

9696
with h5py.File(filepath, mode) as f:
9797
# store the model JSON schema
98-
f.attrs["_model_signature"] = self.model_dump_json()
98+
f.attrs["_datastore_signature"] = self.model_dump_json(indent=2)
9999
for akey, attr in self.attrs.items():
100100
f.attrs[akey] = attr
101101

@@ -105,7 +105,9 @@ def model_dump_hdf5(self, filepath: pathlib.Path, mode: Literal["w", "a"] = "w")
105105
del f[gkey]
106106
h5_group = f.create_group(gkey)
107107

108-
h5_group.attrs["_model_schema"] = json.dumps(group.model_json_schema())
108+
h5_group.attrs["_group_schema"] = json.dumps(
109+
group.model_json_schema(), indent=2
110+
)
109111
for akey, attr in group.attrs.items():
110112
h5_group.attrs[akey] = attr
111113

@@ -132,7 +134,7 @@ def model_validate_hdf5(cls, filepath: pathlib.Path):
132134
filepath (pathlib.Path): The path to the HDF5 file where the model data will be read and validated from.
133135
"""
134136
with h5py.File(filepath, "r") as f:
135-
self = cls.model_validate_json(f.attrs["_model_signature"])
137+
self = cls.model_validate_json(f.attrs["_datastore_signature"])
136138

137139
# loop through all groups in the model schema and load HDF5 store
138140
for gkey, group in self:

0 commit comments

Comments
 (0)