def service(ctx, yes, external, url): """Open the operation service in browser. N.B. The operation must have a run kind service, otherwise it will raise an error. You can open the service embedded in Polyaxon UI or using the real service URL, please use the `--external` flag. """ owner, project_name, run_uuid = get_project_run_or_local( ctx.obj.get("project"), ctx.obj.get("run_uuid"), is_cli=True, ) client = RunClient(owner=owner, project=project_name, run_uuid=run_uuid) client.refresh_data() if client.run_data.kind != V1RunKind.SERVICE: Printer.print_warning("Command expected a operations of " "kind `service` received kind: {}!".format( client.run_data.kind)) sys.exit(1) dashboard_url = settings.CLIENT_CONFIG.host Printer.print_header("Waiting for running condition ...") client.wait_for_condition(statuses=[V1Statuses.RUNNING], print_status=True) client.refresh_data() namespace = client.run_data.settings.namespace run_url = "{}/{}/{}/runs/{}/service".format(dashboard_url, owner, project_name, run_uuid) service_endpoint = SERVICES_V1 if client.run_data.meta_info.get("rewrite_path", False): service_endpoint = REWRITE_SERVICES_V1 external_run_url = "{}/{}/{}/{}/{}/runs/{}/".format( dashboard_url, service_endpoint, namespace, owner, project_name, run_uuid) if url: Printer.print_header( "The service will be available at: {}".format(run_url)) Printer.print_header( "You can also view it in an external link at: {}".format( external_run_url)) sys.exit(0) if not yes: click.confirm( "Dashboard page will now open in your browser. Continue?", abort=True, default=True, ) if external: click.launch(external_run_url) sys.exit(0) click.launch(run_url)
def get(ctx, project, uid): """Get run. Uses /docs/core/cli/#caching Examples for getting a run: \b $ polyaxon ops get # if run is cached \b $ polyaxon ops get --uid=8aac02e3a62a4f0aaa257c59da5eab80 # project is cached \b $ polyaxon ops get --project=cats-vs-dogs -uid 8aac02e3a62a4f0aaa257c59da5eab80 \b $ polyaxon ops get -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80 """ owner, project_name, run_uuid = get_project_run_or_local( project or ctx.obj.get("project"), uid or ctx.obj.get("run_uuid"), is_cli=True, ) try: polyaxon_client = RunClient(owner=owner, project=project_name, run_uuid=run_uuid) polyaxon_client.refresh_data() config = polyaxon_client.client.sanitize_for_serialization( polyaxon_client.run_data) cache.cache( config_manager=RunConfigManager, config=config, owner=owner, project=project_name, ) except (ApiException, HTTPError) as e: handle_cli_error( e, message="Could not load run `{}/{}/{}` info.".format( owner, project_name, run_uuid), ) sys.exit(1) get_run_details(polyaxon_client.run_data)
def get(ctx): """Get run. Uses [Caching](/references/polyaxon-cli/#caching) Examples for getting a run: \b ```bash $ polyaxon runs get # if run is cached ``` \b ```bash $ polyaxon runs --uid=8aac02e3a62a4f0aaa257c59da5eab80 get # project is cached ``` \b ```bash $ polyaxon runs --project=cats-vs-dogs -id 8aac02e3a62a4f0aaa257c59da5eab80 get ``` \b ```bash $ polyaxon runs -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80 get ``` """ owner, project_name, run_uuid = get_project_run_or_local( ctx.obj.get("project"), ctx.obj.get("run_uuid"), is_cli=True) try: polyaxon_client = RunClient(owner=owner, project=project_name, run_uuid=run_uuid) polyaxon_client.refresh_data() config = polyaxon_client.client.sanitize_for_serialization( polyaxon_client.run_data) cache.cache(config_manager=RunManager, config=config) except (ApiException, HTTPError) as e: handle_cli_error( e, message="Could not load run `{}` info.".format(run_uuid)) sys.exit(1) get_run_details(polyaxon_client.run_data)
def service(ctx, yes, external, url): """Open the operation service in browser. N.B. The operation must have a run kind service, otherwise it will raise an error. You can open the service embedded in Polyaxon UI or using the real service URL, please use the `--external` flag. """ owner, project_name, run_uuid = get_project_run_or_local( ctx.obj.get("project"), ctx.obj.get("run_uuid"), is_cli=True, ) client = RunClient(owner=owner, project=project_name, run_uuid=run_uuid) client.refresh_data() if client.run_data.kind != V1RunKind.SERVICE: Printer.print_warning( "Command expected an operation of " "kind `service` received kind: `{}`!".format(client.run_data.kind) ) sys.exit(1) Printer.print_header("Waiting for running condition ...") client.wait_for_condition( statuses={V1Statuses.RUNNING} | LifeCycle.DONE_VALUES, print_status=True ) client.refresh_data() if LifeCycle.is_done(client.run_data.status): Printer.print_header("The operations reached a done statuses.") latest_status = Printer.add_status_color( {"status": client.run_data.status}, status_key="status" ) click.echo("{}\n".format(latest_status["status"])) run_url = get_dashboard_url( subpath="{}/{}/runs/{}/service".format(owner, project_name, run_uuid) ) namespace = client.run_data.settings.namespace service_endpoint = SERVICES_V1 if client.run_data.meta_info.get("rewrite_path", False): service_endpoint = REWRITE_SERVICES_V1 external_run_url = get_dashboard_url( base=service_endpoint, subpath="{}/{}/{}/runs/{}/".format(namespace, owner, project_name, run_uuid), ) if url: Printer.print_header("The service will be available at: {}".format(run_url)) Printer.print_header( "You can also view it in an external link at: {}".format(external_run_url) ) sys.exit(0) if not yes: click.confirm( "Dashboard page will now open in your browser. Continue?", abort=True, default=True, ) if external: click.launch(external_run_url) sys.exit(0) click.launch(run_url)
def get(ctx, project, uid, offline, offline_path): """Get run. Uses /docs/core/cli/#caching Examples for getting a run: \b $ polyaxon ops get # if run is cached \b $ polyaxon ops get --uid=8aac02e3a62a4f0aaa257c59da5eab80 # project is cached \b $ polyaxon ops get --project=cats-vs-dogs -uid 8aac02e3a62a4f0aaa257c59da5eab80 \b $ polyaxon ops get -p alain/cats-vs-dogs --uid=8aac02e3a62a4f0aaa257c59da5eab80 """ uid = uid or ctx.obj.get("run_uuid") if offline: offline_path = offline_path or container_contexts.CONTEXT_OFFLINE_ROOT offline_path = "{}/{}/run_data.json".format(offline_path, uid) if not os.path.exists(offline_path): Printer.print_error( f"Could not get offline run, the path `{offline_path}` " f"does not exist.") sys.exit(1) run_data = RunConfigManager.read_from_path(offline_path) else: owner, project_name, run_uuid = get_project_run_or_local( project or ctx.obj.get("project"), uid, is_cli=True, ) try: polyaxon_client = RunClient(owner=owner, project=project_name, run_uuid=run_uuid) polyaxon_client.refresh_data() config = polyaxon_client.client.sanitize_for_serialization( polyaxon_client.run_data) cache.cache( config_manager=RunConfigManager, config=config, owner=owner, project=project_name, ) run_data = polyaxon_client.run_data except (ApiException, HTTPError) as e: handle_cli_error( e, message="Could not load run `{}/{}/{}` info.".format( owner, project_name, run_uuid), ) sys.exit(1) get_run_details(run_data)