See Community for a list of Theano resources. The following groups/mailing-lists are especially useful to Theano contributors: theano-dev, theano-buildbot, and theano-github.
To get up to speed, you’ll need to
To obtain developer access: register with GitHub and create a fork of Theano.
This will create your own Theano project on GitHub, referred later as “YourProfile/Theano”, or “origin”, from which you will be able to contribute to the original Theano/Theano, also called “central”.
Clone your fork locally with
git clone git@github.com:your_github_login/Theano.git
From your local repository, your own fork on GitHub will be called “origin”.
Then, add a reference to the original (“central”) Theano repository with
git remote add central git://github.com/Theano/Theano.git
You can choose another name than “central” to reference Theano/Theano (for instance, NumPy uses “upstream”), but this documentation will stick to “central.”
You can then test your installation of Theano by following the steps of Testing your installation.
To update your library to the latest revision, you should have a local branch that tracks central/master. You can add one (named “trunk” here) with:
git fetch central
git branch trunk central/master
Once you have such a branch, in order to update it, do:
git checkout trunk
git pull
Keep in mind that this branch should be “read-only”: if you want to patch Theano, you should work in another branch, like described in the Development Workflow section below.
On your local machine, you need to configure git with basic informations:
git config --global user.email you@yourdomain.example.com
git config --global user.name "Your Name Comes Here"
You can also instruct git to use color in diff. For this, you need to add those lines in the file ~/.gitconfig
[color]
branch = auto
diff = auto
interactive = auto
status = auto
When working on a new feature in your own fork, start from an up-to-date copy of the master branch (the principal one) of the central repository (Theano/Theano on GitHub):
git fetch central
git checkout -b my_shiny_feature central/master
Note
This last line is a shortcut for:
git branch my_shiny_feature central/master
git checkout my_shiny_feature
Once your code is ready for others to review, you need to push your branch to your github fork first:
git push -u origin my_shiny_feature
Then, go to your fork’s github page on the github website, select your feature branch and hit the “Pull Request” button in the top right corner. This will signal the maintainers that you wish to submit your changes for inclusion in central/master. If you don’t get any feedback, bug us on the theano-dev mailing list.
Your pull request will be reviewed by members of the core development team. If your branch is not directly accepted, the reviewers will use GitHub’s system to add “notes”, either general (on the entire commit), or “line notes”, relative to a particular line of code. In order to have the pull request accepted, you may have to answer the reviewer’s questions, you can do that on GitHub.
You may also have to edit your code to address their concerns. Some of the usual requests include fixing typos in comments, adding or correcting comments, adding unit tests in the test suite. In order to do that, you should continue your edits in the same branch you used (in this example, “my_shiny_feature”). For instance, if you changed your working branch, you should first:
git checkout my_shiny_feature
Then, edit your code, and test it appropriately (see Tips for Quality Contributions below), and push it again to your GitHub fork, like the first time (except the -u option is only needed the first time):
git push origin my_shiny_feature
The pull request to the central repository will then be automatically updated by GitHub. However, the reviewers will not be automatically notified of your revision, so it is advised to reply to the comments on GitHub, to let them know that you have submitted a fix.
In Theano, we use the same coding style as the Pylearn project, except that we don’t use the numpy docstring standard. The principal thing to know is that we follow the pep8 coding style.
We use git hooks provided in the project pygithooks to validate that commits respect pep8. This happens when each user commits, not when we push/merge to the Theano repository. Github doesn’t allow us to have code executed when we push to the repository. So we ask all contributors to use those hooks.
For historic reason, we currently don’t have all files respecting pep8. We decided to fix everything incrementally. So not all files respect it now. So we strongly suggest that you use the “increment” pygithooks config option to have a good workflow. See the pygithooks main page for how to set it up for Theano and how to enable this option.
Before submitting a pull request, you should run the unit test suite, and make sure that your changes did not create any new Error or Failure. You can consult theano-buildbot for the result of a recent run of the test suite with various options.
To run the test suite with the default options, you can follow the instructions of Testing your installation.
Each night we execute all the unit tests automatically, with different sets of options. The result is sent by email to the theano-buildbot mailing list.
For more detail, see The nightly build/tests process.
To run all the tests with the same configuration as the buildbot, run this script:
theano/misc/do_nightly_build
This function accepts arguments that it forward to nosetests. You can run only some tests or enable pdb by giving the equivalent nosetests parameters.
You can find information and tips in the numpy development page. Here are a few.
When your pull request has been merged, you can delete the branch from your GitHub fork’s list of branches. This is useful to avoid having too many branches staying there. Deleting this remote branch is achieved with:
git push origin :my_shiny_feature
This lines pushes to the “origin” repository (your fork of Theano on GitHub), into the branch “my_shiny_feature”, an empty content (that’s why there is nothing before the colon), effectively removing it.
The branch will still be present in your local clone of the repository. If you want to delete it from there, too, you can run:
git branch -d my_shiny_feature
If you want to fix a commit already submitted within a pull request (e.g. to fix a small typo), before the pull request is accepted, you can do it like this to keep history clean:
git checkout my_shiny_feature
git commit --amend
git push origin my_shiny_feature:my_shiny_feature
Do not abuse that command, and please use it only when there are only small issues to be taken care of. Otherwise, it becomes difficult to match the comments made by reviewers with the new modifications. In the general case, you should stick with the approach described above.
Sometimes you may have commits in your feature branch that are not needed in the final pull request. There is a page that talks about this. In summary:
To collaborate with another user on some feature he is developing, and that is not ready for inclusion in central, the easiest way is to use a branch of their Theano fork (usually on GitHub).
Just like we added Theano/Theano as a remote repository, named “central”, you can add (on your local machine) a reference to their fork as a new remote repository. REPO_NAME is the name you choose to name this fork, and GIT_REPO_PATH is the URL of the fork in question.
git remote add REPO_NAME GIT_REPO_PATH
Then, you can create a new local branch (LOCAL_BRANCH_NAME) based on a specific branch (REMOTE_BRANCH_NAME) from the remote repository (REPO_NAME):
git checkout -b LOCAL_BRANCH_NAME REPO_NAME/REMOTE_BRANCH_NAME