How to import code from GitHub, GitLab, or Bitbucket¶
When working with code, it’s widespread to use libraries for isolating any reusable pieces of code and version them separately from the projects in which they’re used. If they are available in a Git repository, Dataiku DSS provides a way to import Python and R libraries so that they can be used in any code capability of DSS, including recipes, notebooks, or web apps.
Since the import is entirely based on Git, it works with any Git hosting service like Github, Gitlab or Bitbucket. Also, it can be a public or a private repository, as long as Dataiku DSS has been configured to have access to it.
First, from the project on which you want to import the code, navigate to the Libraries page.
From here, you can develop new libraries, or you can decide to import an existing one from a remote Git repository. Click on the Git button, and select Import from Git.
Then, fill in the following fields:
“Repository” must contain the URL for cloning the repository.
The “Checkout” field can contain:
The name of the branch to checkout (If you click on the refresh button next to this field, DSS will fetch the repository and will list the available branches.)
A commit hash
“Path in repository” allows you to configure a path to a subfolder within the library repository. It can be particularly useful if multiple libraries are stored within the same repository, and if you need to import some of them only, rather than importing the entire repository in your project.
“Target path” allows you to configure the local path where the libs will be imported. Leave empty to import them in the lib folder.
“Add to python path” allows you to add the local path to the lib into the PYTHONPATH environment variable, allowing you to use the library without additional configuration wherever it has been imported.
Click on “Save and Retrieve” to proceed to the importation of the external library into the project.
Dataiku DSS has created a “Git reference”, which allows the imported code to be updated by pulling new updates from the remote repository anytime, either manually, or automatically thanks to our scenario step.
The imported library can now be used from anywhere in the project.
In our example, we just need to write the following line to use it:
from autokeras_dataiku import *
For more information about how to use Git references, see Importing code from Git in project libraries.
For more details about all the other ways DSS integrates with Git, including projects, libraries, and plugins, and how to configure DSS to access private repositories, see Working with Git.
For a full tutorial on how to import code from Git, see Cloning a Library from a Remote Git Repository.
For a video showing how to use this feature, see How to import code from Git into a DSS project library.