Exemplo n.º 1
0
def test_client_get_metadata(gordo_project, ml_server):
    """
    Test client's ability to get metadata from some target
    """
    client = Client(project=gordo_project)

    metadata = client.get_metadata()
    assert isinstance(metadata, dict)

    # Can't get metadata for non-existent target
    assert client.get_metadata().get("no-such-target", None) is None
Exemplo n.º 2
0
def metadata(
    ctx: click.Context,
    output_file: typing.Optional[typing.IO[str]],
    target: typing.List[str],
):
    """
    Get metadata from a given endpoint
    """
    client = Client(*ctx.obj["args"], **ctx.obj["kwargs"])
    metadata = {
        k: v.to_dict() for k, v in client.get_metadata(targets=target).items()  # type: ignore
    }
    if output_file:
        json.dump(metadata, output_file)
        click.secho(f"Saved metadata json to file: '{output_file}'")
    else:
        pprint(metadata)
    return metadata