def download(name, output, dashboard_url): """Download the results of a benchmark run""" loaded = setup_client_from_config() client = ApiClient(in_cluster=False, url=dashboard_url, load_config=not loaded) ret = client.get_runs() runs = ret.result().json() run = next(r for r in runs if r['name'] == name) ret = client.download_run_metrics(run['id']) with open(output, 'wb') as f: f.write(ret.result().content)
def status(name, dashboard_url): """Get the status of a benchmark run""" loaded = setup_client_from_config() client = ApiClient(in_cluster=False, url=dashboard_url, load_config=not loaded) ret = client.get_runs() runs = ret.result().json() try: run = next(r for r in runs if r["name"] == name) except StopIteration: click.echo("Run not found") return del run["job_id"] del run["job_metadata"] click.echo(tabulate([run], headers="keys")) loss = client.get_run_metrics(run["id"], metric_filter="val_global_loss @ 0", last_n=1) prec = client.get_run_metrics(run["id"], metric_filter="val_global_Prec@1 @ 0", last_n=1) loss = loss.result() prec = prec.result() if loss.status_code < 300 and "val_global_loss @ 0" in loss.json(): val = loss.json()["val_global_loss @ 0"][0] click.echo("Current Global Loss: {0:.2f} ({1})".format( float(val["value"]), val["date"])) else: click.echo("No Validation Loss Data yet") if prec.status_code < 300 and "val_global_Prec@1 @ 0" in prec.json(): val = prec.json()["val_global_Prec@1 @ 0"][0] click.echo("Current Global Precision: {0:.2f} ({1})".format( float(val["value"]), val["date"])) else: click.echo("No Validation Precision Data yet")
def delete(name, dashboard_url): """Delete a benchmark run""" loaded = setup_client_from_config() client = ApiClient(in_cluster=False, url=dashboard_url, load_config=not loaded) ret = client.get_runs() runs = ret.result().json() try: run = next(r for r in runs if r['name'] == name) except StopIteration: click.echo('Run not found') return del run['job_id'] del run['job_metadata'] client.delete_run(run['id'])