From 12ef907f34ddcbd9ff0473aa4b34e78b657c659e Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Thu, 17 Jun 2021 16:30:38 +0200 Subject: [PATCH] master/databases: fix AttributeError in DatasetDB.set() Add corresponding unit test. Signed-off-by: Etienne Wodey --- artiq/master/databases.py | 2 +- artiq/test/test_dataset_db.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/artiq/master/databases.py b/artiq/master/databases.py index fcf1ad31c..310b5caec 100644 --- a/artiq/master/databases.py +++ b/artiq/master/databases.py @@ -90,7 +90,7 @@ class DatasetDB(TaskObject): def set(self, key, value, persist=None, **hdf5_options): if persist is None: if key in self.data.raw_view: - persist = self.data.raw_view[key].persist + persist = self.data.raw_view[key]["persist"] else: persist = False self.data[key] = make_dataset( diff --git a/artiq/test/test_dataset_db.py b/artiq/test/test_dataset_db.py index 74aff8219..3fa4b1f8a 100644 --- a/artiq/test/test_dataset_db.py +++ b/artiq/test/test_dataset_db.py @@ -97,3 +97,15 @@ class TestDatasetDB(unittest.TestCase): self.ddb.update(mod) self.assertFalse(self.ddb.get(KEY1)["hdf5_options"]["shuffle"]) + + def test_reset_copies_persist(self): + self.assertTrue(self.ddb.get(KEY1)["persist"]) + self.ddb.set(KEY1, DATA) + self.assertTrue(self.ddb.get(KEY1)["persist"]) + + self.assertFalse(self.ddb.get(KEY3)["persist"]) + self.ddb.set(KEY3, DATA) + self.assertFalse(self.ddb.get(KEY3)["persist"]) + + self.ddb.set(KEY3, DATA, persist=True) + self.assertTrue(self.ddb.get(KEY3)["persist"])