Skip to content

Commit

Permalink
hdf5: Warn when attaching metadata to absent key
Browse files Browse the repository at this point in the history
Signed-off-by: yuk <yuk@m-labs.hk>
  • Loading branch information
yuk-m-labs committed Oct 18, 2022
1 parent 22e6db8 commit 3767779
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions artiq/examples/no_hardware/repository/hdf5_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ def run(self):
self.set_dataset("dummy", dummy,
broadcast=True, archive=True)
self.set_dataset_metadata("dummy", {"k1": "v1", "k2": "v2"})

# Attach metadata to an absent key is no-op
self.set_dataset_metadata("nothing", {"no": "op"})
2 changes: 2 additions & 0 deletions artiq/master/worker_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def get(self, key, archive=False):

def set_metadata(self, key, metadata):
if key:
if key not in self.local:
logger.warning(f"Key '{key}' not found in dataset.")
self.hdf5_attributes["datasets/" + key] = metadata
else:
self.hdf5_attributes["datasets"] = metadata
Expand Down

0 comments on commit 3767779

Please sign in to comment.