tensorflow / tensorboard

TensorFlow's Visualization Toolkit
Apache License 2.0
6.68k stars 1.65k forks source link

ipython; set iframe source via parameters; SageMaker notebook magic support #3632

Open yegortokmakov opened 4 years ago

yegortokmakov commented 4 years ago

I'm using hosted notebooks on SageMaker and accessing them on https://xxxxx.notebook.eu-west-1.sagemaker.aws/notebooks/shallowlearning.ipynb.

I'm starting TB in ipython context with these commands:

%load_ext tensorboard
%tensorboard --logdir s3://xxxx/shallowlearning/logs

Generated iframe has url https://xxxxx.notebook.eu-west-1.sagemaker.aws:6006/ but exposing dynamic ports publicly is not allowed by SageMaker (and I would expect by other hosted notebook providers too). As a workaround SageMaker provides proxy, so TB could be accessed on https://xxxxx.notebook.eu-west-1.sagemaker.aws/proxy/6006/.

Would be nice to have possibility to have parameters display_port and display_hostname to override default variables in https://github.com/tensorflow/tensorboard/blob/master/tensorboard/notebook.py#L381

Let me know if you would welcome PR for this feature.

stephanwlee commented 4 years ago

but exposing dynamic ports publicly is not allowed by SageMaker

So, is there a static ports available publicly? Is there a documentation that we can refer to?

I think you can achieve what you want by using combination of port and path_prefix without introducing new flags.

From tensorboard --help

  --port PORT           Port to serve TensorBoard on. Pass 0 to request an
                        unused port selected by the operating system, or pass
                        "default" to try to bind to the default port (6006)
                        but search for a nearby free port if the default port
                        is unavailable. (default: "default").
...
  --path_prefix PATH    An optional, relative prefix to the path, e.g.
                        "/path/to/tensorboard". resulting in the new base url
                        being located at localhost:6006/path/to/tensorboard
                        under default settings. A leading slash is required
                        when specifying the path_prefix. A trailing slash is
                        optional and has no effect. The path_prefix can be
                        leveraged for path based routing of an ELB when the
                        website base_url is not available e.g.
                        "example.site.com/path/to/tensorboard/".

I guess path_prefix is not propagated to _display and _display_ipython.

wchargin commented 4 years ago

I guess path_prefix is not propagated to _display and _display_ipython.

Correct; we considered doing this and decided that it was simpler to omit it and just not pass %tensorboard --path_prefix. See “§” note: https://github.com/tensorflow/tensorboard/blob/master/docs/design/colab_integration.md#high-level-changes-and-apis.

yegortokmakov commented 4 years ago

@stephanwlee yes, it's not propagated and even if it was, I still would need a separate pair of controls: I need tensorboard to still use localhost and port 80, but iframe to point to a different url.

@wchargin I've read the design doc, but seems like solution for SageMaker might be a bit easier. I thought about adding an additional parameter for _display and do const url = new URL("/", propogated_iframe_location or window.location); and something similar for the port number.

But now that you pointed me to Colab doc, it seems like adding a new context in a similar way to Colab is the easiest option.

yegortokmakov commented 3 years ago

any update on this one?