Skip to content

Commit

Permalink
issue 199: verify promotion and shelve work in real life (#212)
Browse files Browse the repository at this point in the history
* clean up 

Missed a skip unit test that flushed out a couple more fixes to shelve. There is also a hidden function in the db API that needs to be fixed. It is noted on #213
  • Loading branch information
al-niessner authored Aug 3, 2023
1 parent a8e485b commit f5cd6d7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
18 changes: 11 additions & 7 deletions Python/dawgie/db/shelve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def reopen()->bool:
'''
return DBI().reopen()

def reset (_runid:int, _tn:str, _tskn, _alg)->None:
log.warning('reset() is not implemented for shelve')
return

def retreat (reg, ret)->dawgie.Timeline:
'''Get a dawgie.Timeline from the database backend
Expand Down Expand Up @@ -389,26 +393,26 @@ def versions():
svs_vers = {}
tasks_vers = {}
vals_vers = {}
for vk,pid in DBI().tables.value:
for vk,pid in DBI().tables.value.items():
pid,vn,vv = util.dissect (vk)
pid,svn,svv = util.dissect (DBI().indices.state[pid])
pid,algn,algv = util.dissect (DBI().indices.alg[pid])
pid,tskn,_tskv = util.dissect (DBI().indices.task[pid])
tasks_vers[tskn] = True
key = '.'.join([tskn, algn])

if key in algs_vers: algs_vers[key].add (algv.asstring())
else: algs_vers[key] = {algv.asstring()}
if key in algs_vers: algs_vers[key].append (algv.asstring())
else: algs_vers[key] = [algv.asstring()]

key = '.'.join([tskn, algn, svn])

if key in svs_vers: svs_vers[key].add (svv.asstring())
else: svs_vers[key] = {svv.asstring()}
if key in svs_vers: svs_vers[key].append (svv.asstring())
else: svs_vers[key] = [svv.asstring()]

key = '.'.join([tskn, algn, svn, vn])

if key in vals_vers: vals_vers[key].add (vv.asstring())
else: vals_vers[key] = {vv.asstring()}
if key in vals_vers: vals_vers[key].append (vv.asstring())
else: vals_vers[key] = [vv.asstring()]
pass
return tasks_vers,algs_vers,svs_vers,vals_vers

Expand Down
2 changes: 1 addition & 1 deletion Python/dawgie/pl/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def for_factories (ae, pkg):
fp = '.'.join ([pkg, pkg_name])
mod = importlib.import_module (fp)
dm = dir(mod)
ignore = getattr (mod, 'ignore') if 'ignore' in dm else False
ignore = getattr(mod,'dawgie_ignore') if 'dawgie_ignore' in dm else False

if ignore:
log.warning ('Ignoring package: %s', fp)
Expand Down
25 changes: 16 additions & 9 deletions Test/test_13.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ def test_archive(self):
self.assertTrue (True) # not testable in a reasonable sense
return

def test_close(self):
dawgie.db.close()
self.assertFalse (dawgie.db.post._db)
dawgie.db.open()
dawgie.db.close()
self.assertFalse (dawgie.db.post._db)
return

def test_connect(self):
tgt,tsk,alg = dawgie.db.testdata.DATASETS[0]
dawgie.db.close()
Expand Down Expand Up @@ -361,7 +353,6 @@ def test_update (self):
dawgie.db.close()
return

@unittest.skip ('takes too long while developing other tests')
def test_versions(self):
dawgie.db.close()
self.assertRaises (RuntimeError, dawgie.db.versions)
Expand Down Expand Up @@ -420,6 +411,14 @@ def tearDownClass(cls):
shutil.rmtree (cls.root, True)
return

def test_close(self):
dawgie.db.close()
self.assertFalse (dawgie.db.post._db)
dawgie.db.open()
dawgie.db.close()
self.assertFalse (dawgie.db.post._db)
return

def test_copy(self):
self.assertRaises (NotImplementedError, dawgie.db.copy, 1, 2, 3)
return
Expand Down Expand Up @@ -485,6 +484,14 @@ def tearDownClass(cls):
setattr (dawgie.db.shelve.comms.Worker, '_send', cls._send)
return

def test_close(self):
dawgie.db.close()
self.assertFalse (dawgie.db.shelve.state.DBI().is_open)
dawgie.db.open()
dawgie.db.close()
self.assertFalse (dawgie.db.shelve.state.DBI().is_open)
return

def test_consistent(self):
self.assertRaises(NotImplementedError, dawgie.db.consistent, [],[],'')
return
Expand Down

0 comments on commit f5cd6d7

Please sign in to comment.