Fix for Captum to be served in Colab notebooks#255
Conversation
|
This pull request was exported from Phabricator. Differential Revision: D19590439 |
3ad466a to
e9f6fa0
Compare
Summary: Pull Request resolved: meta-pytorch#255 This change uses TensorBoard's example of Colab serving to support serving Captum Insights in Colab. The main changes are: - Display a script in Colab which does the following upon execution - Set the base URL to localhost:PORT where PORT is the port that the Insights server is using (this ensures requests are directed properly) - Fetch "." and get the HTML response - Insert the HTML into the DOM - For each script and css file in the HTML, remove and reinsert them in DOM to force them to be loaded. - Replace request.json with request.get_json(force=True). This is necessary since Colab doesn't respect Content-Type header when forwarding requests through proxy, and force=True forces the request body to be parsed as JSON Reviewed By: edward-io Differential Revision: D19590439 fbshipit-source-id: fc5cad83780db35076071555318abfc5b746b620
|
This pull request was exported from Phabricator. Differential Revision: D19590439 |
|
All failures are due to linter error: However, we need to import google.colab in order to test for notebook context. All changes have been retested in Colab, and the widget functions properly. |
| # returned by `IPython.get_ipython` does not have a `get_trait` | ||
| # method. | ||
| try: | ||
| import google.colab |
There was a problem hiding this comment.
We can add # noqa: F401 to the end of the import line to silence linter errors.
Summary: Pull Request resolved: meta-pytorch#255 This change uses TensorBoard's example of Colab serving to support serving Captum Insights in Colab. The main changes are: - Display a script in Colab which does the following upon execution - Set the base URL to localhost:PORT where PORT is the port that the Insights server is using (this ensures requests are directed properly) - Fetch "." and get the HTML response - Insert the HTML into the DOM - For each script and css file in the HTML, remove and reinsert them in DOM to force them to be loaded. - Replace request.json with request.get_json(force=True). This is necessary since Colab doesn't respect Content-Type header when forwarding requests through proxy, and force=True forces the request body to be parsed as JSON Reviewed By: edward-io Differential Revision: D19590439 fbshipit-source-id: 40f4d951256f36390f28bcfa10e0751938054dbc
e9f6fa0 to
cb0d726
Compare
|
This pull request was exported from Phabricator. Differential Revision: D19590439 |
Summary: Pull Request resolved: meta-pytorch#255 This change uses TensorBoard's example of Colab serving to support serving Captum Insights in Colab. The main changes are: - Display a script in Colab which does the following upon execution - Set the base URL to localhost:PORT where PORT is the port that the Insights server is using (this ensures requests are directed properly) - Fetch "." and get the HTML response - Insert the HTML into the DOM - For each script and css file in the HTML, remove and reinsert them in DOM to force them to be loaded. - Replace request.json with request.get_json(force=True). This is necessary since Colab doesn't respect Content-Type header when forwarding requests through proxy, and force=True forces the request body to be parsed as JSON Reviewed By: edward-io Differential Revision: D19590439 fbshipit-source-id: 1cbd835e51cd31ea8287335c3234b16f506b719b
cb0d726 to
f82fcb3
Compare
|
This pull request was exported from Phabricator. Differential Revision: D19590439 |
Summary: Pull Request resolved: meta-pytorch#255 This change uses TensorBoard's example of Colab serving to support serving Captum Insights in Colab. The main changes are: - Display a script in Colab which does the following upon execution - Set the base URL to localhost:PORT where PORT is the port that the Insights server is using (this ensures requests are directed properly) - Fetch "." and get the HTML response - Insert the HTML into the DOM - For each script and css file in the HTML, remove and reinsert them in DOM to force them to be loaded. - Replace request.json with request.get_json(force=True). This is necessary since Colab doesn't respect Content-Type header when forwarding requests through proxy, and force=True forces the request body to be parsed as JSON Reviewed By: edward-io Differential Revision: D19590439 fbshipit-source-id: 51893cd6f77aa6fd77f19e70c946cdefe2895f33
f82fcb3 to
2011099
Compare
|
This pull request was exported from Phabricator. Differential Revision: D19590439 |
|
This pull request has been merged in 22cb33b. |
Summary: Pull Request resolved: meta-pytorch#255 This change uses TensorBoard's example of Colab serving to support serving Captum Insights in Colab. The main changes are: - Display a script in Colab which does the following upon execution - Set the base URL to localhost:PORT where PORT is the port that the Insights server is using (this ensures requests are directed properly) - Fetch "." and get the HTML response - Insert the HTML into the DOM - For each script and css file in the HTML, remove and reinsert them in DOM to force them to be loaded. - Replace request.json with request.get_json(force=True). This is necessary since Colab doesn't respect Content-Type header when forwarding requests through proxy, and force=True forces the request body to be parsed as JSON Reviewed By: edward-io Differential Revision: D19590439 fbshipit-source-id: 53d2180321ceb710ac2c06d0859c4913f4d01040
Summary:
This change uses TensorBoard's example of Colab serving to support serving Captum Insights in Colab. The main changes are:
Differential Revision: D19590439