Datalore 2024.5 Help

Use Git repositories as workspace resources

The procedures below explain how to manage your Git repositories as workspace resources.

Purpose and benefits

Add a Git repository to your workspace resources if you want to use it as a Python library with a setup.py file in it. Once added to the selected workspace, this repository can be installed into any notebook residing in that workspace. It has the following benefits:

  • You set up, store, and manage Git repositories on workspace level.

  • You can attach Git repositories to any notebook from the workspace where these repositories reside.

  • When setting up a Git repository, you use SSH keys stored in the same workspace.

  • This approach ensures SSH keys security as they are never accessible on the agent.

Add a Git repository to a workspace

The procedure explains how to add a Git repository to a workspace from the Home page.

  1. On the Home page, select the workspace to which you want to add the repository.

  2. From the left-hand side menu, select Other and switch to the Repositories tab. This will open the list of Git repositories in the selected workspace.

    Repositories tab
  3. On the Repositories tab, click the Add button in the upper right corner.

  4. In the Add repository connection dialog, do the following:

    1. In the Display name field, provide a name under which the repository will be listed in the workspace.

    2. Provide the URL of the repository in the respective field.

    3. (Optional) To provide an SSH key, expand the list under SSH key and select one of the keys available in this workspace. For more details, see Manage SSH keys.

    4. For Default reference, select the repository branch you want to reference. To use a branch other than the default one, click Fetch the list of available repository references, expand the Default reference list, and select a branch.

    5. Click the Test connection button.

    6. Once the connection is successfully tested, click the Create and close button.

      Add repository connection dialog

Now that the new Git repository connection is added, you can attach it to notebooks.

Add a Git repository through notebook environment

The procedure adds a Git repository to the environment of the selected notebook as a Python library and also adds it to the resources of the respective workspace, which makes it available for any other notebook residing there.

  1. Open the notebook and click the Environment icon on the left-hand sidebar of the editor.

  2. Switch to the Repositories tab.

  3. Click the Add connection button.

    Repositories tab in notebook Environment tool
  4. In the Add repository connection dialog, do the following:

    1. In the Display name field, provide a name under which the repository will be listed in the workspace.

    2. Provide the URL of the repository in the respective field.

    3. (Optional) To provide an SSH key, expand the list under SSH key and select one of the keys available in this workspace. For more details, see Manage SSH keys.

    4. For Default reference, select the repository branch you want to reference. To use a branch other than the default one, click Fetch the list of available repository references, expand the Default reference list, and select a branch.

    5. Click the Test connection button.

    6. Once the connection is successfully tested, click the Create and close button.

      Add repository connection dialog

Manage workspace Git repositories

  1. On the Home page, select the workspace to which you want to add the repository.

  2. From the left-hand side menu, select Data and switch to the Repositories tab. This will open the list of Git repositories in the selected workspace.

  3. In the Repositories view, right-click the repository you want to manage.

  4. Use the following options available in the popup menu:

    • Edit: to change the display name, URL, SSH key, or default reference of the repository.

    • Rename: to change the display name of the repository.

    • Clone: to close the repository to the same workspace. It will be added to the same list under a slightly different name.

    • Clone to other workspaces: to clone the repository to other workspaces. You will be prompted to select where to clone the repository.

Attach a workspace Git repository to a notebook

This is the easiest way to install a publicly available Git repository from the user interface into a single Datalore notebook.

  1. Open the notebook and click the Environment icon on the left-hand sidebar of the editor.

  2. Switch to the Repositories tab.

  3. Click the Select repository to attach to expand the list of workspace repositories.

  4. Select a repository from the expanded list.

    Selecting a Git repository to attach
  5. In the Select reference popup window, do one of the following:

    • Click the Apply button to use the default reference set on the workspace level.

    • Select the other radio button to override the default reference, select a branch, and click the Apply button.

    Select reference dialog
  6. After the repository is attached, click restart kernel in the notification popup to complete the environment update.

If you want to access a private Git repository with a personal token or via credentials, use the init.sh script.

Manage notebook's attached Git repositories

  1. In the notebook, open the Environment tool from the left-hand sidebar.

  2. Switch to Repositories.

  3. In the repository list, right-click the item you want to manage.

  4. Use the following options available in the popup menu:

    • Update repository: to update the attached repository.

    • Change reference: to change the repository reference. You can select the default reference set on the workspace level or any other repository branch.

    • Edit: to change the display name, URL, SSH key, or default reference of the repository.

    • Show installation log: to view or copy the log of the repository installation.

    • Detach connection: to detach the repository connection from the notebook. The repository connection will remain available as a workspace resource.

    Manage attached Git repositories in notebook
Last modified: 28 October 2024