コード例 #1
0
    def parse_standard_calls(cls, parentid, name, calls) -> List[RunJobModel]:

        jobs = []
        parents: Dict[str, RunJobModel] = {}
        for c in calls:
            job = cls.parse_standard_call(parentid, name, c)

            if job.shard is None:
                jobs.append(job)
            else:
                if job.parent in parents:
                    parents[job.parent].jobs.append(job)
                else:
                    parents[job.parent] = RunJobModel(
                        submission_id=job.submission_id,
                        run_id=job.run_id,
                        id_=job.parent,
                        parent=parentid,
                        jobs=[job],
                        name=job.name,
                        status=TaskStatus.PROCESSING,
                    )

        for parent in parents.values():
            parent.start = min(j.start for j in parent.jobs)
            finishes = [j.finish for j in parent.jobs]
            if all(f is not None for f in finishes):
                parent.finish = max(finishes)
            parent.status = TaskStatus.collapse_states([j.status for j in parent.jobs])

        return [*parents.values(), *jobs]
コード例 #2
0
def do_query(args):
    status = None
    if args.status:
        status = TaskStatus(args.status.lower())

    name = args.name
    tasks = ConfigManager.manager().query_tasks(status=status, name=name)

    prepared = [(
        wid,
        t.status,
        t.name,
        t.start,
        (", ".join(t.labels) if t.labels else ""),
        t.outdir,
    ) for wid, t in tasks.items()]
    prepared.sort(key=lambda p: p[3] if p[3] else DateUtil.max())

    print(
        tabulate.tabulate(
            prepared,
            headers=[
                "TaskID", "status", "name", "start date", "labels", "path"
            ],
        ),
        file=sys.stdout,
    )
コード例 #3
0
 def __init__(self, submission_id: str, run_id: str, status: TaskStatus,
              date: datetime):
     self.submission_id = submission_id
     self.run_id = run_id
     self.status = status if isinstance(status,
                                        TaskStatus) else TaskStatus(status)
     if not isinstance(date, datetime):
         date = DateUtil.parse_iso(date)
     self.date = date
コード例 #4
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
コード例 #5
0
def do_wait(args):
    wids = args.wid

    statuses = {}
    for wid in wids:
        wm = ConfigManager.get_from_path_or_submission_lazy(wid, readonly=True)
        Logger.info(f"Waiting for '{wid}' to finish")
        status = wm.database.get_uncached_status()
        while not status.is_in_final_state():
            sleep(2)
            status = wm.database.get_uncached_status()

        statuses[wid] = (wm.submission_id, status)
        Logger.info(
            f"Workflow {wid} finished with status: {status.to_string()}")

    collapsed_status = TaskStatus.collapse_states(
        [s[1] for s in statuses.values()])

    rc = collapsed_status.get_exit_code()
    Logger.info(
        f"All workflows finished with collapsed status {collapsed_status.to_string()}, exiting with rc={rc}"
    )
    sys.exit(rc)
コード例 #6
0
def add_query_args(parser):
    statuses = [v.value for v in TaskStatus.all()]
    parser.add_argument("--status", help="workflow status", choices=statuses)
    parser.add_argument("--name", help="workflow name")

    return parser
コード例 #7
0
    def __init__(
        self,
        id_: str,
        submission_id: str,
        run_id: str,
        parent: Optional[str],
        name: str,
        batchid: Optional[str] = None,
        shard: Optional[int] = None,
        attempt: Optional[int] = None,
        container: Optional[str] = None,
        status: TaskStatus = None,
        start: Union[str, datetime] = None,
        finish: Optional[Union[str, datetime]] = None,
        backend: Optional[str] = None,
        cached: bool = None,
        stdout: Optional[str] = None,
        stderr: Optional[str] = None,
        script: Optional[str] = None,
        error: Optional[str] = None,
        returncode: Optional[str] = None,
        memory: Optional[str] = None,
        cpu: Optional[str] = None,
        analysis: Optional[str] = None,
        # Optional
        jobs: Optional[list] = None,
        lastupdated: Union[str, datetime] = None,
        workdir: Optional[str] = None,
    ):
        self.id_ = id_
        self.submission_id = submission_id
        self.run_id = run_id
        self.parent = parent

        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.error = error
        self.returncode = returncode
        self.workdir = workdir

        self.lastupdated = lastupdated or DateUtil.now()
        if isinstance(lastupdated, str):
            self.lastupdated = DateUtil.parse_iso(lastupdated)

        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.script = script
        self.memory = memory
        self.cpu = cpu
        self.analysis = analysis

        self.jobs: Optional[List[RunJobModel]] = jobs or None
        self.events = None