From f343459d6198352964dbb6779f15c352fe2d5794 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 28 Jul 2013 09:54:54 +0100 Subject: init --- run2.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 run2.py (limited to 'run2.py') diff --git a/run2.py b/run2.py new file mode 100755 index 0000000..a92c118 --- /dev/null +++ b/run2.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python2 + +import os +import datetime +import logging +from src.evaluator import Evaluator +from src.smt_semparse_config import SMTSemparseConfig +from src.smt_semparse_experiment import SMTSemparseExperiment + +LOGFILE_NAME = 'run.log' + +def run_one(config): + # create work dir for this run + # moses can't handle paths with colons + timestamp = datetime.datetime.now().strftime('%Y-%m-%dT%H.%M.%S') + run_work_dir = os.path.join(base_work_dir, timestamp) + assert not os.path.exists(run_work_dir) + os.makedirs(run_work_dir) + config.put('work_dir', run_work_dir) + if os.path.exists('latest'): + os.remove('latest') + os.symlink(run_work_dir, 'latest') + + # set up logging + if config.run == 'debug': + logging.basicConfig(level=logging.DEBUG) + else: + log_path = os.path.join(run_work_dir, LOGFILE_NAME) + logging.basicConfig(filename=log_path, level=logging.INFO) + + experiment = SMTSemparseExperiment(config) + if config.run == 'debug': + experiment.run_fold(1) + elif config.run == 'dev': + for i in range(10): + experiment.run_fold(i) + elif config.run == 'test': + experiment.run_split() + else: + assert False + + logging.info('evaluating') + Evaluator(config).run() + +if __name__ == '__main__': + + # load config + config = SMTSemparseConfig('settings.yaml', 'dependencies.yaml') + + # create base work dir if it doesn't exist + base_work_dir = os.path.join(config.smt_semparse, config.workdir) + if not os.path.exists(base_work_dir): + os.makedirs(base_work_dir) + + run_one(config) -- cgit v1.2.3