Mercurial > pylearn
changeset 604:52a99d83f06d
merge
author | Olivier Breuleux <breuleuo@iro.umontreal.ca> |
---|---|
date | Thu, 15 Jan 2009 17:12:36 -0500 |
parents | 84e3af9d0110 (diff) 28f7dc848efc (current diff) |
children | 8f40262297cf 7cee8c7f0449 |
files | pylearn/dbdict/newstuff.py |
diffstat | 1 files changed, 45 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dbdict/newstuff.py Wed Jan 14 17:22:23 2009 -0500 +++ b/pylearn/dbdict/newstuff.py Thu Jan 15 17:12:36 2009 -0500 @@ -692,6 +692,51 @@ +parser_sqlschedule_filemerge = OptionParser(usage = '%prog sqlschedule_filemerge [options] <tablepath> <experiment> <parameters|files>') + +def runner_sqlschedule_filemerge(options, dbdescr, experiment, mainfile, *other_files): + """ + Schedule a job to run using the sql command using parameter files. + + This command is to sqlschedule what the filemerge command is to + cmdline. + """ + + try: + username, password, hostname, dbname, tablename \ + = sql.parse_dbstring(dbdescr) + except: + raise UsageError('Wrong syntax for dbdescr') + + db = sql.postgres_serial( + user = username, + password = password, + host = hostname, + database = dbname, + table_prefix = tablename) + + with open(mainfile) as f: + _state = parse(*map(str.strip, f.readlines())) + for file in other_files: + if '=' in file: + _state.update(parse(file)) + else: + with open(file) as f: + _state.update(parse(*map(str.strip, f.readlines()))) + state = _state + + try: + resolve(experiment) + except: + raise UsageError('The first parameter to sqlschedule_filemerge must be a valid, importable symbol.') + state['dbdict.experiment'] = experiment + sql.add_experiments_to_db([state], db, verbose = 1) + +runner_registry['sqlschedule_filemerge'] = (parser_sqlschedule_filemerge, runner_sqlschedule_filemerge) + + + + parser_sql = OptionParser(usage = '%prog sql [options] <tablepath> <exproot>') parser_sql.add_option('-n', dest = 'n', type = 'int', default = 1, help = 'Run N experiments sequentially (default 1) '