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, adding users to them, listing the linked users, and deleting 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.
- 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[WorkspaceUserModel]]
- 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) [WorkspaceUserModel(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.
- 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 already exists in the workspace.
RuntimeError โ if there was an error while 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:
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 exists 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.
- 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 the workspace.
RuntimeError โ if there was an 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_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:
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:
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[WorkspaceUserModel]#
Returns the list of users linked to the workspace.
- Returns:
A list of WorkspaceUserModel instances.