# HG changeset patch # User Olivier Breuleux # Date 1232057269 18000 # Node ID 84e3af9d0110a5e7dde24da9ef842a3bd17457fd # Parent 605ab704abc3f1ad1d1612d69efced6f3e08dfe2 added sqlschedule_filemerge to newstuff diff -r 605ab704abc3 -r 84e3af9d0110 pylearn/dbdict/newstuff.py --- a/pylearn/dbdict/newstuff.py Mon Jan 12 18:47:10 2009 -0500 +++ b/pylearn/dbdict/newstuff.py Thu Jan 15 17:07:49 2009 -0500 @@ -677,6 +677,51 @@ +parser_sqlschedule_filemerge = OptionParser(usage = '%prog sqlschedule_filemerge [options] ') + +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] ') parser_sql.add_option('-n', dest = 'n', type = 'int', default = 1, help = 'Run N experiments sequentially (default 1) '