Package: jupyterlab-gitlab-msg
JupyterLab GitLabA JupyterLab extension for browsing GitLab repositories (in read-only mode).This extension is based onjupyterlab-github.
All credit to the JupyterLab team, and especiallyIan Rose, for the github extension!Thanks as well toMark Ghiorsofor thejupyterlab_gitlabextension where I took some inspiration. It didn't fit my needs (no server extension) so I decided to create my own based on a recent
version of jupyterlab-github instead (v0.10.0).What this extension isWhen you install this extension, an additional filebrowser tab will be added
to the left area of JupyterLab. This filebrowser allows you to select GitLab
groups and users, browse their repositories, and open the files in those
repositories. If those files are notebooks, you can run them just as you would
any other notebook. You can also attach a kernel to text files and run those.
Basically, you should be able to open any file in a repository that JupyterLab can handle.WARNING! Subgroups are currently not supported.Here is a screenshot of the plugin opening this very file on GitLab:What this extension is notThis is not an extension that provides full GitLab access, such as
saving files, making commits, forking repositories, etc.If you want to use git from JupyterLab, you should look at thejupyterlab-gitextension.RemarksThis extension has both a client-side component (that is, Javascript that is bundled
with JupyterLab), and a server-side component (that is, Python code that is added
to the Jupyter notebook server). This extensionwillwork without the server extension,
with some drawbacks:requests will be unauthenticated and only give access to public repositoriesunauthenticated requests can impose rate-limits depending on your GitLab instance
(meaning you might have to wait before regaining access)only the 20 first results are returned (pagination links are not followed)For those reasons, you should set up the server extension as well as the lab extension.
This process is described in theinstallationsection.PrerequisitesJupyterLab 1.x for version < 2.0JupyterLab 2.0 for version >= 2.0A GitLab account for the server extensionInstallationAs discussed above, this extension has both a server extension and a lab extension.
We recommend installing both to allow authentication and pagination.
The purpose of the server extension is to add GitLab credentials that you will need to acquire
fromhttps://gitlab.com/profile/personal_access_tokens, and then to proxy your request to GitLab.
Note that OAuth2 token are also supported.1. Installing the lab extensionTo install the lab extension, enter the following in your terminal:jupyterlabextensioninstalljupyterlab-gitlabWith only this installed, the extension should work.2. Getting your credentials from GitLabYou need to create a personal access token to authenticate yourself to GitLab.Go tohttps://gitlab.com/profile/personal_access_tokensor from GitLab, go to yourSettings_ >Access Tokens_.UnderName, enter a short description, to identify the purpose
of this token. I recommend something like:jupyterlab-gitlab.Under Scopes, check theapiscope.ClickCreate personal access token. You will see your new personal access token (a 21 characters string).
Click on the copy to clipboard icon and and paste it locally in a text file for now.
If you have a password manager like 1password, use that.This is the only time you'll see this token in GitLab. If you lose it, you'll
need to create another one.3. Installing the server extensionInstall the server extension using pip, and then enable it:pipinstalljupyterlab-gitlab-msgIf you are running Notebook 5.3 or later, this will automatically enable the extension.
If not, enable the server extension by running:jupyterserverextensionenable--sys-prefixjupyterlab_gitlabYou can check if the server extension is enabled by running:jupyterserverextensionlistYou should now add the credentials you got from GitLab to your notebook configuration file.
Instructions for generating a configuration file can be foundhere.
Once you have identified this file, add the following line to it:c.GitLabConfig.access_token="< YOUR_ACCESS_TOKEN >"where< YOUR_ACCESS_TOKEN >is the string value you obtained above.
It can also be an OAuth2 token.CustomizationCustomizing the server extensionYou saw how to add youraccess_tokento the notebook configuration file.
There are other parameters than you can modify using that file.
Those are the default values:c.GitLabConfig.allow_client_side_access_token=Falsec.GitLabConfig.url="https://gitlab.com"c.GitLabConfig.validate_cert=TrueIf you run your own GitLab instance for example, updatec.GitLabConfig.urlto point to it.Customizing the lab extensionYou can set the plugin to start showing a particular repository at launch time.
Open the "Advanced Settings" editor in the JupyterLab Settings menu,
and under the GitLab settings add{"baseUrl":"https://gitlab.com","defaultRepo":"owner/repository"}whereowneris the GitLab user or group,
andrepositoryis the name of the repository you want to open.ThebaseUrlcan also be updated to point to your own GitLab instance.
If you use the server extension, this url is only used for theOpen this repository on GitLabbutton.