From 8b3602d66794e72cc59602498d9454f82335beb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Man=C3=A9?= Date: Tue, 5 Apr 2016 13:16:18 -0800 Subject: [PATCH] Split TensorBoard gulpfile into per-task files. This is to increase maintainability. Gulp task changes: "compile.all" -> "compile" "tslint-strict" -> "tslint" "tslint-permissive" -> "tslint.permissive" gulp watch will run tslint and compile in parallel rather than in sequence (faster)" Change: 119089704 --- tensorflow/tensorboard/DEVELOPMENT.md | 9 +- tensorflow/tensorboard/gulp_tasks/bower.js | 23 +++ tensorflow/tensorboard/gulp_tasks/compile.js | 38 ++++ tensorflow/tensorboard/gulp_tasks/test.js | 28 +++ tensorflow/tensorboard/gulp_tasks/tslint.js | 27 +++ tensorflow/tensorboard/gulp_tasks/typings.js | 21 ++ .../tensorboard/gulp_tasks/vulcanize.js | 89 +++++++++ tensorflow/tensorboard/gulpfile.js | 182 +++--------------- tensorflow/tensorboard/tsconfig.json | 3 +- 9 files changed, 260 insertions(+), 160 deletions(-) create mode 100644 tensorflow/tensorboard/gulp_tasks/bower.js create mode 100644 tensorflow/tensorboard/gulp_tasks/compile.js create mode 100644 tensorflow/tensorboard/gulp_tasks/test.js create mode 100644 tensorflow/tensorboard/gulp_tasks/tslint.js create mode 100644 tensorflow/tensorboard/gulp_tasks/typings.js create mode 100644 tensorflow/tensorboard/gulp_tasks/vulcanize.js diff --git a/tensorflow/tensorboard/DEVELOPMENT.md b/tensorflow/tensorboard/DEVELOPMENT.md index 2f47f8c48f2..77c3412b2c6 100644 --- a/tensorflow/tensorboard/DEVELOPMENT.md +++ b/tensorflow/tensorboard/DEVELOPMENT.md @@ -40,12 +40,11 @@ to create a realistic demo directory from your own data files. ## Launching TensorBoard with modified source If you are developing in open source, and have made some changes to TensorBoard -that you'd like to try out on real data, then you need to overwrite -`dist/tf-tensorboard.html`. Run `gulp vulcanize`, and you'll get a new file -called `dist/tf-tensorboard.html.OPENSOURCE`. Overwite -`dist/tf-tensorboard.html` with that file: +that you'd like to try out on real data, then you need to regenerate +`dist/tf-tensorboard.html`. -`mv dist/tf-tensorboard.html.OPENSOURCE dist/tf-tensorboard.html`. +Run `gulp regenerate`. That will recompile all of the TensorBoard assets, and +produce a new tf-tensorboard.html with your changes. Now, you can use `bazel` to launch TensorBoard: diff --git a/tensorflow/tensorboard/gulp_tasks/bower.js b/tensorflow/tensorboard/gulp_tasks/bower.js new file mode 100644 index 00000000000..16f4b64228b --- /dev/null +++ b/tensorflow/tensorboard/gulp_tasks/bower.js @@ -0,0 +1,23 @@ +/* Copyright 2015 Google Inc. 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. +==============================================================================*/ + +var gulp = require('gulp'); +var bower = require('gulp-bower'); + +module.exports = function() { + return function() { + return bower(); + } +} diff --git a/tensorflow/tensorboard/gulp_tasks/compile.js b/tensorflow/tensorboard/gulp_tasks/compile.js new file mode 100644 index 00000000000..d25af4a23df --- /dev/null +++ b/tensorflow/tensorboard/gulp_tasks/compile.js @@ -0,0 +1,38 @@ +/* Copyright 2015 Google Inc. 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. +==============================================================================*/ + +var gulp = require('gulp'); +var ts = require('gulp-typescript'); +var typescript = require('typescript'); +var gutil = require('gulp-util'); +var filter = require('gulp-filter'); +var merge = require('merge2'); + +var tsProject = ts.createProject('./tsconfig.json', { + typescript: typescript, + noExternalResolve: true, // opt-in for faster compilation! +}); + + +module.exports = function() { + var isComponent = filter(['components/**/*.js']); + + return tsProject.src() + .pipe(ts(tsProject)) + .js + .pipe(isComponent) + .pipe(gulp.dest('.')) + +} diff --git a/tensorflow/tensorboard/gulp_tasks/test.js b/tensorflow/tensorboard/gulp_tasks/test.js new file mode 100644 index 00000000000..1d82f2f38f6 --- /dev/null +++ b/tensorflow/tensorboard/gulp_tasks/test.js @@ -0,0 +1,28 @@ +/* Copyright 2015 Google Inc. 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. +==============================================================================*/ + +var gulp = require('gulp'); +var tester = require('web-component-tester').test; + +module.exports = function(done) { + tester({}, function(error) { + if (error) { + // Pretty error for gulp. + error = new Error(error.message || error); + error.showStack = false; + } + done(error); + }); +} diff --git a/tensorflow/tensorboard/gulp_tasks/tslint.js b/tensorflow/tensorboard/gulp_tasks/tslint.js new file mode 100644 index 00000000000..b774a911654 --- /dev/null +++ b/tensorflow/tensorboard/gulp_tasks/tslint.js @@ -0,0 +1,27 @@ +/* Copyright 2015 Google Inc. 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. +==============================================================================*/ + +var gulp = require('gulp'); +var tslint = require('gulp-tslint'); + +module.exports = function(strict) { + return function() { + return gulp.src('components/tf-*/**/*.ts') + .pipe(tslint()) + .pipe(tslint.report('verbose', { + emitError: strict, + })); + }; +} diff --git a/tensorflow/tensorboard/gulp_tasks/typings.js b/tensorflow/tensorboard/gulp_tasks/typings.js new file mode 100644 index 00000000000..e4335681231 --- /dev/null +++ b/tensorflow/tensorboard/gulp_tasks/typings.js @@ -0,0 +1,21 @@ +/* Copyright 2015 Google Inc. 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. +==============================================================================*/ +var gulp = require('gulp'); +var typings = require('gulp-typings'); + +module.exports = function() { + return gulp.src('./typings.json') + .pipe(typings()); +} diff --git a/tensorflow/tensorboard/gulp_tasks/vulcanize.js b/tensorflow/tensorboard/gulp_tasks/vulcanize.js new file mode 100644 index 00000000000..afbeb9d7c6f --- /dev/null +++ b/tensorflow/tensorboard/gulp_tasks/vulcanize.js @@ -0,0 +1,89 @@ +/* Copyright 2015 Google Inc. 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. +==============================================================================*/ + +var gulp = require('gulp'); +var fs = require('fs'); +var path = require('path'); +var vulcanize = require('gulp-vulcanize'); +var replace = require('gulp-replace'); +var rename = require('gulp-rename'); +var header = require('gulp-header'); + +var HEADER_STR = '\n\n' + +/** + * Returns a list of non-tensorboard components inside the components + * directory, i.e. components that don't begin with 'tf-'. + */ +function getNonTensorBoardComponents() { + return fs.readdirSync('components') + .filter(function(file) { + var prefix = file.slice(0,3); + return fs.statSync(path.join('components', file)).isDirectory() && + prefix !== 'tf-'; + }) + .map(function(dir) { return '/' + dir + '/'; }); +} + +var linkRegex = /\n/g; +var scriptRegex = /