e3_build_tools.git.registry

Module for interfacing the ESS Gitlab wrapper repositories.

Attributes

Classes

GitLabInterface

Interface to GitLab.

WrapperRegistry

Registry for wrappers and interface to GitLab.

Module Contents

e3_build_tools.git.registry.ESS_GITLAB_URL = 'https://gitlab.esss.lu.se'[source]
e3_build_tools.git.registry.GITLAB_ID_E3_GROUP = 215[source]
e3_build_tools.git.registry.logger[source]
e3_build_tools.git.registry.GitLabCommitPayload[source]
class e3_build_tools.git.registry.GitLabInterface(address: str = ESS_GITLAB_URL, private_token: str | None = None, config: str | None = None, top_group: int = GITLAB_ID_E3_GROUP)[source]

Interface to GitLab.

address = 'https://gitlab.esss.lu.se'[source]
top_group = 215[source]
get_all_projects() List[gitlab.v4.objects.GroupProject][source]

Returns a list of all GroupProjects in the e3 space.

The object returned by Gitlab.groups.get().projects.list() is GroupProject. This needs to be converted to Project to have access to all attributes, but we do not convert at this stage (to keep down the number of calls).

get_project_by_id(_id: int) gitlab.v4.objects.Project[source]

Return a GitLab Project object based on the ID.

Caches previous results to reduce the amount of API calls. We are using the Least Recently Used (LRU) cache but with no limit to the number of elements stored, effectively turning it into an unbound cache.

get_current_user_id() int[source]

Return the current user ID.

Raises:

GitlabAuthenticationError: If authentication is not correct.

create_new_project(name: str, group_id: int) gitlab.v4.objects.Project[source]

Create a new GitLab project.

Raises:

GitlabCreateError: If project already exists in the group.

get_group_by_id(_id: int) gitlab.v4.objects.Group[source]

Return a GitLab Group object based on the ID.

Caches previous results to reduce the amount of API calls. We are using the Least Recently Used (LRU) cache but with no limit to the number of elements stored, effectively turning it into an unbound cache.

class e3_build_tools.git.registry.WrapperRegistry(**kwargs)[source]

Bases: GitLabInterface

Registry for wrappers and interface to GitLab.

The class stores information about the wrapper repositories, and implements the required interfaces to the ESS GitLab repositories.

get_all_wrapper_projects() Dict[str, int][source]

Return a dictionary with the project id for each project.

The returned data is a dictionary with the project name as the keys, and the internal GitLab project ID as the data.

get_project(name: str) gitlab.v4.objects.Project[source]

Return a GitLab Project object based on the name.

Raises:

KeyError: If module name not found.

get_project_id(name: str) int[source]

Return the GitLab ID for a project name.

Raises:

KeyError: If module name not found.

get_config_from(name: str, ref: str, *, file: str) str[source]

Return a module revision’s configuration.

The function fetches the configuration for a wrapper from the GitLab repository at a specified reference (e.g., commit hash, tag, branch).

Raises:

MissingReferenceException: If the reference does not exists on the repository. FileNotFoundException: If name does not exist or if file does not exist for the given reference.

read_version_from(name: str, ref: str, *, config: str, var: str, validate: bool = True) str[source]

Return the configured version for a version of a module.

Raises:

KeyError: If name is not a valid e3-module or file does not exist for the given reference. MissingReferenceException: If the reference does not exists on the repository. FileNotFoundException: If name does not exist or if file does not exist for the given reference.

create_commit_payload(substitutions: Dict[str, Dict[str, str]], starting_reference: str, name: str, branch: str) GitLabCommitPayload[source]

Return representation of JSON data to be used by commit_change().

Raises:

NoModuleChangesException: If there are no changes to be applied to the module.

update_submodule(name: str, submodule_path: str, sha: str, branch: str) None[source]

Update the submodule reference.

commit_change(name: str, payload: GitLabCommitPayload) gitlab.v4.objects.ProjectCommit[source]

Commit changes to project on gitlab.

tag_project(name: str, new_tag: str, ref: str | None = None) gitlab.v4.objects.ProjectTag[source]

Apply a tag to a wrapper repository.

Raises:

KeyError: If name is not a valid e3-module.

get_commit_hash(name: str, reference: str) str[source]

Return the commit hash for a specified reference.

Raises:

KeyError: If name is not a valid e3-module.