Trains Plugins

Trains provides the following plugins:

  • Trains Jupyter Plugin - Push IPython Notebooks to a Git repository.
  • Trains PyCharm Plugin - Sync the local repository information to a remote debugger machine.

Trains Jupyter Plugin

Trains Jupyter Plugin is a Jupyter Notebook extension enabling users to push IPython Notebooks to a Git repository, using the Git button added to the notebook toolbar. After saving a notebook, a user can push the notebook to a predefined Git repository. The extension currently supports pushing to a predefined branch in the repository.

The Trains Jupyter Plugin is available in PyPi, and our trains-jupyter-plugin repository.

The Trains Jupyter Plugin works as follows:

  1. Click the version-control button.
  2. The notebook .ipynb file is pushed to the Git repository based on the folder structure in which it is located.
  3. The notebook is converted to a .py script, and pushed alongside the .ipynb file.
  4. A requirements.txt is created and updated according to the notebook imports, and pushed alongside the .ipynb file.

For example, if you have two repositories:

├── .git
└── experiment1/
   └── notebook1.ipynb

├── .git
└── experiment2/
   └── notebook2.ipynb

notebook1.ipynb is be pushed to the repo1 repository, and notebook2.ipynb is be pushed to the repo2 repository.

To select the predefined branch into which the files will be pushed, use git checkout on the Jupyter host machine.

For example, switch to branch2 in repo2:

cd ~/repo2
git checkout branch2

After switching, the Jupyter Notebook push is done to the branch2 branch in the repo2 repository.

Installing the Trains Jupyter Plugin

To install the Trains Jupyter Plugin from PyPi, do the following:

  • Execute the following commands:
    pip install trains-jupyter-plugin
    if [ ! -f ~/.jupyter/ ]; then
       jupyter notebook --generate-config
    jupyter serverextension enable --py trains-jupyter-plugin
    sudo jupyter nbextension install --py trains-jupyter-plugin

To enable the extension for all notebooks, do the following:

  • Execute the following command:
    jupyter nbextension enable --py trains-jupyter-plugin


Our thanks to Lab41/sunny-side-up and sat28/githubcommit for laying the foundations of this plugin, and for support.

Using the Trains Jupyter Plugin

After installing the plugin and enabling the extension, you can use the plugin with Git repositories.

To use the Trains Jupyter Plugin with a Git repository, do the following:

  1. Clone your Git repository to a directory that will be assigned to a specific user.
  2. Checkout a specific branch for the current user.
  3. Make sure Git is configured with the correct credentials. We recommend verifying a password/passphrase is required when pushing.
  4. Run Jupyter Notebook.
  5. Any commit/push of notebooks from this specific folder will be done to the selected branch.

Trains PyCharm Plugin

The Trains PyCharm Plugin provides syncing of the local repository information to a remote debugger machine. For more information about installing plugins in PyCharm, see Managing plugins, install plugin from disk in the PyCharm documentation.

To install the Trains PyCharm Plugin, do the following:

  1. Download the latest release of the Trains PyCharm Plugin jar file from trains-pycharm-plugin in GitHub.
  2. In PyCharm, install the plugin from disk.
  3. In PyCharm, click File.
  4. Click Settings.
  5. Click Plugins.
  6. Click settings.
  7. Click Install Plugin from Disk
  8. In the file browser, select the Trains PyCharm Plugin jar file you downloaded.
  9. Click Apply.
  10. Restart PyCharm

Optional: To configuring Trains host and credentials:

  1. In PyCharm, click File.
  2. Click Settings.
  3. Click Tools.
  4. Click TRAINS.
  5. In the TRAINS tool window, type your Trains host URL (e.g., http://localhost:8008), user credentials key and secret.
  6. Click Apply.