Skip to content

hopsworks.core.project_members_api #

ProjectMembersApi #

API for managing the members of a Hopsworks project.

Use Project.get_members_api to get an instance of this class.

add_member #

add_member(
    email: str, role: str
) -> project_member_mod.ProjectMember

Add a single user to the project.

Example
import hopsworks

project = hopsworks.login()

project.get_members_api().add_member("alice@example.com", "Data scientist")
PARAMETER DESCRIPTION
email

Email address of the user to add.

TYPE: str

role

The project role to grant, one of Data owner, Data scientist, Observer, Feature store restricted, or a custom project role. Matched regardless of case.

TYPE: str

RETURNS DESCRIPTION
project_member_mod.ProjectMember

The newly added ProjectMember.

RAISES DESCRIPTION
ValueError

If role is not a role of the project.

hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request, for example if the caller is not a project owner or may not give the role.

RuntimeError

If the add succeeded but email could not be found in the project's member list immediately afterwards.

add_members #

add_members(
    emails_and_roles: dict[str, str],
) -> list[project_member_mod.ProjectMember]

Add one or more users to the project in a single call.

PARAMETER DESCRIPTION
emails_and_roles

Mapping of a member's email to the project role to grant them, one of Data owner, Data scientist, Observer, Feature store restricted, or a custom project role. Roles are matched regardless of case.

TYPE: dict[str, str]

RETURNS DESCRIPTION
list[project_member_mod.ProjectMember]

List of the newly added ProjectMember objects.

RAISES DESCRIPTION
ValueError

If any role is not a role of the project.

hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request, for example if the caller is not a project owner or may not give the role.

get_members #

get_members() -> list[project_member_mod.ProjectMember]

Get all members of the project.

Example
import hopsworks

project = hopsworks.login()

for member in project.get_members_api().get_members():
    print(member.email, member.role)
RETURNS DESCRIPTION
list[project_member_mod.ProjectMember]

List of ProjectMember objects, one per user who has access to the project.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

remove_member #

remove_member(
    email: str,
    delete_home_dir: bool = False,
    new_file_owner: str | None = None,
) -> None

Remove a member from the project by email.

Deletes the member's project files when delete_home_dir=True

All files under this member's home directory in the project are permanently deleted and cannot be recovered.

Example
import hopsworks

project = hopsworks.login()

project.get_members_api().remove_member("alice@example.com")
PARAMETER DESCRIPTION
email

Email address of the member to remove.

TYPE: str

delete_home_dir

Whether to also delete the member's home directory in the project.

TYPE: bool DEFAULT: False

new_file_owner

Email address of the data owner that takes over the removed member's home directory. Defaults to the data owner who has been in the project longest. Ignored when delete_home_dir is set, since there is then nothing to take over.

TYPE: str | None DEFAULT: None

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request, for example if a data scientist tries to remove someone other than themselves.

transfer_ownership #

transfer_ownership(email: str) -> None

Hand the project over to another data owner of the project.

Only the current owner can do this. The previous owner stays a data owner, so they can afterwards be removed like any other member. This also works in projects whose members are managed by group mapping, since no membership changes.

Example
import hopsworks

project = hopsworks.login()

project.get_members_api().transfer_ownership("carol@example.com")
PARAMETER DESCRIPTION
email

Email address of the data owner who becomes the project owner.

TYPE: str

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request, for example if the caller does not own the project or the new owner is not a data owner of it.

update_role #

update_role(
    email: str, role: str
) -> project_member_mod.ProjectMember | None

Change a project member's role by email.

Example
import hopsworks

project = hopsworks.login()

project.get_members_api().update_role("alice@example.com", "Observer")
PARAMETER DESCRIPTION
email

Email address of the member to update.

TYPE: str

role

The new project role, one of Data owner, Data scientist, Observer, Feature store restricted, or a custom project role. Matched regardless of case.

TYPE: str

RETURNS DESCRIPTION
project_member_mod.ProjectMember | None

The updated ProjectMember, or None if the member could not be

project_member_mod.ProjectMember | None

found immediately after the update.

RAISES DESCRIPTION
ValueError

If role is not a role of the project.

hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request, for example if the caller is not a project owner, may not give the role, or email is the project owner.