OUP> --project=<PROJECT> \

--token=<GITLAB_TOKEN>where <NAME> is the name of the code repository you are registering, <GROUP> is the group of the project, <PROJECT> is the name of the project, <GITLAB_TOKEN> is your GitLab Personal Access Token, and <GITLAB_URL> is the URL of the GitLab instance which defaults to https://gitlab.com. You will need to set a URL if you have a self-hosted GitLab instance.

After registering the GitLab code repository, ZenML will automatically detect if your source files are being tracked by GitLab and store the commit hash for each pipeline run.

Go to your GitLab account settings and click on Access Tokens.

Name the token and select the scopes that you need (e.g. read_repository, read_user, read_api)

Click on "Create personal access token" and copy the token to a safe place.

Developing a custom code repository

If you're using some other platform to store your code, and you still want to use a code repository in ZenML, you can implement and register a custom code repository.

First, you'll need to subclass and implement the abstract methods of the zenml.code_repositories.BaseCodeRepository class:

class BaseCodeRepository(ABC):

"""Base class for code repositories."""

@abstractmethod

def login(self) -> None:

"""Logs into the code repository."""

@abstractmethod

def download_files(

self, commit: str, directory: str, repo_sub_directory: Optional[str]

) -> None:

"""Downloads files from the code repository to a local directory.

Args:

commit: The commit hash to download files from.

directory: The directory to download files to.

repo_sub_directory: The subdirectory in the repository to

download files from.

"""

@abstractmethod

def get_local_context(

self, path: str

) -> Optional["LocalRepositoryContext"]:

"""Gets a local repository context from a path.

Args:

path: The path to the local repository.

Returns:

The local repository context object.

"""

After you're finished implementing this, you can register it as follows: