Exemple #1
0
def do_version(_):
    from tabulate import tabulate
    import importlib_metadata

    from janis_assistant.__meta__ import __version__ as jr_version
    from janis_core.__meta__ import __version__ as jc_version
    import janis_core.toolbox.entrypoints as EP

    fields = [["janis-core", jc_version], ["janis-assistant", jr_version]]
    # eps = pkg_resources.iter_entry_points(group=EP.EXTENSIONS)
    eps = importlib_metadata.entry_points().get(EP.EXTENSIONS, [])
    skip_eps = {"assistant"}
    for entrypoint in eps:
        if entrypoint.name in skip_eps:
            continue
        try:
            version = entrypoint.load().__version__
            if version:
                fields.append(["janis-" + entrypoint.name, version])
            skip_eps.add(entrypoint.name)

        except Exception as e:
            Logger.log_ex(e)

    print(tabulate(fields))
Exemple #2
0
        def wrapper(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except TranslationError:
                raise
            except Exception as e:

                components = ", ".join([
                    *[repr(a) for a in args],
                    *[
                        f"{k}={v}"
                        for k, v in kwargs.items() if k not in kwargstoignore
                    ],
                ])
                message = f"Couldn't translate {type or ''} with ({components})"
                er = TranslationError(message, inner=e)
                Logger.log_ex(er)
                raise er
    def create_task(self,
                    wid,
                    source,
                    inputs: list,
                    dependencies,
                    workflow_type=None):
        # curl \
        #   -X POST "http://*****:*****@whole_genome_germline.cwl;type=" \
        #   -F "workflowInputs=@whole_genome_germline-local.yml;type=" \
        #   -F "[email protected];type=application/zip

        from requests import post

        url = self.url_create()

        max_inputs = 5
        if len(inputs) > max_inputs:
            raise Exception(
                "Too many inputs (yaml files). Proposed: automatic merge into one file."
            )

        files = {
            "workflowSource":
            source,
            "labels":
            json.dumps({"taskid": wid}),
            "workflowOptions":
            json.dumps({
                "google_labels": {
                    "taskid": wid
                },
                "monitoring_image": "quay.io/dinvlad/cromwell-monitor",
                "workflow_failure_mode": "ContinueWhilePossible",
            }),
        }

        if dependencies:
            files["workflowDependencies"] = dependencies

        for i in range(len(inputs)):
            k = "workflowInputs" + ("" if i == 0 else "_" + str(i + 1))
            files[k] = inputs[i]

        Logger.log("Posting to " + url)

        r = post(url, files=files)
        try:
            res = r.json()
        except Exception as e:
            Logger.log_ex(e)
            Logger.critical(r.text)
            raise e

        if not r.ok or r.status_code > 201 or res["status"] != "Submitted":
            raise Exception(res)

        task_id = res["id"]

        return task_id