def list_children(self, query: str = None, sort: str = None, limit: int = None, offset: int = None): """Lists run's children if the current run has a pipeline. [Run API](/docs/api/#operation/ListRuns) Args: query: str, optional, query filters, please refer to [Project PQL](/docs/core/query-syntax/runs/#query) sort: str, optional, fields to order by, please refer to [Project PQL](/docs/core/query-syntax/runs/#sort) limit: int, optional, limit of runs to return. offset: int, optional, offset pages to paginate runs. Returns: List[V1Run], list of run instances. """ params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) query = params.get("query") query = query + "&" if query else "?" query += "pipeline={}".format(self.run_uuid) params["query"] = query return self.client.runs_v1.list_runs(self.owner, self.project, **params)
def list(self, query: str = None, sort: str = None, limit: int = None, offset: int = None): """Lists projects under the current owner. [Project API](/docs/api/#operation/ListProjects) Args: query: str, optional, query filters, please refer to [Project PQL](/docs/core/query-language/projects/#query) sort: str, optional, fields to order by, please refer to [Project PQL](/docs/core/query-language/projects/#sort) limit: int, optional, limit of projects to return. offset: int, optional, offset pages to paginate projects. Returns: List[V1Project], list of project instances. """ params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) return self.client.projects_v1.list_projects(self.owner, **params)
def list(self, query: str = None, sort: str = None, limit: int = None, offset: int = None): """Lists runs under the current owner - project. [Run API](/docs/api/#operation/ListRuns) Args: query: str, optional, query filters, please refer to [Project PQL](/docs/core/query-syntax/runs/#query) sort: str, optional, fields to order by, please refer to [Project PQL](/docs/core/query-syntax/runs/#sort) limit: int, optional, limit of runs to return. offset: int, optional, offset pages to paginate runs. Returns: List[V1Run], list of run instances. """ params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) return self.client.runs_v1.list_runs(self.owner, self.project, **params)
def list_children( self, query: str = None, sort: str = None, limit: int = None, offset: int = None ): params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) query = params.get("query") query = query + "&" if query else "?" query += "pipeline={}".format(self.run_uuid) params["query"] = query return self.client.runs_v1.list_runs(self.owner, self.project, **params)
def list(self, query: str = None, sort: str = None, limit: int = None, offset: int = None): params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) return self.client.projects_v1.list_projects(self.owner, **params)
def runs(ctx, limit, offset): """List bookmarked runs for user. Uses [Caching](/references/polyaxon-cli/#caching) Examples: \b ```bash $ polyaxon bookmark experiments ``` \b ```bash $ polyaxon bookmark -u adam experiments ``` """ user = get_username_or_local(ctx.obj.get("username")) try: params = get_query_params(limit=limit, offset=offset) polyaxon_client = PolyaxonClient() response = polyaxon_client.runs_v1.list_bookmarked_runs(user, **params) except (ApiException, HTTPError) as e: handle_cli_error( e, message="Could not get bookmarked experiments for user `{}`.".format(user), ) sys.exit(1) meta = get_meta_response(response) if meta: Printer.print_header("Bookmarked experiments for user `{}`.".format(user)) Printer.print_header("Navigation:") dict_tabulate(meta) else: Printer.print_header( "No bookmarked experiments found for user `{}`.".format(user) ) objects = [ Printer.add_status_color(o.to_light_dict(humanize_values=True)) for o in response.results ] objects = list_dicts_to_tabulate(objects) if objects: Printer.print_header("Experiments:") dict_tabulate(objects, is_list_dict=True)
def list_versions(): component_info = "<owner: {}> <component: {}>".format( owner, component_hub) try: polyaxon_client = get_current_or_public_client() params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) response = polyaxon_client.component_hub_v1.list_component_versions( owner, component_hub, **params) except (ApiException, HTTPError) as e: message = "Could not get list of component version." handle_cli_error(e, message=message) sys.exit(1) meta = get_meta_response(response) if meta: Printer.print_header("Versions for {}".format(component_info)) Printer.print_header("Navigation:") dict_tabulate(meta) else: Printer.print_header( "No version found for {}".format(component_info)) objects = list_dicts_to_tabulate( [o.to_dict() for o in response.results], humanize_values=True, exclude_attrs=[ "uuid", "readme", "description", "owner", "owner", "role", "settings", "content", "live_state", ], ) if objects: Printer.print_header("Component versions:") dict_tabulate(objects, is_list_dict=True)
def list_models(): try: polyaxon_client = PolyaxonClient() params = get_query_params(limit=limit, offset=offset, query=query, sort=sort) response = polyaxon_client.model_registry_v1.list_model_registries( owner, **params) except (ApiException, HTTPError) as e: message = "Could not get list of models." handle_cli_error(e, message=message) sys.exit(1) meta = get_meta_response(response) if meta: Printer.print_header("Models for owner {}".format(owner)) Printer.print_header("Navigation:") dict_tabulate(meta) else: Printer.print_header( "No model registry found for owner {}".format(owner)) objects = list_dicts_to_tabulate( [o.to_dict() for o in response.results], humanize_values=True, exclude_attrs=[ "uuid", "readme", "description", "owner", "role", "settings", "live_state", ], ) if objects: Printer.print_header("Models:") dict_tabulate(objects, is_list_dict=True)
def ls(owner, limit, offset): """List projects. Uses [Caching](/references/polyaxon-cli/#caching) """ owner = owner or AuthConfigManager.get_value("username") if not owner: Printer.print_error( "Please login first or provide a valid owner --owner. " "`polyaxon login --help`") sys.exit(1) try: params = get_query_params(limit=limit, offset=offset) polyaxon_client = PolyaxonClient() response = polyaxon_client.projects_v1.list_projects(owner, **params) except (ApiException, HTTPError) as e: handle_cli_error(e, message="Could not get list of projects.") sys.exit(1) meta = get_meta_response(response) if meta: Printer.print_header("Projects for current user") Printer.print_header("Navigation:") dict_tabulate(meta) else: Printer.print_header("No projects found for current user") objects = list_dicts_to_tabulate( [o.to_dict() for o in response.results], humanize_values=True, exclude_attrs=["uuid", "description"], ) if objects: Printer.print_header("Projects:") 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)