“90648f336d0a73630d0a862259a4f73ab3c9fe8c”上不存在“paddle/pten/api/include/manual_api.h”
未验证 提交 ac8d5705 编写于 作者: D daminglu 提交者: GitHub

Fix prod build bug and add sanitizing check for graph data (#384)

上级 68e76c5d
...@@ -14,6 +14,8 @@ import {getPluginGraphsGraph} from '../../service'; ...@@ -14,6 +14,8 @@ import {getPluginGraphsGraph} from '../../service';
// for d3 drawing // for d3 drawing
import * as d3 from 'd3'; import * as d3 from 'd3';
import has from 'lodash/has';
export default { export default {
props: { props: {
'doDownload': { 'doDownload': {
...@@ -63,6 +65,10 @@ export default { ...@@ -63,6 +65,10 @@ export default {
mounted() { mounted() {
let chartScope = this; let chartScope = this;
getPluginGraphsGraph().then(({errno, data}) => { getPluginGraphsGraph().then(({errno, data}) => {
if (has(data, 'data') === false) {
return;
}
let graphData = data.data; let graphData = data.data;
// d3 svg drawing // d3 svg drawing
...@@ -85,6 +91,9 @@ export default { ...@@ -85,6 +91,9 @@ export default {
}; };
// add input nodes // add input nodes
if (has(graphData, 'input') === false) {
return;
}
for (let i=0; i<graphData['input'].length; ++i) { for (let i=0; i<graphData['input'].length; ++i) {
let curInputNode = graphData['input'][i]; let curInputNode = graphData['input'][i];
let nodeKey = curInputNode['name']; let nodeKey = curInputNode['name'];
...@@ -105,6 +114,9 @@ export default { ...@@ -105,6 +114,9 @@ export default {
} }
// add operator nodes then add edges from inputs to operator and from operator to output // add operator nodes then add edges from inputs to operator and from operator to output
if (has(graphData, 'node') === false) {
return;
}
for (let i=0; i<graphData['node'].length; ++i) { for (let i=0; i<graphData['node'].length; ++i) {
let curOperatorNode = graphData['node'][i]; let curOperatorNode = graphData['node'][i];
let nodeKey = 'opNode_' + i; let nodeKey = 'opNode_' + i;
...@@ -129,6 +141,9 @@ export default { ...@@ -129,6 +141,9 @@ export default {
nodeKeys.push(nodeKey); nodeKeys.push(nodeKey);
// add output node // add output node
if (has(graphData, 'output') === false) {
return;
}
let outputNodeKey = curOperatorNode['output'][0]; let outputNodeKey = curOperatorNode['output'][0];
let outputPadding = ' '.repeat(Math.floor(outputNodeKey.length/2)); let outputPadding = ' '.repeat(Math.floor(outputNodeKey.length/2));
g.setNode( g.setNode(
...@@ -155,7 +170,7 @@ export default { ...@@ -155,7 +170,7 @@ export default {
} }
g.setEdge(nodeKey, curOperatorNode['output'][0], { g.setEdge(nodeKey, curOperatorNode['output'][0], {
style: 'stroke: #333;stroke-width: 1.5px' style: 'stroke: #333;stroke-width: 1.5px',
}); });
} }
......
...@@ -24,13 +24,22 @@ webpackConfig.plugins = webpackConfig.plugins.concat([ ...@@ -24,13 +24,22 @@ webpackConfig.plugins = webpackConfig.plugins.concat([
var name = opt.outputName.replace(/\.html$/, ''); var name = opt.outputName.replace(/\.html$/, '');
var feRoot = feRoots[name]; /*
We do not need the following hack, which was added here:
if (feRoot) { https://github.com/PaddlePaddle/VisualDL/commit/75f5c3b55fb411e0329b98d66253e60137f88bd5#diff-b6dc766994d45268924eff9a07f0765bR31
html = html
.replace(/href="/g, 'href="' + feRoot) What it does is simply add './' in front of 'src' and 'href' to make sure it is loading local files.
.replace(/src="/g, 'src="' + feRoot); But it should be able to load both local JS files and CDN files via 'https://...'
} */
// var feRoot = feRoots[name];
// if (feRoot) {
// html = html
// .replace(/href="/g, 'href="' + feRoot);
// .replace(/src="/g, 'src="' + feRoot);
// }
return html; return html;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册