GitLab Version Control for Jupyter Notebooks¶
To use the version control for Notebooks using GitLab, you must perform the following tasks:
After configuring the GitLab Repository, you can perform the following tasks to manage the notebook versions:
- Pushing Commits to Linked GitLab
- Viewing and Comparing the Jupyter Notebook Versions
- Restoring a Commit from GitLab
- Creating a Pull Request from Jupyter Notebooks
- Resolving Conflicts While Using GitLab
Configuring a GitLab Token¶
You can configure a GitLab Token for Jupyter notebooks at per user and per account setting level from the My Accounts or JupyterLab interface.
To configure the GitLab token for Jupyter notebooks for your account, see Configuring a GitLab Token.
To configure the GitLab token from Jupyter notebooks, perform the following steps:
Navigate to Notebooks >> Jupyter and open a Jupyter notebook.
From the left sidebar, click on the GitLab Versions icon as shown in the following figure.
Click Configure now.
In the dialog box add the generated GitLab token and click Save.
The GitLab token is now configured for your account.
Viewing and Comparing the Jupyter Notebook Versions¶
You can view a particular version of the Jupyter notebook by using the View option in the GITLAB VERSIONS sidebar as shown below.
You can compare a version of the Jupyter notebook with the previous version or version with current changes by using the Compare option in the GITLAB VERSIONS sidebar as shown below.
The Compare icon on top of the left sidebar compares the current notebook with the head of the branch. The Compare hyperlink in the left sidebar compares the given version with the previous version.
The following image shows a sample comparison of Jupyter notebook versions.
Restoring a Commit from GitLab¶
- Open the required Jupyter notebook.
- From the left sidebar, click on the GitLab Versions icon.
- Select a version from the list and click Restore to checkout that version.
- Click OK to checkout that version in the confirmation dialog box.
Qubole does not store commits or revisions of notebooks. However, commits or revisions of notebooks can be fetched from users’ GitLab account whenever required.
Creating a Pull Request from Jupyter Notebooks¶
Open the required Jupyter notebook.
From the left side bar, click on the GitLab Versions icon.
Click on the Gear icon in the GITLAB VERSIONS pane. The Link Notebook to GitLab dialog is displayed.
Click on the Create PR hyperlink.
Proceed with the steps in GitLab to create the PR.
For more information, see GitLab Documentation.
Resolving Conflicts While Using GitLab¶
There may be conflicts while pushing/checking out commits in the GitLab versions.
You can use the option force commit to force push over the old commit (irrespective of any conflict).
Perform the following steps to resolve conflicts in commits:
- Clone the notebook.
- Link the cloned notebook to the same GitLab repo branch and path as the original notebook.
- Checkout the latest version of the cloned notebook.
- Manually port changes from the original notebook to the cloned notebook.
- You can commit the cloned notebook after porting changes.