Exemple #1
0
def open_tensorboard(args: Namespace) -> None:
    resp = api.get(args.master,
                   "tensorboard/{}".format(args.tensorboard_id)).json()
    tensorboard = render.unmarshal(Command, resp)
    check_eq(tensorboard.state, "RUNNING",
             "TensorBoard must be in a running state")
    api.open(args.master, resp["service_address"])
Exemple #2
0
def start_tensorboard(args: Namespace) -> None:
    if args.trial_ids is None and args.experiment_ids is None:
        print("Either experiment_ids or trial_ids must be specified.")
        sys.exit(1)

    config = parse_config(args.config_file, None, [], [])
    req_body = {
        "config": config,
        "trial_ids": args.trial_ids,
        "experiment_ids": args.experiment_ids,
    }

    if args.context is not None:
        req_body["user_files"], _ = context.read_context(
            args.context, constants.MAX_CONTEXT_SIZE)

    resp = api.post(args.master, "tensorboard", body=req_body).json()

    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["service_address"])
                else:
                    url = api.open(args.master, resp["service_address"])

                print(
                    colored("TensorBoard is running at: {}".format(url),
                            "green"))
                render_event_stream(msg)
                break
            render_event_stream(msg)
Exemple #3
0
def start_notebook(args: Namespace) -> None:
    config = parse_config(args.config_file, None, args.config, args.volume)

    resp = launch_command(
        args.master,
        "notebooks",
        config,
        args.template,
        context_path=args.context,
    )

    if args.detach:
        print(resp["id"])
        return

    with api.ws(args.master, "notebooks/{}/events".format(resp["id"])) as ws:
        for msg in ws:
            if msg["service_ready_event"] and not args.no_browser:
                url = api.open(args.master, resp["service_address"])
                print(
                    colored("Jupyter Notebook is running at: {}".format(url),
                            "green"))
            render_event_stream(msg)
Exemple #4
0
def open_notebook(args: Namespace) -> None:
    resp = api.get(args.master, "notebooks/{}".format(args.notebook_id)).json()
    notebook = render.unmarshal(Command, resp)
    check_eq(notebook.state, "RUNNING", "Notebook must be in a running state")
    api.open(args.master, resp["service_address"])