Workspaces#

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

class argilla.client.workspaces.Workspace(name=None, *, id=None)#

The Workspace class is used to manage workspaces in Argilla. It provides methods to create new workspaces, add users to them, list the linked users, and delete users from the workspace. While itโ€™s not allowed to delete a workspace neither to update the workspace name.

Parameters:
  • name (Optional[str]) โ€“ the name of the workspace to be managed. Defaults to None.

  • id (Optional[Union[str, UUID]]) โ€“ the ID of the workspace 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 workspace.

Type:

uuid.UUID

name#

the name of the workspace.

Type:

str

users#

the list of users linked to the workspace. Defaults to None.

Type:

Optional[List[UserModel]]

inserted_at#

the datetime when the workspace was created.

Type:

datetime.datetime

updated_at#

the datetime when the workspace was last updated.

Type:

datetime.datetime

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.from_name("my-workspace") # or `Workspace.from_id("...")`
>>> workspace.add_user("my-user")
>>> print(workspace.users)
[UserModel(id='...', first_name='Luke', last_name="Skywalker', full_name='Luke Skywalker', username='my-user', role='annotator', workspaces=['my-workspace'], api_key='...', inserted_at=datetime.datetime(2021, 8, 31, 10, 0, 0), updated_at=datetime.datetime(2021, 8, 31, 10, 0, 0))]
>>> workspace.delete_user("my-user")
>>> print(workspace.users)
[]
add_user(user_id)#

Adds an existing user to the workspace in Argilla.

Note that users with the owner role are excluded from the add_user method, as they are superusers and they can access all the workspaces and datasets in Argilla.

Parameters:

user_id (UUID) โ€“ the ID of the user to be added to the workspace. The user must exist in Argilla.

Raises:
  • ValueError โ€“ if the user with the provided ID either doesnโ€™t exist in Argilla or already exists in the workspace.

  • RuntimeError โ€“ if there was an error while either fetching the user from Argilla or adding the user to the workspace.

Return type:

None

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.from_name("my-workspace")
>>> workspace.add_user("my-user-id")
classmethod create(name)#

Creates a new workspace in Argilla.

Parameters:

name (str) โ€“ the name of the workspace to be created.

Raises:

ValueError โ€“ if the workspace with the provided name already exists.

Returns:

A Workspace instance.

Return type:

Workspace

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.create("my-workspace")
delete()#

Deletes an existing workspace from Argilla. Note that the workspace cannot have any linked dataset to be removed from Argilla. Otherwise, an error will be raised.

Raises:
  • ValueError โ€“ if the workspace does not exist or some datasets are linked to it.

  • RuntimeError โ€“ if there was an unexpected error while deleting the user from the workspace.

Return type:

None

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.from_name("my-workspace")
>>> workspace.delete()
delete_user(user_id)#

Deletes an existing user from the workspace in Argilla. Note that the user will not be deleted from Argilla, but just from the workspace.

Note that users with the owner role are excluded from the delete_user method, as they are superusers and they can access all the workspaces and datasets in Argilla.

Parameters:

user_id (UUID) โ€“ the ID of the user to be deleted from the workspace. The user must exist in Argilla.

Raises:
  • ValueError โ€“ if the user with the provided ID doesnโ€™t exist in either the workspace or Argilla.

  • RuntimeError โ€“ if there was an error while retrieving the user from Argilla or while deleting it from the workspace.

Return type:

None

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.from_name("my-workspace")
>>> workspace.delete_user("my-user-id")
classmethod from_id(id)#

Gets an existing workspace from Argilla by its ID.

Parameters:

id (UUID) โ€“ the ID of the workspace to be retrieved.

Returns:

A Workspace instance.

Raises:
  • ValueError โ€“ if the workspace with the provided ID doesnโ€™t exist, or if itโ€™s not a valid UUID identifier.

  • RuntimeError โ€“ if there was an error while retrieving the workspace.

Return type:

Workspace

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.from_id("my-workspace-id")
classmethod from_name(name)#

Gets an existing workspace from Argilla by its name.

Parameters:

name (str) โ€“ the name of the workspace to be retrieved.

Returns:

A Workspace instance.

Raises:
  • RuntimeError โ€“ if there was an error while listing the workspaces.

  • ValueError โ€“ if the workspace with the provided name doesnโ€™t exist.

Return type:

Workspace

Examples

>>> from argilla import rg
>>> workspace = rg.Workspace.from_name("my-workspace")
classmethod list()#

Lists all the workspaces in Argilla.

Returns:

A list of Workspace instances.

Raises:

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

Return type:

Iterator[Workspace]

Examples

>>> from argilla import rg
>>> workspaces = rg.Workspace.list()
property users: List[UserModel]#

Returns the list of users linked to the workspace.

Returns:

A list of UserModel instances.