def open_tensorboard(args: Namespace) -> None: tensorboard_id = command.expand_uuid_prefixes(args) resp = api.get( args.master, "api/v1/tensorboards/{}".format(tensorboard_id)).json()["tensorboard"] check_eq(resp["state"], "STATE_RUNNING", "TensorBoard must be in a running state") api.browser_open(args.master, resp["serviceAddress"])
def open_notebook(args: Namespace) -> None: notebook_id = command.expand_uuid_prefixes(args) resp = api.get( args.master, "api/v1/notebooks/{}".format(notebook_id)).json()["notebook"] check_eq(resp["state"], "STATE_RUNNING", "Notebook must be in a running state") api.browser_open(args.master, resp["serviceAddress"])
def start_tensorboard(args: Namespace) -> None: if not (args.trial_ids or args.experiment_ids): print("Either experiment_ids or trial_ids must be specified.") sys.exit(1) config = parse_config(args.config_file, None, args.config, []) req_body = { "config": config, "trial_ids": args.trial_ids, "experiment_ids": args.experiment_ids, } if args.context is not None: req_body["files"], _ = context.read_context(args.context, constants.MAX_CONTEXT_SIZE) resp = api.post(args.master, "api/v1/tensorboards", json=req_body).json()["tensorboard"] if args.detach: print(resp["id"]) return url = "tensorboard/{}/events".format(resp["id"]) with api.ws(args.master, url) as ws: for msg in ws: if msg["log_event"] is not None: # TensorBoard will print a url by default. The URL is incorrect since # TensorBoard is not aware of the master proxy address it is assigned. if "http" in msg["log_event"]: continue if msg["service_ready_event"]: if args.no_browser: url = api.make_url(args.master, resp["serviceAddress"]) else: url = api.browser_open(args.master, resp["serviceAddress"]) print( colored("TensorBoard is running at: {}".format(url), "green")) render_event_stream(msg) break render_event_stream(msg)
def start_notebook(args: Namespace) -> None: config = parse_config(args.config_file, None, args.config, args.volume) files = None if args.context is not None: context = Context.from_local(args.context) files = [ bindings.v1File( content=e.content.decode("utf-8"), gid=e.gid, mode=e.mode, mtime=e.mtime, path=e.path, type=e.type, uid=e.uid, ) for e in context.entries ] body = bindings.v1LaunchNotebookRequest(config, files=files, preview=False) resp = bindings.post_LaunchNotebook(setup_session(args), body=body) if args.preview: print(render.format_object_as_yaml(resp.config)) return nb = resp.notebook if args.detach: print(nb.id) return with api.ws(args.master, "notebooks/{}/events".format(nb.id)) as ws: for msg in ws: if msg["service_ready_event"] and nb.serviceAddress and not args.no_browser: url = api.browser_open(args.master, nb.serviceAddress) print( colored("Jupyter Notebook is running at: {}".format(url), "green")) render_event_stream(msg)