Mercurial > pylearn
changeset 634:9b24b4345f52
merge
author | desjagui@atchoum.iro.umontreal.ca |
---|---|
date | Wed, 21 Jan 2009 03:27:13 -0500 |
parents | e242c12eb30d (current diff) e52a5c3aaca5 (diff) |
children | 89bc88affef0 |
files | |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dbdict/sql.py Wed Jan 21 03:23:50 2009 -0500 +++ b/pylearn/dbdict/sql.py Wed Jan 21 03:27:13 2009 -0500 @@ -86,6 +86,9 @@ # use dedicated column to retrieve jobs, not the dictionary keyval pair # This should be much faster. q = q.filter(db._Dict.status==START) + q = q.order_by(db._Dict.priority.desc()) + + # this doesn't seem to work, hene the string hack below q = q.options(eagerload('_attrs')) #hard-coded in api0 #try to reserve a dct @@ -209,7 +212,7 @@ # Queue ########### -def insert_dict(jobdict, db, force_dup=False, session=None): +def insert_dict(jobdict, db, force_dup=False, session=None, priority=1.0): """Insert a new `job` dictionary into database `db`. :param force_dup: forces insertion even if an identical dictionary is already in the db @@ -230,7 +233,7 @@ if do_insert: job[STATUS] = START job[HASH] = jobhash - job[PRIORITY] = 1.0 + job[PRIORITY] = priority rval = db.insert(job, session=s) s.commit() @@ -239,10 +242,10 @@ return rval -def insert_job(experiment_fn, state, db, force_dup=False, session=None): +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__ - return insert_dict(state, db, force_dup=force_dup, session=session) + return insert_dict(state, db, force_dup=force_dup, session=session, priority=priority) # TODO: FIXME: WARNING