def cycle(cls): from .service import auto_complete, auto_submit_chain, auto_submit_root, auto_start auto_complete() auto_submit_chain() auto_submit_root() auto_start() print('Cycle at {t}.'.format(t=now(True)))
def __init__(self, desc, data, state=None, workdir=None, worker=None, ttype=None, dependency=None, time_create=None, time_start=None, time_end=None, is_root=True): self.desc = desc self.data = data if time_create is None: time_create = now() self.time_create = time_create if state is None: from .config import config as c state = c['default_state'] self.state = state self.worker = worker self.workdir = workdir self.ttype = ttype self.dependency = dependency self.is_root = is_root
def __init__(self, start=None): if start is None: start = now() super(Start, self).__init__({'start': start})
def update_run(self): self.run = now() - self.start
def create_now(cls): return cls(create=now(), start=None, end=None)
def complete(task): task = Task.from_json(task.to_json()) task.end = now() task.state = State.Complete return task
def start(task): task = Task.from_json(task.to_json()) task.start = now() task.state = State.Runing return task
def mark_complete(task) -> None: if task.time_stamp.end is None: task.time_stamp = TaskStamp(create=task.time_stamp.create, start=task.time_stamp.start, end=now()) return update(ts.complete(task))
def mark_start(task) -> None: if task.time_stamp.start is None: task.time_stamp = TaskStamp(create=task.time_stamp.create, start=now(), end=task.time_stamp.end) return update(ts.start(task))