Skip to content

Commit

Permalink
Use http_file instead of new_http_archive for some external dependenc…
Browse files Browse the repository at this point in the history
…ies.

1) Use http_file for the following external deps:
-   Three.js since the github releases are extremely large (>500mb).
-   numericjs since the compiled js is not checked into the github repo or even bower. It is hosted on the numericjs website.

2) Link the compiled source from ES6 components (e.g. Embedding Projector) into TensorBoard. In other words, new releases of vulcanized tf-tensorboard.html will now include the compiled code for the embedding projector (not visible yet in the UI).

3) Make bower_dependency_sync script generate one more file, dist/bazel-html-imports.html. This file imports the external deps that use http_file (via <script> tag) since they have special paths in bazel runfiles.
Change: 132388361
  • Loading branch information
Dan Smilkov authored and tensorflower-gardener committed Sep 7, 2016
1 parent 91ce95d commit 33c9c02
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 396 deletions.
32 changes: 16 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,9 @@ new_http_archive(
strip_prefix = "neon-animation-1.2.2",
)

new_http_archive(
name = "numericjs",
build_file = "bower.BUILD",
url = "https://github.com/sloisel/numeric/archive/v1.2.6.tar.gz",
strip_prefix = "numeric-1.2.6",
http_file(
name = "numericjs_numeric_1_2_6_min_js",
url = "http://www.numericjs.com/lib/numeric-1.2.6.min.js",
)

new_http_archive(
Expand Down Expand Up @@ -300,8 +298,8 @@ new_http_archive(
new_http_archive(
name = "paper_input",
build_file = "bower.BUILD",
url = "https://github.com/polymerelements/paper-input/archive/v1.1.14.tar.gz",
strip_prefix = "paper-input-1.1.14",
url = "https://github.com/polymerelements/paper-input/archive/v1.1.18.tar.gz",
strip_prefix = "paper-input-1.1.18",
)

new_http_archive(
Expand Down Expand Up @@ -430,10 +428,14 @@ new_http_archive(
strip_prefix = "promise-polyfill-1.0.0",
)

new_http_archive(
name = "three_js",
build_file = "bower.BUILD",
url = "https://github.com/mrdoob/three.js/archive/r77.tar.gz",
http_file(
name = "three_js_three_min_js",
url = "https://raw.githubusercontent.com/mrdoob/three.js/r77/build/three.min.js",
)

http_file(
name = "three_js_orbitcontrols_js",
url = "https://raw.githubusercontent.com/mrdoob/three.js/r77/examples/js/controls/OrbitControls.js",
)

new_http_archive(
Expand All @@ -450,9 +452,7 @@ new_http_archive(
strip_prefix = "webcomponentsjs-0.7.22",
)

new_http_archive(
name = "weblas",
build_file = "bower.BUILD",
url = "https://github.com/waylonflinn/weblas/archive/v0.9.0.tar.gz",
strip_prefix = "weblas-0.9.0",
http_file(
name = "weblas_weblas_js",
url = "https://raw.githubusercontent.com/waylonflinn/weblas/v0.9.0/dist/weblas.js",
)
326 changes: 0 additions & 326 deletions bower.BUILD

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tensorflow/tensorboard/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ filegroup(
name = "frontend",
srcs = [
"TAG",
"dist/bazel-html-imports.html",
"dist/index.html",
"dist/tf-tensorboard.html",
"//tensorflow/tensorboard/bower",
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/tensorboard/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#1.3.2",
"paper-header-panel": "PolymerElements/paper-header-panel#1.1.4",
"paper-icon-button": "PolymerElements/paper-icon-button#1.1.1",
"paper-input": "PolymerElements/paper-input#1.1.14",
"paper-input": "PolymerElements/paper-input#1.1.18",
"paper-item": "PolymerElements/paper-item#1.1.4",
"paper-listbox": "PolymerElements/paper-listbox#1.1.2",
"paper-material": "PolymerElements/paper-material#1.0.6",
Expand Down Expand Up @@ -150,7 +150,7 @@
"paper-dropdown-menu": "1.3.2",
"paper-header-panel": "1.1.4",
"paper-icon-button": "1.1.1",
"paper-input": "1.1.14",
"paper-input": "1.1.18",
"paper-item": "1.1.4",
"paper-listbox": "1.1.2",
"paper-material": "1.0.6",
Expand Down
7 changes: 4 additions & 3 deletions tensorflow/tensorboard/bower/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ filegroup(
"@iron_validatable_behavior//:iron_validatable_behavior",
"@lodash//:lodash",
"@neon_animation//:neon_animation",
"@numericjs//:numericjs",
"@numericjs_numeric_1_2_6_min_js//file",
"@paper_behaviors//:paper_behaviors",
"@paper_button//:paper_button",
"@paper_checkbox//:paper_checkbox",
Expand Down Expand Up @@ -63,9 +63,10 @@ filegroup(
"@plottable//:plottable",
"@polymer//:polymer",
"@promise_polyfill//:promise_polyfill",
"@three_js//:three_js",
"@three_js_orbitcontrols_js//file",
"@three_js_three_min_js//file",
"@web_animations_js//:web_animations_js",
"@webcomponentsjs//:webcomponentsjs",
"@weblas//:weblas",
"@weblas_weblas_js//file",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,6 @@ <h2>Settings</h2>
},
});
</script>
<!-- Compiled bundle of all components using ES6 modules. -->
<script src="../bundle.js"></script>
</dom-module>
23 changes: 23 additions & 0 deletions tensorflow/tensorboard/dist/bazel-html-imports.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!-- TENSORBOARD_BOWER_AUTOGENERATED_BELOW_THIS_LINE_DO_NOT_EDIT -->
<script src="../numericjs_numeric_1_2_6_min_js/file/numeric-1.2.6.min.js"></script>
<script src="../three_js_three_min_js/file/three.min.js"></script>
<script src="../three_js_orbitcontrols_js/file/OrbitControls.js"></script>
<script src="../weblas_weblas_js/file/weblas.js"></script>
1 change: 1 addition & 0 deletions tensorflow/tensorboard/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="stylesheet" type="text/css" href="lib/css/global.css">
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMQAAADECAMAAAD3eH5ZAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAD/UExURfFlKfaELvFmKfNyK/67NvWALf68Nv69NvNxK/20NfyyNP22NfN0K/JrKvqhMv2zNf25Nf24Nf23NfeOL/yzNPyvNPJoKviWMPmeMfN1K/WBLfePL/FnKfeML/qlMvR7LPmcMfeLL/aJLvR5LPFoKfJuKvR3LP66NvywNPeNL/V/LfaILv21Nf26NfNzK/NvK/R6LPmaMfyxNPqfMvV+LfurM/iSMPmbMfJvKvmdMfumM/qiMvmZMfytNPJqKvysNPN2K/iYMPNwK/upM/JtKvJsKviVMPaHLvaGLvJpKvR8LPaKLvqkMvuqM/aFLvR4LPuoM/iTMPWDLfiRMPmYMXS0ngkAAALoSURBVHja7drnctpAFIbhFUISSKJ3MKYa0+y4xTW9937/15JkJhlTjhrSrHRmvuf/as6L0YLFCgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBJ6njenqspzgnPrsrGX9Zpi2tCrmnc6+dYNthVY5WpMmxQLWPdMsOuYVwzNj3ei2t3mQwaV43BJPDCS2NbJ5aEeuX/+9qcjQOtfFIkIkrvY2g4MVcmOBsFWbowKO/kNyj62gRpJcDaPBlxLr1B0zdG0C/8LzbJiJrshuvy1gzlA9+rD8mIkuyIJjFE3/dqnYwoSm7IUEPoD/wut8iIguSIDjlFxe/yfXL5vuSI21BTZLLhXoOILMO8Hxwa/L8bI0LfmUdhGowb2ZvT0e57pFNDgB06IlVyjmmIBl2T/nl9Rw6SD9GgSG/Q0uQkaW3XhmovKQ3eFQ4N2Uo9OQ1eFZsNerf7vP+rO4rhmY1Lg3vFVoP8+8BXg1sFnwbnCk4NThW8GuiKBDdkVVtTNFvNelVsNqTbyWnIOM2oeTRoyWvwmpJHg/ucXBrcJuXT4DwrpwZi2vy0VCx8YtXg/D2bU4OfiuQ3eFfE2KD4bfCqiLNB993gXsGlwa2CT4NzBacGIVQ6YsipQdh0xEdODUKjIxrSp88onZ8zbbFLg1DoiFO5BXvDGv2My9/JhUT8JUZTI0yDaNHLBzIbvqTDNYhUiVw/kdjQ1kM2CHFDPjKW+KzyRTF0g/ga9w9y+fANQpxvX8CU+Ny7FUWDeF3Y+g3lROIf4k0UDX9eCyvO531PyYhHga9zvPZJU5b73Y/eXj8Hv9D48n6HaF5LbcjRt8TZTtda5M1DfXnbkX1C0SHCFKzQB5Fe8op4GNGNHavvZESbVwT5r6W1xyuCPBY3Y9YgDqzknH/e3YfNzzuL30l0IebrZ5kKtuDIXt1n868ET6kf3/49tLvrCcZyF8Pu215dAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcPIbNrBhOaBXucoAAAAASUVORK5CYII=">
<link rel="import" href="dist/bazel-html-imports.html">
<link rel="import" href="dist/tf-tensorboard.html">
</head>
<body>
Expand Down
93 changes: 49 additions & 44 deletions tensorflow/tensorboard/gulp_tasks/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,51 +40,56 @@ var ES6_COMPONENTS = [{
]
}];

module.exports = function() {
// Compile all components that are using ES6 modules into a bundle.js
// using browserify.
var entries = ['typings/index.d.ts'];
var deps = {};
ES6_COMPONENTS.forEach(function(component) {
// Collect all the typescript files across the components.
entries = entries.concat(glob(
'components/' + component.name + '/**/*.ts',
// Do not include tests or IDE-purposed files.
{ignore: ['**/*_test.ts', '**/deps.d.ts']}));
// Collect the unique external deps across all components using es6 modules.
component.deps.forEach(function(dep) { deps['components/' + dep] = true; });
});
deps = Object.keys(deps);

// Compile, bundle all the typescript files and prepend their deps.
browserify(entries)
.plugin(tsify)
.bundle()
.on('error', function(error) { console.error(error.toString()); })
.pipe(source('app.js'))
.pipe(gulp.dest('components'))
.on('end', function() {
// Typescript was compiled and bundled. Now we need to prepend
// the external dependencies.
gulp.src(deps.concat(['components/app.js']))
.pipe(concat('bundle.js'))
.pipe(gulp.dest('components'));
module.exports = function(includeDeps) {
return function() {
// Compile all components that are using ES6 modules into a bundle.js
// using browserify.
var entries = ['typings/index.d.ts'];
var deps = {};
ES6_COMPONENTS.forEach(function(component) {
// Collect all the typescript files across the components.
entries = entries.concat(glob(
'components/' + component.name + '/**/*.ts',
// Do not include tests or IDE-purposed files.
{ignore: ['**/*_test.ts', '**/deps.d.ts']}));
// Collect the unique external deps across all components using es6
// modules.
component.deps.forEach(function(dep) {
deps['components/' + dep] = true;
});
});
deps = Object.keys(deps);

// Compile components that are using global namespaces producing 1 js file
// for each ts file.
var isComponent = filter([
'components/tf-*/**/*.ts', 'components/vz-*/**/*.ts', 'typings/**/*.ts',
'components/plottable/plottable.d.ts'
// Ignore components that use es6 modules.
].concat(ES6_COMPONENTS.map(function(component) {
return '!components/' + component.name + '/**/*.ts';
})));
// Compile, bundle all the typescript files and prepend their deps.
browserify(entries)
.plugin(tsify)
.bundle()
.on('error', function(error) { console.error(error.toString()); })
.pipe(source('bundle.js'))
.pipe(gulp.dest('components'))
.on('end', function() {
// Typescript was compiled and bundled. Now we need to prepend
// the external dependencies.
if (includeDeps) {
gulp.src(deps.concat(['components/bundle.js']))
.pipe(concat('bundle.js'))
.pipe(gulp.dest('components'));
}
});

return tsProject.src()
.pipe(isComponent)
.pipe(ts(tsProject))
.js
.pipe(gulp.dest('.'));
// Compile components that are using global namespaces producing 1 js file
// for each ts file.
var isComponent = filter([
'components/tf-*/**/*.ts', 'components/vz-*/**/*.ts', 'typings/**/*.ts',
'components/plottable/plottable.d.ts'
// Ignore components that use es6 modules.
].concat(ES6_COMPONENTS.map(function(component) {
return '!components/' + component.name + '/**/*.ts';
})));

}
return tsProject.src()
.pipe(isComponent)
.pipe(ts(tsProject))
.js.pipe(gulp.dest('.'));
};
};
2 changes: 1 addition & 1 deletion tensorflow/tensorboard/gulp_tasks/vulcanize.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = function(overwrite) {
inlineScripts: true,
inlineCss: true,
stripComments: true,
excludes: getNonTensorBoardComponents(),
excludes: getNonTensorBoardComponents()
}))
.pipe(header(HEADER_STR))
.pipe(rename('tf-tensorboard.html' + suffix))
Expand Down
13 changes: 9 additions & 4 deletions tensorflow/tensorboard/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ function getTask(task) {
}


gulp.task('compile', getTask('compile'));
gulp.task('compile', getTask('compile')(true));
gulp.task('tslint', getTask('tslint')(true));
// tslint.permissive warns without failing.
gulp.task('tslint.permissive', getTask('tslint')(false));
gulp.task('first-compile', getTask('compile'));
gulp.task('first-compile', getTask('compile')(true));
gulp.task('compile-without-deps', getTask('compile')(false));
gulp.task('test.onlytest', getTask('test')); // if you don't want to lint, etc
gulp.task('test', ['tslint', 'compile'], getTask('test'));

Expand Down Expand Up @@ -65,9 +66,13 @@ gulp.task('server', ['first-compile'], function() {

// TODO(danmane): When testing is nicer, integrate into vulcanize task
// gulp vulcanize: Regenerate the tf-tensorboard.html.OPENSOURCE file for pre-release
gulp.task('vulcanize', ['first-compile', 'tslint.permissive'], getTask('vulcanize')(false));
gulp.task(
'vulcanize', ['compile-without-deps', 'tslint.permissive'],
getTask('vulcanize')(false));
// gulp regenerate: Regenerate the tf-tensorboard.html for interactive bazel development
gulp.task('regenerate', ['first-compile', 'tslint.permissive'], getTask('vulcanize')(true));
gulp.task(
'regenerate', ['compile-without-deps', 'tslint.permissive'],
getTask('vulcanize')(true));

// TODO(danmane): consider making bower install part of default task
gulp.task('default', ['watch', 'server']);
Expand Down

0 comments on commit 33c9c02

Please sign in to comment.