def ls(ctx, io, query, sort, limit, offset, columns): """List runs for this project. Uses /docs/core/cli/#caching Examples: Get all runs: \b Get all runs with with status {created or running}, and creation date between 2018-01-01 and 2018-01-02, and params activation equal to sigmoid and metric loss less or equal to 0.2 \b $ polyaxon ops ls \ -q "status:created|running, started_at:2018-01-01..2018-01-02, \ params.activation:sigmoid, metrics.loss:<=0.2" Get all runs sorted by update date: \b $ polyaxon ops ls -s "-updated_at" Get all runs of kind job: \b $ polyaxon ops ls -q "kind: job" Get all runs of kind service: \b $ polyaxon ops ls -q "kind: service" """ owner, project_name = get_project_or_local(ctx.obj.get("project"), is_cli=True) try: polyaxon_client = RunClient(owner=owner, project=project_name) response = polyaxon_client.list( limit=limit, offset=offset, query=query, sort=sort ) except (ApiException, HTTPError) as e: handle_cli_error( e, message="Could not get runs for project `{}`.".format(project_name) ) sys.exit(1) meta = get_meta_response(response) if meta: Printer.print_header("Runs for project `{}/{}`.".format(owner, project_name)) Printer.print_header("Navigation:") dict_tabulate(meta) else: Printer.print_header( "No runs found for project `{}/{}`.".format(owner, project_name) ) objects = [Printer.add_status_color(o.to_dict()) for o in response.results] if io: objects = get_runs_with_keys(objects=objects, params_keys=["inputs", "outputs"]) objects = list_dicts_to_tabulate( objects, include_attrs=validate_tags(columns), exclude_attrs=[ "owner", "project", "description", "content", "raw_content", "deleted", "readme", "settings", "meta_info", "original", "pipeline", "role", "status_conditions", "is_helper", ], ) else: objects = list_dicts_to_tabulate( objects, include_attrs=validate_tags(columns), exclude_attrs=[ "owner", "project", "description", "content", "raw_content", "deleted", "readme", "inputs", "outputs", "settings", "meta_info", "original", "pipeline", "role", "status_conditions", "is_helper", ], ) if objects: Printer.print_header("Runs:") objects.pop("project_name", None) dict_tabulate(objects, is_list_dict=True)
def ls(ctx, io, query, sort, limit, offset): """List runs for this project. Uses [Caching](/references/polyaxon-cli/#caching) Examples: Get all runs: \b ```bash $ polyaxon project runs ``` Get all runs with with status {created or running}, and creation date between 2018-01-01 and 2018-01-02, and params activation equal to sigmoid and metric loss less or equal to 0.2 \b ```bash $ polyaxon project runs \ -q "status:created|running, started_at:2018-01-01..2018-01-02, \ params.activation:sigmoid, metric.loss:<=0.2" ``` Get all runs sorted by update date \b ```bash $ polyaxon project runs -s "-updated_at" ``` """ owner, project_name = get_project_or_local(ctx.obj.get("project")) try: polyaxon_client = PolyaxonClient() params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) response = polyaxon_client.runs_v1.list_runs(owner=owner, project=project_name, **params) except (ApiException, HTTPError) as e: handle_cli_error(e, message="Could not get runs for project `{}`.".format( project_name)) sys.exit(1) meta = get_meta_response(response) if meta: Printer.print_header("Experiments for project `{}/{}`.".format( owner, project_name)) Printer.print_header("Navigation:") dict_tabulate(meta) else: Printer.print_header("No runs found for project `{}/{}`.".format( owner, project_name)) objects = [Printer.add_status_color(o.to_dict()) for o in response.results] if io: objects = get_runs_with_keys(objects=objects, params_keys=["inputs", "outputs"]) objects = list_dicts_to_tabulate( objects, exclude_attrs=[ "owner", "project", "description", "content", "deleted", "readme", "run_env", ], ) else: objects = list_dicts_to_tabulate( objects, exclude_attrs=[ "owner", "project", "description", "content", "deleted", "readme", "run_env", "inputs", "outputs", ], ) if objects: Printer.print_header("Runs:") objects.pop("project_name", None) dict_tabulate(objects, is_list_dict=True)