Skip to content

Commit

Permalink
issue_186: maybe fix timelines (#188)
Browse files Browse the repository at this point in the history
* maybe fix timelines

Could not exactly replicate the error in the log file but found a simple error and repaired it. Given how algorithm and sv PKs work, it is necessary to allow multiples and then work with the latest in the database (largest primary table PK).

* fixed timelines

The notebook page was running with the older psycopg2 which worked. Moved to the correct psycopg (3.1.9) and duplicated the error. Corrected it code using fetchall() as it now returns a list of tuples.
  • Loading branch information
al-niessner authored Oct 13, 2022
1 parent 5df9aff commit fe88994
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions Python/dawgie/db/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ def _recede (self, refs:[(dawgie.SV_REF, dawgie.V_REF)])->None:
cur.execute('SELECT PK from Algorithm WHERE name = %s and ' +
'task_ID = %s;',
(ref.impl.name(), task_ID,))
alg_IDs = cur.fetchall()
alg_IDs = [aid[0] for aid in cur.fetchall()]
cur.execute('SELECT PK FROM StateVector WHERE name = %s and ' +
'alg_ID = ANY(%s);',
(ref.item.name(), alg_IDs,))
sv_IDs = cur.fetchall()
sv_IDs = [svid[0] for svid in cur.fetchall()]
fsvn = '.'.join ([dawgie.util.task_name (ref.factory),
ref.impl.name(),
ref.item.name()])
Expand All @@ -387,20 +387,14 @@ def _recede (self, refs:[(dawgie.SV_REF, dawgie.V_REF)])->None:
'sv_ID = ANY(%s);', [tnid, task_ID, alg_IDs, sv_IDs])
rids = sorted ({r[0] for r in cur.fetchall()})
for rid in rids:
cur.execute ('SELECT alg_ID,sv_ID FROM Prime WHERE ' +
cur.execute ('SELECT PK,alg_ID,sv_ID FROM Prime WHERE ' +
'run_ID = %s AND tn_ID = %s AND ' +
'task_ID = %s AND alg_ID = ANY(%s) AND ' +
'sv_ID = ANY(%s);',
[rid, tnid, task_ID, alg_IDs, sv_IDs])
ids = cur.fetchall()
aids = {id[0] for id in ids}
svids = {id[1] for id in ids}

if len (aids) != 1 and len (svids) != 1:
log.critical ('Database corruption from many versions at one run id.')
continue

alg_ID,sv_ID = aids.pop(),svids.pop()
pks = [id[0] for id in ids]
alg_ID,sv_ID = ids[pks.index(max(pks))][1:]
cur.execute('SELECT val_ID from Prime WHERE run_ID = %s AND ' +
'alg_ID = %s AND tn_ID = %s and task_ID = %s and ' +
'sv_ID = %s;',
Expand Down

0 comments on commit fe88994

Please sign in to comment.