def cmd_abort(argv): parser = ArgumentParser(prog=argv.pop(0)) parser.add_argument('-q', '--quiet', action='store_true', help="no output") args = parser.parse_args(argv) from accelerator.build import Automata a = Automata(cfg.url) res = a.abort() if not args.quiet: print("Killed %d running job%s." % (res.killed, '' if res.killed == 1 else 's'))
def build(method, options={}, datasets={}, jobs={}, name=None, caption=None, **kw): """Just like urd.build, but for making subjobs""" global _a, _bad_kws assert g.running != 'analysis', "Analysis is not allowed to make subjobs" assert g.subjob_cookie, "Can't build subjobs: out of cookies" if not _a: _a = Automata(g.server_url, subjob_cookie=g.subjob_cookie) _a.update_method_info() _a.record[None] = _a.jobs = globals()['jobs'] _bad_kws = set(getarglist(_a.call_method)) bad_kws = _bad_kws & set(kw) if bad_kws: raise Exception('subjobs.build does not accept these keywords: %r' % (bad_kws, )) def run(): return _a.call_method(method, options=options, datasets=datasets, jobs=jobs, record_as=name, caption=caption, **kw) try: if name or caption: msg = 'Building subjob %s' % (name or method, ) if caption: msg += ' "%s"' % (caption, ) with status(msg): jid = run() else: jid = run() except ServerError as e: raise ServerError(e.args[0]) except JobError as e: raise JobError(e.job, e.method, e.status) for d in _a.job_retur.jobs.values(): if d.link not in _record: _record[d.link] = bool(d.make) return jid
def sub_part(sliceno, opts): a = Automata(g.server_url, verbose=True) pid = os.getpid() def verify(want): timeout = 0 got = None for _ in range(25): status_stacks = a._server_idle(timeout)[2] for line in status_stacks: if line[0] == pid and line[1] < 0: # this is our tail got = line[2].replace('\r\n', '\n') if got == want: return # it might not have reached the server yet timeout += 0.01 # we've given it 3 seconds, it's not going to happen. raise Exception("Wanted to see tail output of %r, but saw %r" % (want, got,)) print(opts.prefix, file=sys.stderr) verify(opts.prefix + '\n') if isinstance(sliceno, int): msg = opts.a % (sliceno,) else: msg = opts[sliceno] print(msg) verify(opts.prefix + '\n' + msg + '\n')
def build(method, options={}, datasets={}, jobids={}, name=None, caption=None): """Just like urd.build, but for making subjobs""" global _a assert g.running != 'analysis', "Analysis is not allowed to make subjobs" assert g.subjob_cookie, "Can't build subjobs: out of cookies" if not _a: _a = Automata(g.daemon_url, subjob_cookie=g.subjob_cookie) _a.update_method_deps() _a.record[None] = _a.jobs = jobs def run(): return _a.call_method(method, options=options, datasets=datasets, jobids=jobids, record_as=name, caption=caption) try: if name or caption: msg = 'Building subjob %s' % (name or method, ) if caption: msg += ' "%s"' % (caption, ) with status(msg): jid = run() else: jid = run() except DaemonError as e: raise DaemonError(e.args[0]) except JobError as e: raise JobError(e.jobid, e.method, e.status) for d in _a.job_retur.jobs.values(): if d.link not in _record: _record[d.link] = bool(d.make) return jid