def submit(hostname, submitter=None): """ Submit a new job to given host. """ host = hostname + '-host' try: host_cfg = simcity.get_config().section(host) except: raise ValueError('%s not configured under %s section' % (hostname, host)) try: if submitter is None: if host_cfg['method'] == 'ssh': submitter = SSHSubmitter( database=simcity.get_job_database(), host=host_cfg['host'], jobdir=host_cfg['path'], prefix=hostname + '-') elif host_cfg['method'] == 'osmium': submitter = OsmiumSubmitter( database=simcity.get_job_database(), port=host_cfg['port'], jobdir=host_cfg['path'], prefix=hostname + '-') else: raise EnvironmentError('Connection method for %s unknown' % hostname) script = [host_cfg['script']] except KeyError: raise EnvironmentError( "Connection method for %s not well configured" % hostname) return submitter.submit(script)
def __init__(self, task_db=None, iterator=None, job_db=None, config=None): if task_db is None: task_db = simcity.get_task_database() super(ExecuteActor, self).__init__(task_db, iterator=iterator) if job_db is None: job_db = simcity.get_job_database() self.job_db = job_db if config is None: config = simcity.get_config() self.config = config.section("Execution")