Пример #1
0
def main(args=None):
    parser = ArgParser(description=Description)
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]

    args = parser.parse_args(args)
    test()
Пример #2
0
def main(args=None):
    parser = ArgParser(description=Description + \
                    ', to the latest version of its image')
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]

    args = parser.parse_args(args)
    sync()
Пример #3
0
def main(args=None):
    parser = ArgParser(description=Description+\
  " to reflect the latest method snapshot")
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]

    args = parser.parse_args(args)
    config()
Пример #4
0
def main(args=None):
    # TODO: allow bulk pushes from the workspace level like with build
    docker_cfg = ConfigLoader().config.Docker
    parser = ArgParser(description=Description)

    # Because parser.prog is initialized to the name of the top-level calling
    # module, it needs to be modified here to be consistent.
    # (i.e. so hydrant docker push -h returns a usage that begins with
    # hydrant docker push rather than only hydrant)
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]
        
    repo = os.path.basename(os.getcwd())
    
    client = connect_to_daemon()
    
    try:
        registry, namespace = find_registry_namespace(client, repo, docker_cfg)
    except Exception as e:
        logging.exception(str(e))
        sys.exit(1)
        
    registry = registry or docker_cfg.Registry
    namespace = namespace or docker_cfg.Namespace
    
    reg_kwargs = {'help': "Host[:port] of registry if not at Docker Hub"}
    if registry is not None:
        add_default_arg(registry, reg_kwargs)
    parser.add_argument('-R', '--registry', **reg_kwargs)
    
    ns_kwargs = {'help': 'Namespace under which the repository resides'}
    if namespace is None:
        ns_kwargs['required'] = True
    else:
        add_default_arg(namespace, ns_kwargs)
    parser.add_argument('-n', '--namespace', **ns_kwargs)
    parser.add_argument('-r', '--repository', default=repo,
                        help='Repository name (default: %(default)s)')
    tag = docker_cfg.Tag
    parser.add_argument('-t', '--tag', help="Version of the image or task " + \
                        "(default: {})".format(tag or 'latest'), default=tag)
    
    args = parser.parse_args(args)
    
    repo = args.namespace + '/' + args.repository
    if args.registry is not None:
        repo = args.registry + '/' + repo
    
    push_kwargs = {'stream': True}
    if args.tag is not None:
        push_kwargs['tag'] = args.tag
    
    push_image(client, repo, push_kwargs)        
Пример #5
0
def main(args=None):
    method_name = os.path.basename(os.getcwd())
    wdl = method_name + '.wdl'
    firecloud_cfg = ConfigLoader().config.FireCloud  # @UndefinedVariable
    
    parser = ArgParser(formatter_class=ArgumentDefaultsHelpFormatter,
                       description=Description)
    # Because parser.prog is initialized to the name of the top-level calling
    # module, it needs to be modified here to be consistent.
    # (i.e. so hydrant install -h returns a usage that begins with
    # hydrant install rather than only hydrant)
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]
    
    parser.add_argument('-m', '--method', help='Method name',
                        default=method_name)
    method_ns_kwargs = {}
    if fcconfig.method_ns:
        method_ns_kwargs['default'] = fcconfig.method_ns
    else:
        method_ns_kwargs['required'] = True
    parser.add_argument('-n', '--namespace', help="Method Repo namespace.",
                        **method_ns_kwargs)
    parser.add_argument('-d','--wdl', default=wdl, help="Method definiton, " + \
                        "as a file of WDL (Workflow Description Language)",
                        type=ValidFile)
    parser.add_argument('-s', '--synopsis', help="Short (<80 chars) " + \
                        "description of method")
    parser.add_argument('--doc', help='Optional documentation file <10Kb',
                        type=ValidFile)
    parser.add_argument('-c', '--comment', metavar='SNAPSHOT_COMMENT',
                        help='Optional comment specific to this snapshot',
                        default='')
    parser.add_argument('-o', '--owners',
                        **acl_kwargs('owner', firecloud_cfg.Owners))
    parser.add_argument('-r', '--readers',
                        **acl_kwargs('reader', firecloud_cfg.Readers))
    parser.add_argument('-w', '--writers',
                        **acl_kwargs('writer', firecloud_cfg.Writers))
    
    args = parser.parse_args(args)
    
    meth_new(args)
    args.snapshot_id = None
    set_acl('owner', args)
    set_acl('reader', args)
    set_acl('writer', args)
Пример #6
0
def main(args=None):

    parser = ArgParser(description=Description)

    # Because parser.prog is initialized to the name of the top-level calling
    # module, it needs to be modified here to be consistent.
    # (i.e. so hydrant init -h returns a usage that begins with hydrant init
    # rather than only hydrant)
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]

    parser.add_argument('-p',
                        '--package',
                        action='store_true',
                        help='include packaging tools')
    parser.add_argument('-n',
                        '--num_tasks',
                        type=int,
                        default=1,
                        help='Number of empty tasks to create')
    parser.add_argument('-c',
                        '--config',
                        type=task_config,
                        help='Config file with [Task <task_name>] sections ' +
                        'that may contain Src=<path/to/src>, ' +
                        'Image=<[registry/]namespcae/repo[:tag]>, and ' +
                        'any [Docker] section arguments to initialize ' +
                        'tasks with specified names, then copy source ' +
                        "code to each task's src directory and " +
                        "initialize each task's hydrant.cfg, or " +
                        'initialize WDL with prexisting docker image(s)')
    parser.add_argument('workflow',
                        type=new_folder,
                        help='Name of template folder')
    parser.add_argument('task',
                        nargs='*',
                        type=user_task,
                        help='Name of existing locally written task to ' +
                        'initialize with in the format of ' +
                        '<workflow>.<task|*>, with "<workflow>.*" ' +
                        'indicating all tasks in <workflow>')

    args = parser.parse_args(args)
    user_tasks = process_user_tasks(args.task, args.workflow)
    generate_workflow(args.workflow, args.num_tasks, user_tasks, args.config
                      or ConfigLoader().config, args.package)
Пример #7
0
def main(args=None):
    repos = {repo: version for repo, version in docker_repos()}
    docker_cfg = ConfigLoader().config.Docker
    # TODO: allow multiple registries and namespaces from the workspace folder
    #       level.
    reg_kwargs = {'help': "Host[:port] of registry if not at Docker Hub"}
    if docker_cfg.Registry is not None:
        add_default_arg(docker_cfg.Registry, reg_kwargs)
    ns_kwargs = {'help': 'Namespace under which the repository resides'}
    if docker_cfg.Namespace is not None:
        add_default_arg(docker_cfg.Namespace, ns_kwargs)
    else:
        ns_kwargs['required'] = True
    repo_kwargs = {'help': 'Repository name[:tag]'}
    # TODO: Allow arbitrary repo names and uncomment below code. For now repo
    #       names must match task folder names.
#     if len(repos) == 1 and cwd in repos:
#         repo_kwargs['help'] += ' (default: %(default)s)'
#         repo_kwargs['default'] = os.path.basename(cwd) + ':' + repos[cwd]
    if len(repos) > 0:
        repo_kwargs['choices'] = sorted(os.path.basename(repo) + ':' + version
                                        for repo, version in repos.items())
        if len(repos) > 1:
            repo_kwargs['nargs'] = '*'
        else:
            repo_kwargs['nargs'] = '?'
            repo_kwargs['metavar'] = repo_kwargs['choices'][0]
            repo_kwargs['const'] = repo_kwargs['metavar']
            repo_kwargs['default'] = repo_kwargs['metavar']
    else:
        repo_kwargs['help'] += ''', requires hydrant.cfg file if building
                               multiple images with tags other than "latest"'''
        
    parser = ArgParser(description=Description)

    # Because parser.prog is initialized to the name of the top-level calling
    # module, it needs to be modified here to be consistent.
    # (i.e. so hydrant docker build -h returns a usage that begins with
    # hydrant docker build rather than only hydrant)
    if __name__ != '__main__':
        parser.prog += " " + __name__.rsplit('.', 1)[-1]

    parser.add_argument('-R', '--registry', **reg_kwargs)
    parser.add_argument('-n', '--namespace', **ns_kwargs)
    parser.add_argument('-r', '--repository', **repo_kwargs)
    parser.add_argument('-a', '--all', action='store_true',
                        help="Build all docker images.")

    args = parser.parse_args(args)
    client = connect_to_daemon()
    
    if args.all:
        for repo, version in repos.items():
            tag = get_full_tag(args.registry, args.namespace,
                               os.path.basename(repo), version)
            build_image(client, repo, tag)
    elif args.repository:
        all_repos = {os.path.basename(path): path for path in repos}
        if isinstance(args.repository, list):
            user_repos = [repo.split(':', 1)[0] for repo in args.repository]
            # Only build images if all user-specified ones are available
            build_images = set(user_repos).issubset(set(all_repos.keys()))
            for idx, repo in enumerate(args.repository):
                tag = get_full_tag(args.registry, args.namespace, repo)
                user_repo = user_repos[idx]
                if user_repo in all_repos:
                    if build_images:
                        build_image(client, all_repos[user_repo],
                                    tag)
                else:
                    logging.error("Could not find a path for %s. Please ensure" + \
                                  " the directory containing the Dockerfile " + \
                                  "matches the name of the repository.", tag)
            if not build_images:
                sys.exit(1)
        else:
            tag = get_full_tag(args.registry, args.namespace, args.repository)
            repo = args.repository.split(':', 1)[0]
            build_image(client, all_repos[repo], tag)
    else:
        logging.error("No repository specified.")
        sys.exit(1)