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: _ROLE_ARG
) -> 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. Matched regardless of case.

TYPE: _ROLE_ARG

RETURNS DESCRIPTION
project_member_mod.ProjectMember

The newly added ProjectMember.

RAISES DESCRIPTION
ValueError

If role is not a settable project role.

hopsworks.client.exceptions.RestAPIError

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

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, _ROLE_ARG],
) -> 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. Roles are matched regardless of case.

TYPE: dict[str, _ROLE_ARG]

RETURNS DESCRIPTION
list[project_member_mod.ProjectMember]

List of the newly added ProjectMember objects.

RAISES DESCRIPTION
ValueError

If any role is not a settable project role.

hopsworks.client.exceptions.RestAPIError

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

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
) -> 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

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.

update_role #

update_role(
    email: str, role: _ROLE_ARG
) -> 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. Matched regardless of case.

TYPE: _ROLE_ARG

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 settable project role.

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 email is the project owner.