Push to Git
Commit notebook changes directly to your Git repository from Jupyter. This requires setting up SSH credentials in Valohai.
Setup Overview
You'll need to:
Generate SSH keys
Add the public key as a deploy key in your Git repository
Add the private key to Valohai
Test the connection from a notebook
This setup is one-time per repository. Once configured, any notebook in your project can push changes.
Generate SSH Keys
Create an SSH key pair on your local machine:
ssh-keygen -t rsa -b 4096 -C "[email protected]"When prompted for a file location and passphrase, accept the defaults or customize as needed.
This creates two files:
id_rsa(private key) — stays secret, goes into Valohaiid_rsa.pub(public key) — goes into GitHub/GitLab as a deploy key
Add Deploy Key to GitHub
In your GitHub repository:
Go to Settings → Deploy keys
Click Add deploy key
Paste your public key (
id_rsa.pubcontents)Give it a descriptive title like "Valohai Notebooks"
Check Allow write access
Click Add key
For GitLab or other providers, the process is similar—look for "Deploy Keys" or "Access Keys" in repository settings.
Add Private Key to Valohai
In Valohai:
Click your name in the top-right corner
Select Manage Organization
Navigate to App Credentials
Click Add credentials
Enter the Git hostname (e.g.,
github.com)Paste your private key (
id_rsacontents)Click Save
Your notebooks now have write access to the repository through this credential.
Test from a Notebook
Launch a notebook execution in your Valohai project. Once it's running:
Open Jupyter
Create or modify a notebook file
Save your changes
Open a terminal in Jupyter (New → Terminal)
Run these commands:
git status
git add <your_file>
git commit -m "Update notebook from Valohai"
git push origin mainIf the push succeeds, check your GitHub repository to verify the changes appeared.
💡 Tip: Use a separate branch for notebook experiments to keep your main branch clean. Push to a feature branch, then create a pull request for review.
Best Practices
Use dedicated branches
Don't push directly to main from notebooks. Create feature branches:
git checkout -b experiment/new-feature
git add my_notebook.ipynb
git commit -m "Add new feature exploration"
git push origin experiment/new-featureCommit meaningful changes
Notebooks auto-save cell outputs, which creates noisy diffs. Consider:
Clearing outputs before committing:
Cell → All Output → ClearCommitting only when you've made substantial progress
Using descriptive commit messages
Test in a separate project first
If you're setting up Git pushes for the first time, test the workflow in a non-production project to avoid accidentally pushing broken code.
Troubleshooting
Permission denied errors
If you see "Permission denied (publickey)" when pushing:
Verify the private key in Valohai matches the public key in GitHub
Check that "Allow write access" is enabled on the deploy key
Confirm the hostname in Valohai credentials matches your Git provider
Push rejected errors
If your push is rejected:
Pull the latest changes first:
git pull origin mainResolve any merge conflicts
Then retry the push
No remote tracking branch
If Git complains about no upstream branch:
git push --set-upstream origin <branch-name>Next Steps
Save Your Work — Version outputs and log metrics
Convert to Production Script — Move from experimentation to execution
Connect Repo — Set up Git integration for your project
Last updated
Was this helpful?
