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:
  • KeyError – if the user already exists in Argilla.

  • ValueError – if the provided parameters are not valid.

  • 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:
  • ValueError – if the user doesn’t exist in Argilla.

  • RuntimeError – 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")
property is_admin: bool#

Returns whether the current user is an admin or not.

Returns:

A boolean indicating whether the current user is an admin or not.

property is_annotator: bool#

Returns whether the current user is an annotator or not.

Returns:

A boolean indicating whether the current user is an annotator or not.

property is_owner: bool#

Returns whether the current user is an owner or not.

Returns:

A boolean indicating whether the current user is an owner or not.

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.