User

Developer guide for managing team members using the Python SDK.

Client

import labelbox as lb
client = lb.Client(api_key="<YOUR_API_KEY>")

Get the current user

user = client.get_user()

Methods

Update an organization role

# get the available roles
roles = client.get_roles()

# update the role (in this case, the user is granted labeler permissions)
user_to_update.update_org_role(roles["LABELER"])

Upsert a project-based role

# get the available roles
roles = client.get_roles()

# get the project
project = client.get_project("<project_id>")

# update the project-based role (in this case, the user is granted reviewer permissions)
user_to_update.upsert_project_role(
  project=project,
  role=roles["REVIEWER"]
)

Remove from a project

# get the project
project = client.get_project("<project_id>")

# remove from the project
user_to_remove.remove_from_project(project)

Manage user groups

from labelbox.schema.user_group import UserGroup, UserGroupColor

# Create a user group
user_group = UserGroup.create(
    client=client,
    name="New User Group",
    color=UserGroupColor.BLUE
    users=set(user, user1, user2),
    projects=set(project)
)

# Update a user group
user_group.update(
    name="Updated User Group Name",
    color=UserGroupColor.GREEN
)

# Get info of a user group
user_group.get()

# Delete a user group
user_group.delete()

# Get all user groups in your workspace
UserGroup.get_user_groups(client)

Attributes

Get the basics

# name (str)
user.name

# nickname (str)
user.nickname

# email (str)
user.email

# created at (datetime)
user.created_at

# updated at (datetime)
user.updated_at

# role (relationship to OrgRole object)
role = user.org_role()

# organization (relationship to Organization object)
organization = user.organization()

Get the projects

# get the projects (relationship to Project objects)
projects = user.projects()

# inspect one project
next(projects)

# inspect all projects
for project in projects:
  print(project)

# for ease of use, you can convert the paginated collection to a list
list(projects)

Get the created tasks

# get the tasks (relationship to Task objects)
tasks = user.created_tasks()

# inspect one project
next(tasks)

# inspect all projects
for task in tasks:
  print(task)

# for ease of use, you can convert the paginated collection to a list
list(tasks)