Users#

Here we describe how to manage users in Argilla via the Python client.

class argilla.client.users.User(name=None, *, id=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 (Optional[str]) โ€“ the name of the user to be managed. Defaults to None.

  • id (Optional[Union[str, UUID]]) โ€“ 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, password, *, first_name=None, last_name=None, role=None, workspaces=None)#

Creates a new user in Argilla.

Parameters:
  • username (str) โ€“ the username of the user to be created.

  • password (str) โ€“ the password of the user to be created.

  • first_name (Optional[str]) โ€“ the first name of the user to be created. Defaults to None.

  • last_name (Optional[str]) โ€“ the last name of the user to be created. Defaults to None.

  • role (Optional[UserRole]) โ€“ the role of the user to be created. Defaults to None.

  • workspaces (Optional[List[str]]) โ€“ 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.

Return type:

User

Examples

>>> from argilla import rg
>>> user = rg.User.create("my-user", "my-password", role="admin")
delete()#

Deletes the user from Argilla.

Raises:
  • ValueError โ€“ if the user doesnโ€™t exist in Argilla.

  • RuntimeError โ€“ if the user cannot be deleted from Argilla.

Return type:

None

Examples

>>> from argilla import rg
>>> user = rg.User.from_name("my-user")
>>> user.delete()
classmethod from_id(id)#

Gets an existing user from Argilla by its ID.

Parameters:

id (UUID) โ€“ 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.

Return type:

User

Examples

>>> from argilla import rg
>>> user = rg.User.from_id("my-user")
classmethod from_name(name)#

Gets an existing user from Argilla by its name.

Parameters:

name (str) โ€“ 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.

Return type:

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()#

Lists all the users in Argilla.

Returns:

An iterator of User instances.

Raises:

RuntimeError โ€“ if there was an error while listing the users.

Return type:

Iterator[User]

Examples

>>> from argilla import rg
>>> for user in rg.User.list():
...     print(user)
classmethod me()#

Gets the current user from Argilla.

Returns:

A User instance.

Raises:

RuntimeError โ€“ if there was an error while retrieving the current user.

Return type:

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.