Ejemplo n.º 1
0
    def __init__(
        self,
        jid: str,
        parentjid: Optional[str],
        name: str,
        batchid: Optional[str],
        shard: Optional[int],
        attempt: Optional[int],
        container: Optional[str],
        status: TaskStatus,
        start: Union[str, datetime],
        finish: Optional[Union[str, datetime]],
        backend: Optional[str],
        cached: bool,
        stdout: Optional[str],
        stderr: Optional[str],
        jobs: Optional[list] = None,
    ):
        self.jid = jid
        self.parentjid = parentjid
        self.status = status if isinstance(status,
                                           TaskStatus) else TaskStatus(status)

        self.name = name
        self.batchid = batchid
        self.shard = None
        if shard is not None:
            if isinstance(shard, str) and shard.isdigit:
                shard = int(shard)
            if shard >= 0:
                self.shard = shard
        self.attempt = None
        if attempt is not None:
            if isinstance(attempt, str) and attempt.isdigit():
                attempt = int(attempt)
            if attempt > 1:
                self.attempt = attempt

        self.container = container

        self.backend = backend
        self.cached = cached

        self.stderr = stderr
        self.stdout = stdout

        self.start = start
        self.finish = finish
        if start and isinstance(start, str):
            self.start = DateUtil.parse_iso(start)
        if finish and isinstance(finish, str):
            self.finish = DateUtil.parse_iso(finish)

        self.jobs = jobs or None
        self.events = None
Ejemplo n.º 2
0
    def get(self, wid: str) -> Optional[datetime]:
        with self.with_cursor() as cursor:
            cursor.execute("SELECT timestamp FROM runs WHERE wid = ?", (wid, ))
            row = cursor.fetchone()

        if not row:
            return None

        return DateUtil.parse_iso(row[0])
 def get_all(self) -> Dict[str, datetime]:
     with self.with_cursor() as cursor:
         cursor.execute("SELECT key, timestamp FROM progress WHERE wid = ?",
                        (self.wid, ))
         rows = cursor.fetchall()
         return {row[0]: DateUtil.parse_iso(row[1]) for row in rows}
Ejemplo n.º 4
0
 def __init__(self, jid: str, status: TaskStatus, timestamp: str):
     self.jid = jid
     self.status = status
     self.timestamp = timestamp
     if timestamp and isinstance(timestamp, str):
         self.timestamp = DateUtil.parse_iso(timestamp)
Ejemplo n.º 5
0
    def get_all(self) -> Dict[str, datetime]:
        with self.with_cursor() as cursor:
            cursor.execute("SELECT wid, timestamp FROM runs")
            rows = cursor.fetchall()

        return {row[0]: DateUtil.parse_iso(row[1]) for row in rows}