Use Git repositories¶
Notebooks are represented as .ipynb files in a codespace, which allows you to version both your notebook and non-notebook files using an external Git repository. In addition to initializing a new codespace from a Git repo, you can directly use the Git CLI in a codespace's integrated terminal during an active session. DataRobot integrates with Git providers for you to version your code and collaborate with your team when developing code in a codespace.
Integrate with a Git provider¶
Integrate DataRobot with your Git provider to allow DataRobot to access your repositories using the OAuth 2.0 standard. To integrate with your Git provider, click your user icon and select the OAuth provider management page.
From the OAuth provider management page, select the provider that you want to integrate with. DataRobot supports integrations with GitHub Cloud, GitLab Cloud, Bitbucket Cloud, Microsoft's Azure Repos, and GitLab Enterprise Self-Managed (for on-prem and STS deployments). You only need to complete this integration setup once per Git provider account. The example below outlines authentication with GitHub Cloud.
After choosing a provider, click the actions menu icon () and select Authorize on github.com (the URL will change depending on the provider selected).
DataRobot redirects you to the provider's login page. Sign in to your account and authorize DataRobot's access.
Once authorized, DataRobot redirects you to the Git providers page.
Additional GitHub configuration
GitHub configuration requires an additional step after authorization. Authorizing DataRobot to GitLab or Bitbucket accounts does not require this additional configuration step.
When you return to the Git providers page, DataRobot notifies you to visit the settings page on GitHub to install the DataRobot App. Click Manage Permissions in the notification to get redirected to GitHub.
Install the DataRobot GitHub app on your personal GitHub account and any organization accounts to work with the repositories that belong to them. Select the account you want to integrate with and specify whether you want to install and authorize the DataRobot App for all repositories belonging to that account, or only select repositories. If the DataRobot app is not installed on your personal GitHub account, you will not be able to use the Git integration with your private repositories. After selecting the repositories to authorize, click Install & Authorize.
Manage Git provider integrations¶
To view and manage the permissions for the DataRobot App installed on your Git provider account, navigate to the menu icon for that corresponding provider and click Manage on github.com (the URL will change depend on the provider selected). This redirects you to the corresponding Git provider site to view your authorizations and permissions settings.
The table below provides a list of locations to manage authorization for common OAuth providers.
| Provider | App location | Notes |
|---|---|---|
| GitHub | Github application installation settings page and GitHub application authorizations | The App Authorization section helps to configure and revoke your account authorization, while the Installation settings page helps to configure Github App permissions to repositories for your account. Use the OAuth Management interface to go to the specific application settings page where you can find application configurations for other organizations. |
| GitLab | Gitlab application settings | View the authorized applications table for configuration details. |
| Bitbucket | Bitbucket app authorizations | N/A |
| Microsoft | Microsoft app authorizations | N/A |
To remove DataRobot's authorization to your Git provider account, click Revoke authorization. DataRobot will no longer have access to your account and will delete any associated metadata. However, the DataRobot App may still appear in the Git provider's authenticated app, due to API limitations that prevent DataRobot from fully revoking authorization.
For GitLab and Bitbucket, once you’ve removed authorization, you must complete an additional step in the provider's settings to revoke authorization of the DataRobot OAuth app. For example, in GitLab, revoke the authorization on the Applications page in the GitLab user settings.
In the case where you have revoked authorization on your Git provider’s site but not in DataRobot settings, the authorization will be detected as expired the next time you use Git operations in a codespace for a repository in that corresponding Git account. You will need to re-authorize DataRobot to that Git provider account in order to use this integration again.
Manage additional providers
For more information on managing authentication provider integrations in DataRobot, see Manage OAuth providers.
Develop with Git CLI¶
Once you have authorized DataRobot to your Git provider, you can start using the Git CLI in your codespace sessions from the terminal. You will not need to manually authenticate to your Git account using a personal access token (PAT) each time you run a Git CLI command, as DataRobot automatically handles authentication on your behalf. Behind the scenes, DataRobot uses a custom Git credential helper to accomplish this.
Git CLI authentication
This automatic authentication flow is currently only supported for the Git CLI, and not the GitHub CLI. If you want to use the GitHub CLI in a codespace, you will need to manually authenticate with your personal access token (PAT) when using gh commands in the terminal. You can set your PAT as a GH_TOKEN or GITHUB_TOKEN environment variable. gh will authenticate using that environment variable value.
Git authentication is handled at the individual user level. Even if multiple use case members have access to the same shared codespace in a use case, DataRobot will only attempt to authenticate on behalf of the user who has started the active codespace session based on that user’s authorized Git provider account(s).
You can simply clone remote Git repos and push and pull changes to and from those repos without any additional authentication steps required:
git clone https://github.com/<my-account>/<my-repo>
git pull
If you are using a codespace with a custom environment, Git integration functionality requires the custom environment image to include the DataRobot Git helper binary for private Git authentication:
# Install the Git helper binary used for private git authentication in notebooks and codepaces
RUN curl -L -o drgithelper https://github.com/datarobot-oss/drgithelper/releases/download/v0.0.9/drgithelper && chmod +x drgithelper
You can use a sample environment template as an end-to-end example of how to configure the Dockerfile for configuring a custom environment.
Create a codespace from a Git repository¶
If you would like to create a new codespace instantiated with code from an existing external Git repository, navigate to a Use Case and select Add > Codespace > Upload codespace.
If you are cloning a public repo, provide the Git clone URL (this does not require you to have added an integration with the corresponding Git provider).
To create a codespace from a private repository, select the Private repository tab and choose the provider from the dropdown. Only providers that you have already authorized appear here.
Select the repository you wish to clone. By default, DataRobot displays the most recently updated repositories in the Repository dropdown. Type in the search field to find a specific repository.
In addition to creating a new codespace from a Git repo, you can also directly clone a Git repo into an existing codespace using the Git CLI in the codespace terminal.
Next steps¶
With a codespace session running, automate notebook runs on a schedule or use the integrated terminal to manage your environment further.
- Start a session: Start a codespace session.
- Codespace scheduling: Automate code-based workflows by scheduling notebooks in a codespace to run in non-interactive mode.
- Notebook terminals: Use the integrated terminal to run shell commands, install packages, and execute scripts in a codespace session.
- Manage the notebook environment: Configure the resource type, environment image, and inactivity timeout for a codespace session.












