Users#
Here we describe how to manage users in Argilla via the Python client.
- class argilla.client.users.User(name: Optional[str] = None, *, id: Optional[Union[str, UUID]] = None)#
The User class is used to manage users in Argilla. It provides methods to create new users, list all the users, get a user by its name or ID, and delete it. While itโs not allowed to update the user information for the moment.
- Parameters:
name โ the name of the user to be managed. Defaults to None.
id โ the ID of the user to be managed. Defaults to None.
- _client#
the httpx.Client initialized to interact with the Argilla API.
- Type:
httpx.Client
- id#
the ID of the user.
- Type:
uuid.UUID
- username#
the username of the user.
- Type:
str
- first_name#
the first name of the user.
- Type:
str
- last_name#
the last name of the user. Defaults to None.
- Type:
Optional[str]
- full_name#
the full name of the user. Defaults to None.
- Type:
Optional[str]
- role#
the role of the user.
- Type:
argilla.client.sdk.users.models.UserRole
- api_key#
the API key of the user.
- Type:
str
- inserted_at#
the datetime when the user was created.
- Type:
datetime.datetime
- updated_at#
the datetime when the user was last updated.
- Type:
datetime.datetime
Examples
>>> from argilla import rg >>> user = rg.User.from_name("my-user") # or `User.from_id("...")` >>> print(user) User(id='...', username='my-user', role='annotator', first_name='Luke', last_name="Skywalker', full_name='Luke Skywalker', role='annotator', api_key='...', inserted_at=datetime.datetime(2021, 8, 31, 10, 0, 0), updated_at=datetime.datetime(2021, 8, 31, 10, 0, 0))
- classmethod create(username: str, password: str, *, first_name: Optional[str] = None, last_name: Optional[str] = None, role: Optional[UserRole] = None, workspaces: Optional[List[str]] = None) User #
Creates a new user in Argilla.
- Parameters:
username โ the username of the user to be created.
password โ the password of the user to be created.
first_name โ the first name of the user to be created. Defaults to None.
last_name โ the last name of the user to be created. Defaults to None.
role โ the role of the user to be created. Defaults to None.
workspaces โ a list of workspace names the user to be created is linked to. Defaults to None.
- Returns:
A new User instance.
- Raises:
ValueError โ if the user already exists in Argilla.
RuntimeError โ if the user cannot be created in Argilla.
Examples
>>> from argilla import rg >>> user = rg.User.create("my-user", "my-password", role="admin")
- delete() None #
Deletes the user from Argilla.
- Raises:
BaseClientError โ if the user cannot be deleted from Argilla.
Examples
>>> from argilla import rg >>> user = rg.User.from_name("my-user") >>> user.delete()
- classmethod from_id(id: UUID) User #
Gets an existing user from Argilla by its ID.
- Parameters:
id โ the ID of the user to be retrieved.
- Returns:
A User instance.
- Raises:
ValueError โ if the user with the provided ID doesnโt exist.
RuntimeError โ if there was an error while retrieving the user.
Examples
>>> from argilla import rg >>> user = rg.User.from_id("my-user")
- classmethod from_name(name: str) User #
Gets an existing user from Argilla by its name.
- Parameters:
name โ the name of the user to be retrieved.
- Returns:
A User instance.
- Raises:
ValueError โ if the user with the provided name doesnโt exist.
RuntimeError โ if there was an error while retrieving the user.
Examples
>>> from argilla import rg >>> user = rg.User.from_name("my-user")
- classmethod list() Iterator[User] #
Lists all the users in Argilla.
- Returns:
An iterator of User instances.
- Raises:
RuntimeError โ if there was an error while listing the users.
Examples
>>> from argilla import rg >>> for user in rg.User.list(): ... print(user)
- classmethod me() User #
Gets the current user from Argilla.
- Returns:
A User instance.
- Raises:
RuntimeError โ if there was an error while retrieving the current user.
Examples
>>> from argilla import rg >>> user = rg.User.me()
- property workspaces: Optional[List[WorkspaceModel]]#
Returns the workspace names the current user is linked to.
- Returns:
A list of WorkspaceModel the current user is linked to.