Exemplo n.º 1
0
import json
import typing
import argparse
from datetime import datetime
from typing import Any, Tuple, List, Dict

from firecloud import fiss

from terra_notebook_utils import workflows
from terra_notebook_utils.cli import Config, dispatch


workflow_cli = dispatch.group("workflows", help=workflows.__doc__)

workspace_args: Dict[str, Dict[str, Any]] = {
    "--workspace": dict(
        type=str,
        default=None,
        help="workspace name. If not provided, the configured CLI workspace will be used"
    ),
    "--workspace-namespace": dict(
        type=str,
        required=False,
        default=Config.info['workspace_namespace'],
        help=("The billing project for GS requests. "
              "If omitted, the CLI configured `workspace_namespace` will be used. "
              "Note that DRS URLs also involve a GS request.")
    )
}

@workflow_cli.command("list-submissions", arguments={**workspace_args})
Exemplo n.º 2
0
import json
import argparse

from terra_notebook_utils import vcf, WORKSPACE_GOOGLE_PROJECT
from terra_notebook_utils.cli import dispatch
from terra_notebook_utils.drs import blob_for_url

vcf_cli = dispatch.group(
    "vcf",
    help=vcf.__doc__,
    arguments={
        "path":
        dict(help="local path, gs://, or drs://"),
        "--billing-project":
        dict(type=str,
             required=False,
             default=WORKSPACE_GOOGLE_PROJECT,
             help=("The billing project for GS requests. "
                   "If omitted, the environment variables GOOGLE_PROJECT, "
                   "GCP_PROJECT, AND GCLOUD_PROJECT will be in that order.")),
    })


@vcf_cli.command("head")
def head(args: argparse.Namespace):
    """
    Output VCF header.
    """
    blob = blob_for_url(args.path, args.billing_project)
    info = vcf.VCFInfo.with_blob(blob)
    info.print_header()
Exemplo n.º 3
0
import argparse

from terra_notebook_utils import vcf
from terra_notebook_utils.cli import dispatch, Config
import google.cloud.storage.blob


vcf_cli = dispatch.group("vcf", help=vcf.__doc__, arguments={
    "path": dict(
        help="local path, gs://, or drs://"
    ),
    "--workspace": dict(
        type=str,
        default=None,
        help="Workspace name. If not provided, the configured CLI workspace will be used."
    ),
    "--workspace-namespace": dict(
        type=str,
        required=False,
        default=Config.info['workspace_namespace'],
        help=("The billing project for GS requests. "
              "If omitted, the CLI configured `workspace_google_project` will be used. "
              "Note that DRS URLs also involve a GS request.")
    ),
})


@vcf_cli.command("head")
def head(args: argparse.Namespace):
    """
    Output VCF header.
    """
Exemplo n.º 4
0
import json
import typing
import argparse

from firecloud import fiss

from terra_notebook_utils import workspace
from terra_notebook_utils.cli import Config, dispatch


workspace_cli = dispatch.group("workspace", help=workspace.__doc__)


@workspace_cli.command("list")
def list_workspaces(args: argparse.Namespace):
    """
    List workspaces available to the current usuer
    """
    list_workspaces.__doc__ = workspace.list_workspaces.__doc__
    data = workspace.list_workspaces()
    info_keys = ["name", "createdBy", "bucketName", "namespace"]
    workspaces = [{key: ws['workspace'][key] for key in info_keys}
                  for ws in data]
    print(json.dumps(workspaces, indent=2))

@workspace_cli.command("get", arguments={
    "--workspace": dict(type=str, required=True, help="workspace name"),
    "--workspace-namespace": dict(type=str, required=False, default=None, help="workspace namespace"),
})
def get_workspace(args: argparse.Namespace):
    """
Exemplo n.º 5
0
import json
import argparse
from uuid import uuid4

from terra_notebook_utils import table as tnu_table
from terra_notebook_utils.cli import dispatch, CLIConfig


table_cli = dispatch.group("table", help=tnu_table.__doc__, arguments={
    "--workspace": dict(
        type=str,
        default=None,
        help="workspace name. If not provided, the configured CLI workspace will be used"
    ),
    "--workspace-namespace": dict(
        type=str,
        default=None,
        help=("The workspace namespace represents the parent containing the workspace "
              "(the Terra billing project) "
              "If omitted, the CLI configured `workspace_namespace` will be used. ")
    ),
})

@table_cli.command("list")
def list_tables(args: argparse.Namespace):
    """
    List all tables in the workspace
    """
    args.workspace, args.workspace_namespace = CLIConfig.resolve(args.workspace, args.workspace_namespace)
    for table in tnu_table.list_tables(args.workspace, args.workspace_namespace):
        print(table)
Exemplo n.º 6
0
"""
Configure the CLI
"""
import typing
import argparse

from terra_notebook_utils.cli import Config, dispatch

config_cli = dispatch.group("config", help=__doc__)


@config_cli.command("set-workspace", arguments={"workspace": dict()})
def set_config_workspace(args: argparse.Namespace):
    """
    Set workspace for cli commands
    """
    Config.info["workspace"] = args.workspace
    Config.write()


@config_cli.command("set-workspace-namespace",
                    arguments={"workspace_namespace": dict(type=str)})
def set_config_workspace_namespace(args: argparse.Namespace):
    """
    Set workspace namespace for cli commands
    """
    Config.info["workspace_namespace"] = args.workspace_namespace
    Config.write()


@config_cli.command("print")