Workspace management¶
This guide provides an overview of workspaces, explaining how to set up and manage workspaces in Extralit.
A workspace is a space inside your Extralit instance where authorized users can collaborate on datasets. It is accessible through the Python SDK and the UI.
Question: Who can manage workspaces?
Only users with the owner role can manage (create, read and delete) workspaces.
A user with the admin role can only read the workspace to which it belongs.
Initial workspaces¶
Depending on your Extralit deployment, the initial workspace will vary.
- If you deploy on the Hugging Face Hub, the initial workspace will be the one indicated in the
.oauth.yamlfile. By default,extralit. - If you deploy with Docker, you will need to create a workspace as shown in the next section.
Main Class
Check the Workspace - Python Reference to see the attributes, arguments, and methods of the
Workspaceclass in detail.
Create a new workspace¶
To create a new workspace in Extralit, you can define it in the Workspace class and then call the create method. This method is inherited from the Resource base class and operates without modifications.
When you create a new workspace, it will be empty. To create and add a new dataset, check these guides.
import extralit as ex
client = ex.Extralit(api_url="<api_url>", api_key="<api_key>")
workspace_to_create = ex.Workspace(name="my_workspace")
created_workspace = workspace_to_create.create()
Accessing attributes
Access the attributes of a workspace by calling them directly on the Workspace object. For example, workspace.id or workspace.name.
List workspaces¶
You can list all the existing workspaces in Extralit by calling the workspaces attribute on the Extralit class and iterating over them. You can also use len(client.workspaces) to get the number of workspaces.
import extralit as ex
client = ex.Extralit(api_url="<api_url>", api_key="<api_key>")
workspaces = client.workspaces
for workspace in workspaces:
print(workspace)
Notebooks
When using a notebook, executing client.workspaces will display a table with the number of datasets in each workspace, name, id, and the last update as updated_at.
Retrieve a workspace¶
You can retrieve a workspace by accessing the workspaces method on the Extralit class and passing the name or id of the workspace as an argument. If the workspace does not exist, a warning message will be raised and None will be returned.
Check workspace existence¶
You can check if a workspace exists. The client.workspaces method will return None if the workspace is not found.
import extralit as ex
client = ex.Extralit(api_url="<api_url>", api_key="<api_key>")
workspace = client.workspaces("my_workspace")
if workspace is not None:
pass
List users in a workspace¶
You can list all the users in a workspace by accessing the users attribute on the Workspace class and iterating over them. You can also use len(workspace.users) to get the number of users by workspace.
For further information on how to manage users, check this how-to guide.
import extralit as ex
client = ex.Extralit(api_url="<api_url>", api_key="<api_key>")
workspace = client.workspaces('my_workspace')
for user in workspace.users:
print(user)
Add a user to a workspace¶
You can also add a user to a workspace by calling the add_user method on the Workspace class.
For further information on how to manage users, check this how-to guide.
import extralit as ex
client = ex.Extralit(api_url="<api_url>", api_key="<api_key>")
workspace = client.workspaces("my_workspace")
added_user = workspace.add_user("my_username")
Remove a user from workspace¶
You can also remove a user from a workspace by calling the remove_user method on the Workspace class.
For further information on how to manage users, check this how-to guide.
import extralit as ex
client = ex.Extralit(api_url="<api_url>", api_key="<api_key>")
workspace = client.workspaces("my_workspace")
removed_user = workspace.remove_user("my_username")
Diagnose workspace health¶
You can run health diagnostics on a workspace to check for common issues like missing S3 buckets, connectivity problems, or configuration issues. The doctor method checks various aspects of the workspace setup and can automatically fix certain issues.
CLI Usage
You can run workspace diagnostics from the command line:
The doctor checks: - S3 bucket existence: Creates the bucket if missing (when autofix=True) - Bucket versioning: Verifies file versioning policy (informational) - RQ worker pool: Tests background job queue connectivity (informational) - Elasticsearch indexes: Checks dataset index availability (informational)
Delete a workspace¶
To delete a workspace, no dataset can be associated with it. If the workspace contains any dataset, deletion will fail. You can delete a workspace by calling the delete method on the Workspace class.
To clear a workspace and delete all their datasets, refer to this how-to guide.