Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions captum/insights/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ def render(self, debug=True):
def serve(self, blocking=False, debug=False, port=None):
context = _get_context()
if context == _CONTEXT_COLAB:
self._serve_colab(blocking=blocking, debug=debug, port=port)
return self._serve_colab(blocking=blocking, debug=debug, port=port)
else:
self._serve(blocking=blocking, debug=debug, port=port)
return self._serve(blocking=blocking, debug=debug, port=port)

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

start_server(self, blocking=blocking, debug=debug, _port=port)
return start_server(self, blocking=blocking, debug=debug, _port=port)

def _serve_colab(self, blocking=False, debug=False, port=None):
from IPython.display import display, HTML
Expand Down
1 change: 1 addition & 0 deletions captum/insights/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "frontend",
"version": "0.2.0",
"private": true,
"homepage": ".",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this necessary to get relative paths working?

Copy link
Contributor Author

@edward-io edward-io Mar 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this rewrites the urls from /something.css to ./something.css, so it doesn't try to access the url root (if the app was hosted on example.com/proxy/1234/ it would correctly access it in example.com/proxy/1234/something.css instead of example.com/something.css.

"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"babel-loader": "^8.0.6",
Expand Down
6 changes: 3 additions & 3 deletions captum/insights/frontend/src/WebApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class WebApp extends React.Component {
}

_fetchInit = () => {
fetch("/init")
fetch("init")
.then(r => r.json())
.then(r => this.setState({ config: r }));
};

fetchData = filter_config => {
this.setState({ loading: true });
fetch("/fetch", {
fetch("fetch", {
method: "POST",
headers: {
"Content-Type": "application/json"
Expand All @@ -36,7 +36,7 @@ class WebApp extends React.Component {
};

onTargetClick = (labelIndex, instance, callback) => {
fetch("/attribute", {
fetch("attribute", {
method: "POST",
headers: {
"Content-Type": "application/json"
Expand Down
2 changes: 1 addition & 1 deletion captum/insights/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def start_server(
app.logger.disabled = True

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

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