Skip to content

Commit 485bbbb

Browse files
edward-iofacebook-github-bot
authored andcommitted
disable js map files to reduce package size (#556)
Summary: - Clean up some JS warnings - remove unpkg - switch to plotlyjs-basic-dist-min Pull Request resolved: #556 Reviewed By: NarineK Differential Revision: D25506078 Pulled By: edward-io fbshipit-source-id: f133975579c1ab3376f243499aca6520aafbb568
1 parent d5a2437 commit 485bbbb

11 files changed

+13
-56
lines changed

captum/insights/attr_vis/frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"babel-loader": "^8.0.6",
1717
"css-loader": "3.3.0",
1818
"js-levenshtein": "^1.1.6",
19-
"plotly.js-basic-dist": "^1.53.0",
19+
"plotly.js-basic-dist-min": "^1.58.2",
2020
"react": "^16.9.0",
2121
"react-dom": "^16.9.0",
2222
"react-plotly.js": "^2.4.0",

captum/insights/attr_vis/frontend/src/App.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Header from "./components/Header";
44
import cx from "./utils/cx";
55
import Spinner from "./components/Spinner";
66
import FilterContainer from "./components/FilterContainer";
7-
import Visualization from "./components/Visualization";
87
import VisualizationGroupDisplay from "./components/VisualizationGroup";
98
import "./App.css";
109
import { VisualizationGroup } from "./models/visualizationOutput";

captum/insights/attr_vis/frontend/src/components/Plot.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import createPlotlyComponent from "react-plotly.js/factory";
2-
import Plotly from "plotly.js-basic-dist";
2+
import Plotly from "plotly.js-basic-dist-min";
33

44
const Plot = createPlotlyComponent(Plotly);
55

captum/insights/attr_vis/frontend/src/components/Visualization.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class Visualization extends React.Component<
4747
//TODO: Refactor the visualization table as a <table> instead of columns, in order to have cleaner styling
4848
render() {
4949
const data = this.props.data;
50-
const isFirstInGroup = this.props.data.model_index == 0;
51-
console.log("visualization", data);
50+
const isFirstInGroup = this.props.data.model_index === 0;
5251
const features = data.feature_outputs.map((f) => (
5352
<Feature data={f} hideHeaders={isFirstInGroup} />
5453
));
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
declare module "plotly.js-basic-dist";
1+
declare module "plotly.js-basic-dist-min";

captum/insights/attr_vis/frontend/widget/webpack.config.js

-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var path = require("path");
2-
var version = require("../package.json").version;
32

43
// Custom webpack rules are generally the same for all webpack bundles, hence
54
// stored in a separate local variable.
@@ -73,44 +72,6 @@ module.exports = [
7372
path: path.resolve(__dirname, "..", "..", "widget", "static"),
7473
libraryTarget: "amd",
7574
},
76-
devtool: "source-map",
77-
module: {
78-
rules: rules,
79-
},
80-
resolveLoader: {
81-
modules: ["../node_modules"],
82-
},
83-
resolve: {
84-
modules: ["../node_modules"],
85-
extensions: extensions,
86-
},
87-
externals: ["@jupyter-widgets/base"],
88-
},
89-
{
90-
// Embeddable jupyter-captum-insights bundle
91-
//
92-
// This bundle is generally almost identical to the notebook bundle
93-
// containing the custom widget views and models.
94-
//
95-
// The only difference is in the configuration of the webpack public path
96-
// for the static assets.
97-
//
98-
// It will be automatically distributed by unpkg to work with the static
99-
// widget embedder.
100-
//
101-
// The target bundle is always `dist/index.js`, which is the path required
102-
// by the custom widget embedder.
103-
//
104-
mode: "production",
105-
entry: "./src/embed.js",
106-
output: {
107-
filename: "index.js",
108-
path: path.resolve(__dirname, "..", "..", "widget", "dist"),
109-
libraryTarget: "amd",
110-
publicPath:
111-
"https://unpkg.com/jupyter-captum-insights@" + version + "/dist/",
112-
},
113-
devtool: "source-map",
11475
module: {
11576
rules: rules,
11677
},

captum/insights/attr_vis/frontend/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -7716,10 +7716,10 @@ pkg-up@^2.0.0:
77167716
dependencies:
77177717
find-up "^2.1.0"
77187718

7719-
plotly.js-basic-dist@^1.53.0:
7720-
version "1.53.0"
7721-
resolved "https://registry.yarnpkg.com/plotly.js-basic-dist/-/plotly.js-basic-dist-1.53.0.tgz#dadc4cbd1fcdeec803deb55462439b5bcbcd2b40"
7722-
integrity sha512-906O6cwy+D8rygaYiP/ujl6PaLrEXkgwnuiNjjYnkCUfpkfd2QQEQaoRp4W9WAFFDJofbnWPOVIso7P5y1Xwtw==
7719+
plotly.js-basic-dist-min@^1.58.2:
7720+
version "1.58.2"
7721+
resolved "https://registry.yarnpkg.com/plotly.js-basic-dist-min/-/plotly.js-basic-dist-min-1.58.2.tgz#7b40228f0e6d46c8936f90a0d876803df68dfe39"
7722+
integrity sha512-Yu84SGV2+bgK7ZVzmr/xUh7d6qucZ5kR/lA9emJs7N+KFmZXn7t69NCMn5YWCNeKdFys/ogdHBT9iG42yBFdPA==
77237723

77247724
pn@^1.1.0:
77257725
version "1.1.0"

scripts/install_via_conda.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ conda update -y --no-channel-priority -c conda-forge nodejs
4444

4545

4646
# build insights and install captum
47-
# TODO: remove CI=false when we want React warnings treated as errors
48-
CI=false BUILD_INSIGHTS=1 python setup.py develop
47+
BUILD_INSIGHTS=1 python setup.py develop

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def get_package_files(root, subdirs):
159159
[
160160
"captum/insights/attr_vis/widget/static/extension.js",
161161
"captum/insights/attr_vis/widget/static/index.js",
162-
"captum/insights/attr_vis/widget/static/index.js.map",
163162
],
164163
),
165164
(

tutorials/CIFAR_TorchVision_Captum_Insights.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"import torchvision.transforms as transforms\n",
3333
"\n",
3434
"from captum.insights import AttributionVisualizer, Batch\n",
35-
"from captum.insights.features import ImageFeature\n"
35+
"from captum.insights.attr_vis.features import ImageFeature\n"
3636
]
3737
},
3838
{
@@ -224,4 +224,4 @@
224224
},
225225
"nbformat": 4,
226226
"nbformat_minor": 2
227-
}
227+
}

tutorials/Multimodal_VQA_Captum_Insights.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
" print(\"please provide a valid path to pytorch-vqa\")\n",
8787
" \n",
8888
"from captum.insights import AttributionVisualizer, Batch\n",
89-
"from captum.insights.features import ImageFeature, TextFeature\n",
89+
"from captum.insights.attr_vis.features import ImageFeature, TextFeature\n",
9090
"from captum.attr import TokenReferenceBase, configure_interpretable_embedding_layer, remove_interpretable_embedding_layer"
9191
]
9292
},
@@ -621,4 +621,4 @@
621621
},
622622
"nbformat": 4,
623623
"nbformat_minor": 2
624-
}
624+
}

0 commit comments

Comments
 (0)