snorkelai.sdk.develop.User
- final class snorkelai.sdk.develop.User(uid, username, role, default_view, email=None, timezone=None, is_superadmin=False, is_active=True)
Bases:
BaseUser management class for Snorkel SDK.
This class provides methods to create, retrieve, update, and delete users within Snorkel Flow. Each user is assigned a role that determines their permissions, and users are organized within workspaces.
- __init__(uid, username, role, default_view, email=None, timezone=None, is_superadmin=False, is_active=True)
Create a user object in-memory with necessary properties. This constructor should not be called directly, and should instead be accessed through the
create(),get(), andlist()methodsParameters
Parameters
Name Type Default Info uid intThe unique integer identifier for the user within Snorkel Flow. username strThe username of the user. role UserRoleThe role assigned to the user. Defaults to UserRole.standard if not set. default_view UserViewThe default view preference for the user. Defaults to UserView.standard if not set. email Optional[str]NoneThe email address of the user. timezone Optional[str]NoneThe timezone preference for the user. is_superadmin boolFalseWhether the user has superadmin privileges. Defaults to False if not set. is_active boolTrueWhether the user account is active. Defaults to True if not set.
\_\_init\_\_
__init__
Methods
__init__(uid, username, role, default_view)Create a user object in-memory with necessary properties. create(username, password[, role, email, ...])Create a new user. delete(user)Delete a user by UID or username. get(user[, workspace])Get a user by UID or username. list([include_inactive, ...])List all users in a workspace with optional filters. reset_password(user, new_password)Reset any user's password without requiring old password. update([email, role, timezone, ...])Update user properties. Attributes
default_viewThe default view preference for the user emailThe email address of the user is_activeWhether the user account is active is_superadminWhether the user has superadmin privileges roleThe role assigned to the user timezoneThe timezone preference for the user. uidThe unique integer identifier for the user within Snorkel Flow usernameThe username of the user - classmethod create(username, password, role=None, email=None, timezone=None)
Create a new user.
Examples
>>> from snorkelai.sdk.develop import User, UserRole
>>> new_user = User.create(username='jane_smith', password='SecurePass123!', role=UserRole.REVIEWER)
User jane_smith has been created with UID 42.
>>> new_user.username
'jane_smith'Parameters
Parameters
Returns
Returns
The created User object
Return type
Return type
Name Type Default Info username strUsername for the new user. password strPassword for the new user (minimum 12 characters with at least 3 character types). role Optional[UserRole]NoneUser role - ‘standard’, ‘admin’, ‘reviewer’, ‘labeler’, or ‘superadmin’. Defaults to ‘standard’. email Optional[str]NoneEmail address for the user. timezone Optional[str]NoneIANA timezone (e.g., ‘America/Sao_Paulo’, ‘UTC’, ‘Europe/London’).
create
create
- classmethod delete(user)
Delete a user by UID or username.
This performs a soft delete: sets is_active=False and clears email. Use list(include_inactive=True) to view deleted users.
Examples
>>> from snorkelai.sdk.develop import User
>>> User.delete("john_doe")
User john_doe has been deleted.
>>> User.delete(42)
User 42 has been deleted.
delete
delete
- classmethod get(user, workspace=None)
Get a user by UID or username.
Examples
>>> from snorkelai.sdk.develop import User
>>> user = User.get("john_doe")
>>> user.username
'john_doe'
>>> user.uid
42
>>> user.email
'john.doe@example.com'
>>> user = User.get(42, workspace="my-workspace")
>>> user.username
'jane_smith'Parameters
Parameters
Returns
Returns
The user object with all user information
Return type
Return type
Raises
Raises
ValueError – If the user is not found in the specified workspace, or if there is a network error or HTTP error during the request.
Name Type Default Info user Union[str, int]User UID (int) or username (str). workspace Union[str, int, None]NoneWorkspace UID (int) or workspace name (str). If None, uses the default workspace.
get
get
- classmethod list(include_inactive=False, include_superadmins=False, workspace=None)
List all users in a workspace with optional filters.
Examples
>>> from snorkelai.sdk.develop import User
>>> users = User.list()
>>> users[0].username
'john_doe'
>>> inactive_users = User.list(include_inactive=True)
>>> all_users = User.list(include_superadmins=True, workspace="my-workspace")Parameters
Parameters
Returns
Returns
List of User objects matching the filter criteria
Return type
Return type
List[User]
Name Type Default Info include_inactive boolFalseInclude inactive/deleted users in the results. include_superadmins boolFalseInclude superadmin users in the results. workspace Union[str, int, None]NoneWorkspace UID (int) or workspace name (str). If None, uses the default workspace.
list
list
- classmethod reset_password(user, new_password)
Reset any user’s password without requiring old password.
Accepts user UID (int) or username (str).
Examples
>>> from snorkelai.sdk.develop import User
>>> User.reset_password("john_doe", "NewSecurePass123!")
Password for user john_doe has been reset.
>>> User.reset_password(42, "AnotherPass456!")
Password for user 42 has been reset.
reset\_password
reset_password
- update(email=None, role=None, timezone=None, is_superadmin=None, default_view=None)
Update user properties.
Examples
>>> from snorkelai.sdk.develop import User
>>> user = User.get("john_doe")
>>> user.update(email="john.doe@example.com")
User john_doe (UID: 42) has been updated.
>>> user.email
'john.doe@example.com'
>>> user.update(timezone="America/New_York")
User john_doe (UID: 42) has been updated.
>>> user.timezone
'America/New_York'Parameters
Parameters
Return type
Return type
None
Name Type Default Info email Optional[str]NoneEmail address for the user. role Optional[UserRole]NoneUser role - ‘standard’, ‘admin’, ‘reviewer’, ‘labeler’, or ‘superadmin’. timezone Optional[str]NoneIANA timezone (e.g., ‘America/Sao_Paulo’, ‘UTC’, ‘Europe/London’). is_superadmin Optional[bool]NoneWhether the user should be a superadmin. default_view Optional[UserView]NoneDefault view for the user. noteTo deactivate a user (set is_active=False), use User.delete() which performs a soft delete.
update
update
- property default_view: UserView
The default view preference for the user
- property email: str | None
The email address of the user
- property is_active: bool
Whether the user account is active
- property is_superadmin: bool
Whether the user has superadmin privileges
- property role: UserRole
The role assigned to the user
- property timezone: str | None
The timezone preference for the user.
- property uid: int
The unique integer identifier for the user within Snorkel Flow
- property username: str
The username of the user