Esempio 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
Esempio n. 2
0
def metadata(ctx: click.Context, output_file: Optional[IO[str]],
             target: List[str]):
    """Get metadata from a given endpoint."""
    client = Client(*ctx.obj["args"], **ctx.obj["kwargs"])
    target_metadata = {
        k: v.dict()  # type: ignore
        for k, v in client.get_metadata(targets=target).items()  # type: ignore
    }
    if output_file:
        json.dump(target_metadata, output_file)
        click.secho(f"Saved metadata json to file: '{output_file}'")
    else:
        pprint(target_metadata)
    return target_metadata