Mercurial > pylearn
changeset 608:8f40262297cf
merged
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Thu, 15 Jan 2009 22:23:43 -0500 |
parents | 23467f473eb7 (current diff) 52a99d83f06d (diff) |
children | e8cb4bde30a7 |
files | pylearn/dbdict/newstuff.py |
diffstat | 1 files changed, 45 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dbdict/newstuff.py Thu Jan 15 22:22:45 2009 -0500 +++ b/pylearn/dbdict/newstuff.py Thu Jan 15 22:23:43 2009 -0500 @@ -703,6 +703,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) '