changeset 637:83397981a118

merge
author James Bergstra <bergstrj@iro.umontreal.ca>
date Wed, 21 Jan 2009 16:02:07 -0500
parents 9fb784c1f23d (diff) 89bc88affef0 (current diff)
children 4b1bb5810423 af14b1f32882
files
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/dbdict/sql.py	Wed Jan 21 03:37:58 2009 -0500
+++ b/pylearn/dbdict/sql.py	Wed Jan 21 16:02:07 2009 -0500
@@ -231,9 +231,12 @@
 
     rval = None
     if do_insert:
-        job[STATUS] = START
-        job[HASH] = jobhash
-        job[PRIORITY] = priority
+        if STATUS not in job:
+            job[STATUS] = START
+        if HASH not in job:
+            job[HASH] = jobhash
+        if PRIORITY not in job:
+            job[PRIORITY] = priority
         rval = db.insert(job, session=s)
         s.commit()
 
@@ -244,7 +247,12 @@
 
 def insert_job(experiment_fn, state, db, force_dup=False, session=None, priority=1.0):
     state = copy.copy(state)
-    state[EXPERIMENT] = experiment_fn.__module__ + '.' + experiment_fn.__name__
+    experiment_name = experiment_fn.__module__ + '.' + experiment_fn.__name__
+    if EXPERIMENT in state:
+        if state[EXPERIMENT] != experiment_name:
+            raise Exception('Inconsistency: state element %s does not match experiment %s' %(EXPERIMENT, experiment_name))
+    else:
+        state[EXPERIMENT] = experiment_name
     return insert_dict(state, db, force_dup=force_dup, session=session, priority=priority)