Skip to content

PLT-2655 - Fix UserGroup -project membership- and remove "users" #1989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

paulnoirel
Copy link
Contributor

@paulnoirel paulnoirel commented Jun 16, 2025

Description

PLT-2655
To resolve the problems with group memberships encountered when using UserGroup, methods have been updated to utilise V3 APIs.
This is a breaking change: to reduce customer confusion, there will be a new way to create a group with members.

Changes

Create

import labelbox as lb
from labelbox.schema.user_group import UserGroup, UserGroupColor, UserGroupMember
API_KEY = "<API_KEY>"

client = lb.Client(API_KEY)
roles = client.get_roles()

users = (u for u in client.get_users() if u.org_role().name == 'None')
projects = client.get_projects()

user_group_with_roles = UserGroup(
    client=client,
    name="User Group with Explicit Roles",
    color=UserGroupColor.GREEN,
    members={
        UserGroupMember(user=next(users), role=roles["LABELER"]),
        UserGroupMember(user=next(users), role=roles["REVIEWER"]),
        UserGroupMember(user=next(users), role=roles["LABELER"])
    },
    projects={next(projects)},
    description="Basic test"
)
created_group_with_roles = user_group_with_roles.create()

Update

created_group_with_roles.members.add(UserGroupMember(next(users), roles["TEAM_MANAGER"]))

created_group_with_roles.projects.add(next(projects))

created_group_with_roles.description = "New group"

created_group_with_roles.update()

Delete

created_group_with_roles.delete()

Fixes # PLT-2655

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Document change (fix typo or modifying any markdown files, code comments or anything in the examples folder only)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

New Feature Submissions

  • Does your submission pass tests?
  • Have you added thorough tests for your new feature?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Have you added a Docstring?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

@paulnoirel paulnoirel marked this pull request as ready for review June 16, 2025 19:25
@paulnoirel paulnoirel requested a review from a team as a code owner June 16, 2025 19:25
@paulnoirel paulnoirel merged commit 9289f6e into develop Jun 16, 2025
43 of 45 checks passed
@paulnoirel paulnoirel deleted the pno/fix-user-group-remove-users branch June 16, 2025 20:34
mrobers1982 added a commit that referenced this pull request Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants