Skip to content

Commit 465dbaf

Browse files
edward-iofacebook-github-bot
authored andcommitted
Use relative paths for Insights (#312)
Summary: This change allows Insights to work with [Jupyter server proxy](https://github.com/jupyterhub/jupyter-server-proxy). However, Sagemaker is broken due to https://forums.aws.amazon.com/message.jspa?messageID=914445#914445. Pull Request resolved: #312 Reviewed By: vivekmig Differential Revision: D20252333 Pulled By: edward-io fbshipit-source-id: f90cfd9dab46a479319774dbf6263d75e92a9be1
1 parent 37555ab commit 465dbaf

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

captum/insights/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ def render(self, debug=True):
256256
def serve(self, blocking=False, debug=False, port=None):
257257
context = _get_context()
258258
if context == _CONTEXT_COLAB:
259-
self._serve_colab(blocking=blocking, debug=debug, port=port)
259+
return self._serve_colab(blocking=blocking, debug=debug, port=port)
260260
else:
261-
self._serve(blocking=blocking, debug=debug, port=port)
261+
return self._serve(blocking=blocking, debug=debug, port=port)
262262

263263
def _serve(self, blocking=False, debug=False, port=None):
264264
from captum.insights.server import start_server
265265

266-
start_server(self, blocking=blocking, debug=debug, _port=port)
266+
return start_server(self, blocking=blocking, debug=debug, _port=port)
267267

268268
def _serve_colab(self, blocking=False, debug=False, port=None):
269269
from IPython.display import display, HTML

captum/insights/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "frontend",
33
"version": "0.2.0",
44
"private": true,
5+
"homepage": ".",
56
"dependencies": {
67
"@babel/plugin-proposal-class-properties": "^7.5.5",
78
"babel-loader": "^8.0.6",

captum/insights/frontend/src/WebApp.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ class WebApp extends React.Component {
1717
}
1818

1919
_fetchInit = () => {
20-
fetch("/init")
20+
fetch("init")
2121
.then(r => r.json())
2222
.then(r => this.setState({ config: r }));
2323
};
2424

2525
fetchData = filter_config => {
2626
this.setState({ loading: true });
27-
fetch("/fetch", {
27+
fetch("fetch", {
2828
method: "POST",
2929
headers: {
3030
"Content-Type": "application/json"
@@ -36,7 +36,7 @@ class WebApp extends React.Component {
3636
};
3737

3838
onTargetClick = (labelIndex, instance, callback) => {
39-
fetch("/attribute", {
39+
fetch("attribute", {
4040
method: "POST",
4141
headers: {
4242
"Content-Type": "application/json"

captum/insights/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ def start_server(
9191
app.logger.disabled = True
9292

9393
port = _port or get_free_tcp_port()
94-
print(f"\nFetch data and view Captum Insights at http://localhost:{port}/\n")
9594
# Start in a new thread to not block notebook execution
9695
t = threading.Thread(target=run_app, kwargs={"debug": debug})
9796
t.start()
9897
sleep(0.01) # add a short delay to allow server to start up
9998
if blocking:
10099
t.join()
101100

101+
print(f"\nFetch data and view Captum Insights at http://localhost:{port}/\n")
102102
return port

0 commit comments

Comments
 (0)