Exemplo n.º 1
0
Arquivo: cli.py Projeto: kant/zpy
def get_dataset(name, dtype, path):
    config = read_config()
    dir_path = to_pathlib_path(path)
    if not dir_path.exists():
        log.info(f'output path {dir_path} does not exist')
        return
    fetch_dataset(name, path, dtype, config['ENDPOINT'], config['TOKEN'])
Exemplo n.º 2
0
Arquivo: cli.py Projeto: swpecht/zpy
def config():
    """display config

    Display current configuration file to developer.
    """
    pretty_config = json.dumps(read_config(), indent=2)
    click.echo(f"Zpy cli configuration:\n{pretty_config}")
Exemplo n.º 3
0
Arquivo: cli.py Projeto: kant/zpy
def upload_dataset(name, path):
    config = read_config()
    input_path = to_pathlib_path(path)
    if not input_path.exists():
        log.info(f'input path {input_path} does not exist')
        return
    if input_path.suffix != '.zip':
        log.warning(f'input path {input_path} not a zip file')
    create_uploaded_dataset(name, path, config['ENDPOINT'], config['TOKEN'])
Exemplo n.º 4
0
Arquivo: cli.py Projeto: kant/zpy
def create_job(name, operation, datasets, filters, configfile, args):
    config = read_config()
    if configfile:
        job_config = read_json(configfile)
    else:
        job_config = parse_args(args)
    datasets_list = [x for x in datasets]
    for dfilter in filters:
        datasets_list.extend(
            filter_dataset(dfilter, config['ENDPOINT'], config['TOKEN']))
    create_new_job(name, operation, job_config, datasets_list,
                   config['ENDPOINT'], config['TOKEN'])
Exemplo n.º 5
0
Arquivo: cli.py Projeto: swpecht/zpy
def env(env):
    """switch target environment

    This command allows zumo labs developers to swap the endpoint that the
    cli communicates with. Unlikely to be relevant for non-zumo devs.

    Args:
        env (str): new environment for endpoint
    """
    config = read_config()
    old_env, old_endpoint = config["ENVIRONMENT"], config["ENDPOINT"]
    config["ENVIRONMENT"] = env
    config["ENDPOINT"] = get_endpoint(env)
    config["TOKEN"] = None
    write_config(config)
    click.echo("Swapped environment:")
    click.echo(f"  {old_env} -> {config['ENVIRONMENT']}")
    click.echo(f"  {old_endpoint} -> {config['ENDPOINT']}")
    click.echo("zpy login to fetch token")
Exemplo n.º 6
0
Arquivo: cli.py Projeto: swpecht/zpy
def login(username, password):
    """login to ragnarok

    This command will update the zpy config with a token that is fetched
    from the backend using account details.

    Accounts can be created at: app.zumolabs.ai

    Args:
        username (str): developer username
        password (str): developer password
    """
    config = read_config()
    endpoint = f"{config['ENDPOINT']}/auth/login/"
    r = requests.post(endpoint, auth=HTTPBasicAuth(username, password))
    if r.status_code != 200:
        click.secho("Login failed.", err=True, fg="red")
        return
    config["TOKEN"] = r.json()["token"]
    write_config(config)
    click.echo("Login successful!")
Exemplo n.º 7
0
 def wrapper(*args, **kwargs):
     config = read_config()
     endpoint = config['ENDPOINT']
     auth_header = auth_headers(config['TOKEN'])
     return func(*args, **kwargs, url=endpoint, auth_headers=auth_header)
Exemplo n.º 8
0
Arquivo: cli.py Projeto: kant/zpy
def list_jobs():
    config = read_config()
    fetch_jobs(config['ENDPOINT'], config['TOKEN'])
Exemplo n.º 9
0
Arquivo: cli.py Projeto: kant/zpy
def list_scenes():
    config = read_config()
    fetch_scenes(config['ENDPOINT'], config['TOKEN'])
Exemplo n.º 10
0
Arquivo: cli.py Projeto: kant/zpy
def list_datasets():
    config = read_config()
    fetch_datasets(config['ENDPOINT'], config['TOKEN'])
Exemplo n.º 11
0
Arquivo: cli.py Projeto: kant/zpy
def _config():
    """ display config """
    config = read_config()
    log.info('zpy cli configuration:')
    log.info(config)
Exemplo n.º 12
0
Arquivo: cli.py Projeto: kant/zpy
def create_dataset(name, scene, args):
    config = read_config()
    dataset_config = parse_args(args)
    create_generated_dataset(name, scene, dataset_config, config['ENDPOINT'],
                             config['TOKEN'])
Exemplo n.º 13
0
Arquivo: utils.py Projeto: swpecht/zpy
 def wrapper(*args, **kwargs):
     config = read_config()
     endpoint = config["ENDPOINT"]
     auth_header = {"Authorization": "token {}".format(config["TOKEN"])}
     return func(*args, **kwargs, url=endpoint, auth_headers=auth_header)