Ejemplo n.º 1
0
 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)))
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def __init__(self, start=None):
     if start is None:
         start = now()
     super(Start, self).__init__({'start': start})
Ejemplo n.º 4
0
 def update_run(self):
     self.run = now() - self.start
Ejemplo n.º 5
0
 def create_now(cls):
     return cls(create=now(), start=None, end=None)
Ejemplo n.º 6
0
def complete(task):
    task = Task.from_json(task.to_json())
    task.end = now()
    task.state = State.Complete
    return task
Ejemplo n.º 7
0
def start(task):
    task = Task.from_json(task.to_json())
    task.start = now()
    task.state = State.Runing
    return task
Ejemplo n.º 8
0
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))
Ejemplo n.º 9
0
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))