This project contains the configuration files that I use to set up my development environment for modifying the TensorFlow code.
-
Check out this repository into your home directory.
-
Install Anaconda
-
Run the script
buildenv.sh
to set up an Anaconda environmenttfbuild
for building TensorFlow. -
Add the following to your
.bashrc
:export MY_TF_REPO_URL=<Github URL of your fork of TensorFlow; for example, https://github.com/frreiss/tensorflow-fred.git> if [ -f ~/tf-dev-conf/aliases.sh ]; then source ~/tf-dev-conf/aliases.sh fi
- aliases.sh: Bash aliases for common TensorFlow develoment tasks
- branch.py: Script to create a local development branch for a TensorFlow pull request
- buildenv.sh: Script to configure an Anaconda environment on the local machine for building TensorFlow.
- lintenv.sh: Script to create an Anaconda environment that replicates the
TensorFlow Docker containers' Python setup. Useful for running tools like
tensorflow/tools/ci_build/ci_sanity.sh
outside of Docker. - testenv.sh: Script to create an Anaconda environment under the current directory for testing your modified version of TensorFlow.
- tf.bazelproject: Configuration file for setting up the Bazel integration in IntelliJ/CLion. Import this file from the "import Bazel project" wizard.
Phase 1: Implement code changes on laptop:
tfb my-pr-name
: Replacemy-pr-name
with a name for your branch and local working directory. The local working directory will betf-my-pr-name
and the branch you push to will beissue-my-pr-name
. Choose a name that will be memorable; larger pull requests can stay in the review queue for weeks or months.cd tf-my-branch-name
tfcc
(activatestfbuild
environment and configures for compilation)bbt
: Kick off a build/test cycle in the background while you make your code changes. This step will save you time later on.- Make changes
git push --set-upstream origin issue-my-pr-name
(create and push to your branch)
Phase 2a: Manual testing on laptop:
cd tf-my-branch-name
bbp
/bbp2
(prepare to build a Pip package)bbpp
(actually build the pip package)~/tf-dev-conf/testenv.sh
conda activate ./testenv
pip install ./pip_package/*.whl
cd ./testenv
: Can't run TensorFlow from the root of a TensorFlow source tree.jupyter lab
(to try out your changes)
Phase 2b: Build/test on the cloud. These steps can run at the same time as 2a.
- Create a large virtual machine or container. I use a 56-core VM with 128GB of memory and local flash storage.
- Import this repository's scripts and configuration to your VM/container
tfc my-pr-name
: Check out a copy of your branch to the cloud machine.cd tf-my-pr-name
tfcc
bbd
: Run pre-commit sanity checks likepylint
. Fix any problems that arise while the next step runs.bbtd
: Full regression test suite from a Docker environment.
Phase 3: Prepare PR:
- Return to laptop and
cd tf-my-branch-name
. git rebase --interactive HEAD~<number of commits made>
: Squash all your commits to date.git push --force
. Note that you will need to check out a fresh copy of your branch on your large cloud VM/container after this step by runningtfc my-branch-name
a second time.- Go to github.com and create a pull request off the branch
issue-my-branch-name
.
Phase 4: Maintain branch during review. On your laptop:
conda activate tfbuild
cd tf-my-branch-name
- Make any changes requested
bbt
to rerun regression tests affected by your changes- If you made significant changes, fire up a VM and repeat Phase 2b.
git push
. Do not rebase a second time; doing so will corrupt your pull request.