User Group

UserGroup implementation for Labelbox Python SDK.

This module provides the UserGroup class and related functionality for managing user groups in Labelbox.

labelbox.schema.user_group.INVALID_USERGROUP_ROLES = frozenset({'NONE', 'TENANT_ADMIN'})

Roles that cannot be assigned to UserGroup members.

  • NONE: Project-based role

  • TENANT_ADMIN: Special Administrative role

class labelbox.schema.user_group.UserGroup(client: Client, id: str = '', name: str = '', color: UserGroupColor = UserGroupColor.BLUE, description: str = '', notify_members: bool = False, members: Set[UserGroupMember] | None = None, projects: Set[Project] | None = None)[source]

Bases: BaseModel

Represents a user group in Labelbox.

UserGroups allow organizing users and projects together for access control and collaboration. Each user is added with an explicit role via UserGroupMember.

id

Unique identifier for the user group.

Type:

str

name

Display name of the user group.

Type:

str

color

Visual color identifier for the group.

Type:

labelbox.schema.user_group.UserGroupColor

description

Optional description of the group’s purpose.

Type:

str

notify_members

Whether to notify members of group changes.

Type:

bool

members

Set of UserGroupMember objects with explicit roles.

Type:

Set[labelbox.schema.user_group.UserGroupMember]

projects

Set of projects associated with this group.

Type:

Set[labelbox.schema.project.Project]

client

Labelbox client instance for API communication.

Type:

labelbox.client.Client

Note

Only users with no organization role (orgRole: null) can be added to UserGroups. Users with any organization role will be rejected.

create() UserGroup[source]

Create a new user group in Labelbox.

Returns:

Self with ID and updated information from the server.

Raises:
  • ValueError – If group already has ID, name is invalid, or projects don’t exist.

  • ResourceCreationError – If creation fails, user validation fails, or users have workspace-level org roles.

  • ResourceConflict – If a group with the same name already exists.

delete() bool[source]

Delete the user group from Labelbox.

Returns:

True if deletion was successful.

Raises:
get() UserGroup[source]

Reload the user group information from the server.

Returns:

Self with updated information from the server.

Raises:
  • ValueError – If group ID is not set.

  • ResourceNotFoundError – If the group is not found on the server.

static get_user_groups(client: Client, page_size: int = 100) Iterator[UserGroup][source]

Get all user groups from Labelbox with pagination support.

Parameters:
  • client – Labelbox client for API communication.

  • page_size – Number of groups to fetch per page.

Yields:

UserGroup instances for each group found.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'client': FieldInfo(annotation=Client, required=True), 'color': FieldInfo(annotation=UserGroupColor, required=True), 'description': FieldInfo(annotation=str, required=False, default=''), 'id': FieldInfo(annotation=str, required=True), 'members': FieldInfo(annotation=Set[labelbox.schema.user_group.UserGroupMember], required=False, default_factory=set), 'name': FieldInfo(annotation=str, required=True), 'notify_members': FieldInfo(annotation=bool, required=False, default=False), 'projects': FieldInfo(annotation=Set[labelbox.schema.project.Project], required=False, default_factory=set)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

update() UserGroup[source]

Update the group in Labelbox.

Returns:

Self with updated information from the server.

Raises:
  • ValueError – If group ID or name is not set, or if projects don’t exist.

  • ResourceNotFoundError – If the group or projects are not found.

  • UnprocessableEntityError – If user validation fails or users have workspace-level org roles.

class labelbox.schema.user_group.UserGroupColor(value)[source]

Bases: Enum

Enum representing the available colors for user groups.

Each color is represented by its hex color code value.

class labelbox.schema.user_group.UserGroupMember(user: User, role: Role)[source]

Bases: object

Represents a user with their role in a user group.

This class encapsulates the relationship between a user and their assigned role within a specific user group.

user

The User object representing the group member.

Type:

labelbox.schema.user.User

role

The Role object representing the user’s role in the group.

Type:

labelbox.schema.role.Role