Skip to content

Commit 995786f

Browse files
authored
docs: add instructions for linting Python code (#3033)
Summary: As of #2967, backend code is linted with Black. Test Plan: One can successfully install and run the listed version of Black: ``` ve="$(mktemp -d)" && virtualenv -q -p python3.7 "${ve}" && . "${ve}/bin/activate" && pip install tf-nightly \ -r tensorboard/pip_package/requirements.txt \ -r tensorboard/pip_package/requirements_dev.txt \ && black . ``` This prints, “All done! 347 files left unchanged.” wchargin-branch: docs-black
1 parent 887c835 commit 995786f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

DEVELOPMENT.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# How to Develop TensorBoard
22

3-
TensorBoard at HEAD relies on the nightly installation of TensorFlow: this allows plugin authors to use the latest features of TensorFlow, but it means release versions of TensorFlow may not suffice for development. We recommend installing TensorFlow nightly in a [Python virtualenv](https://virtualenv.pypa.io), and then running your modified development copy of TensorBoard within that virtualenv. To install TensorFlow nightly within the virtualenv, you can simply run
3+
TensorBoard at HEAD relies on the nightly installation of TensorFlow: this allows plugin authors to use the latest features of TensorFlow, but it means release versions of TensorFlow may not suffice for development. We recommend installing TensorFlow nightly in a [Python virtualenv](https://virtualenv.pypa.io), and then running your modified development copy of TensorBoard within that virtualenv. To install TensorFlow nightly within the virtualenv, as well as TensorBoard's runtime and tooling dependencies, you can run:
44

55
```sh
66
$ virtualenv tf
77
$ source tf/bin/activate
88
(tf)$ pip install --upgrade pip
9-
(tf)$ pip install tf-nightly
9+
(tf)$ pip install tf-nightly -r tensorboard/pip_package/requirements.txt -r tensorboard/pip_package/requirements_dev.txt
1010
```
1111

1212
TensorBoard builds are done with [Bazel](https://bazel.build), so you may need to [install Bazel](https://docs.bazel.build/versions/master/install.html). The Bazel build will automatically "vulcanize" all the HTML files and generate a "binary" launcher script. When HTML is vulcanized, it means all the script tags and HTML imports are inlined into one big HTML file. Then the Bazel build puts that index.html file inside a static assets zip. The python HTTP server then reads static assets from that zip while serving.
@@ -23,6 +23,10 @@ You may see warnings about “Limited tf.compat.v2.summary API due to missing Te
2323

2424
For any changes to the frontend, you’ll need to install [Yarn][yarn] to lint your code (`yarn lint`, `yarn fix-lint`). You’ll also need Yarn to add or remove any NPM dependencies.
2525

26+
For any changes to the backend, you’ll need to install [Black][black] to lint your code (run `black .`). Our `black` version is specified in `requirements_dev.txt` in this repository. Black only runs on Python 3.6 or higher, so you may want to install it into a separate virtual environment and use a [wrapper script to invoke it from any environment][black-wrapper].
27+
28+
You may wish to configure your editor to automatically run Prettier and Black on save.
29+
2630
To generate fake log data for a plugin, run its demo script. For instance, this command generates fake scalar data in `/tmp/scalars_demo`:
2731

2832
```sh
@@ -35,5 +39,7 @@ If you have Bazel≥0.16 and want to build any commit of TensorBoard prior to 20
3539
$ git cherry-pick bc4e7a6e5517daf918433a8f5983fc6bd239358f
3640
```
3741

42+
[black]: https://github.com/psf/black
43+
[black-wrapper]: https://gist.github.com/wchargin/d65820919f363d33545159138c86ce31
3844
[pr-1334]: https://github.com/tensorflow/tensorboard/pull/1334
3945
[yarn]: https://yarnpkg.com/

0 commit comments

Comments
 (0)