Importing code from Git in project libraries

Overview

If you have code that has been developed outside of DSS and is available in a Git repository (for example, a library created by another team), you can import this repository (or a part of it) in the project libraries, and use it in any code capability of DSS (recipes, notebooks, webapps, …)

In the project libraries, you can import multiple external repositories, and declare which parts of said repositories should be treated as being part of the project source paths.

This mechanism is called “Git references”.

Importing a new repository

  • Go to the project’s library editor

  • Click “Git” > “Import from Git…”

  • Enter the URL of the Git repository. Optionally, enter a branch name, tag name or commit id to import

  • Optionally, enter a subpath if you only want to import a part of the repository

  • Enter the “Target path”: where in the hierarchy of libraries you want to import this repository

When you click “Save and Retrieve”, the repository is fetched. The page will be reloaded, so it is advised that you save your unsaved work before importing a new repository.

For more details on working with Git remotes, including SSH setup with Git group rules and per-user SSH keys in Profile > Credentials > SSH, see Working with Git

Managing large repositories

Exclusion patterns let you choose which files DSS excludes when synchronizing a library with a Git repository. New references exclude common large or generated files by default. You can edit these patterns in the Git reference dialog.

Files matching these patterns are not retrieved from the remote repository, and local changes to them are not committed or pushed. If a matching file already exists in your local library, DSS keeps it unchanged when retrieving remote updates. For example, adding an exclusion after importing a file stops future synchronization but does not delete its local copy. Exclusions do not remove files from the project Git history.

Patterns use Git ignore syntax and are relative to the repository root, including when importing a subdirectory. For example, when importing dataikuapi, use /dataikuapi/cache/ to exclude its cache directory. Patterns apply whether the reference targets a branch, tag, or specific commit ID.

Before importing or updating the library, DSS checks the total size of the content selected for synchronization. If you selected a subdirectory, only content within that subdirectory counts towards the limits.

  • Warning threshold: DSS displays a warning. You can continue the import, or exclude more files using exclusion patterns and retry.

  • Maximum size: DSS blocks the import. You must reduce the selected content before retrying. Users cannot bypass this limit for an operation.

Note

For instances running Git earlier than 2.28, DSS must check out all files before applying the exclusion patterns. Excluded files are still excluded from synchronization, but their size counts towards the import limits within the selected directory. Upgrading to Git 2.28 or later enables sparse checkout, so excluded files are also excluded from the size check.

An administrator can change these instance-wide limits by editing DATADIR/config/dip.properties:

dku.projectLibraries.git.softMaxSizeMB=1000
dku.projectLibraries.git.hardMaxSizeMB=2000

Both values are expressed in megabytes. DSS compares sizes in bytes: content exactly at a limit is allowed, while content exceeding it by even one byte triggers that limit. Displayed sizes are rounded; hover over a size in the warning dialog to see its exact byte count.

The defaults are 1000 MB for the warning threshold and 2000 MB for the maximum size. Set the maximum size higher than the warning threshold so that users can explicitly continue after a warning. These limits apply to all Git project libraries on the instance and cannot be configured per project or per Git reference. Users can customize exclusion patterns for each reference.

Manage repositories

You can manage your libraries in a dedicated window. To access this window, go to the project’s library editor and click “Git” > “Manage repositories…” This window allows you to:

Working with Git references

Push local changes to git

You can push your local changes from DSS to git, using of the three possible actions:

  • Use the manage repositories window

  • Right-click on the library that contains your changes and select “Commit and push…”

  • Click on “Git” > “Commit and push all…”

Each of these actions allows you to commit your changes and push them to git. You will have the option to provide your own commit message.

In the event of a conflict, the conflicting files will be loaded into the editor, alongside the traditional git markers (<<<<, ====, >>>>). For each conflicting file, you will have to resolve the conflict and mark the file as resolved (by clicking the appropriate button located at the top right). Once all files have been marked, you can commit and push your changes.

In the event of a conflict, you can also choose to abandon the resolution of the conflict and revert to the version before the commit attempt.

Reset from remote HEAD

Once the repository is retrieved, you can perform modifications to the files in DSS. Please note that if you are working on a library that is used in other projects, all changes to this library will be taken into account in all projects.

Once the repository has been retrieved, it can be imported in Python and R code. See reusing Python code and reusing R code.

To update a reference, either use:

  • “Git” > “Manage repositories…” > “Reset from remote HEAD”

  • Right-click on the root path of the Git reference and click “Reset from remote HEAD”

This action replaces synchronized files with their remote versions, so local changes to those files are lost. Local files matching the reference’s exclusion patterns are preserved, including their local modifications.

If changes have been detected, you will see a confirmation window. This happens when you (or some of your colleagues) have some “unpushed” changes.

Reset from remote HEAD

Reset from remote HEAD

Please note that any change made on a DSS version older than DSS 10.0.0 will not be detected. For example, if you have some unpushed changes from a previous version of DSS, and then migrate to a newer version, you will not be able to see this window until you make additional changes to your library.

Edit a git reference

The edit reference window allows you to edit and update a git reference and then import a repository. You have to provide the same information as required for importing a new repository.

To edit a git reference, either use:

  • “Git” > “Manage repositories…” > “Edit reference”

  • Right-click on the root path of the Git reference and click “Edit Git reference…”

Update all references

Selecting this option will reset from the remote HEAD all your libraries. Please note that if you select this option, it will override the mechanism that prevents you from pulling a library if you have made changes to a library.