rg.Argilla
¶
To interact with the Argilla server from Python you can use the Argilla
class. The Argilla
client is used to create, get, update, and delete all Argilla resources, such as workspaces, users, datasets, and records.
Usage Examples¶
Deploying Argilla Server on Hugging Face Spaces¶
To deploy Argilla on Hugging Face Spaces, use the deploy_on_spaces
method.
Connecting to an Argilla server¶
To connect to an Argilla server, instantiate the Argilla
class and pass the api_url
of the server and the api_key
to authenticate.
import argilla as rg
client = rg.Argilla(
api_url="https://argilla.example.com",
api_key="my_api_key",
)
Accessing Dataset, Workspace, and User objects¶
The Argilla
clients provides access to the Dataset
, Workspace
, and User
objects of the Argilla server.
my_dataset = client.datasets("my_dataset")
my_workspace = client.workspaces("my_workspace")
my_user = client.users("my_user")
These resources can then be interacted with to access their properties and methods. For example, to list all datasets in a workspace:
Argilla
¶
Bases: APIClient
, SpacesDeploymentMixin
, NotebookHTMLReprMixin
Argilla API client. This is the main entry point to interact with the API.
Attributes:
Name | Type | Description |
---|---|---|
workspaces |
Workspaces
|
A collection of workspaces. |
datasets |
Datasets
|
A collection of datasets. |
users |
Users
|
A collection of users. |
me |
User
|
The current user. |
Source code in src/argilla/client.py
workspaces: Workspaces
property
¶
A collection of workspaces on the server.
datasets: Datasets
property
¶
A collection of datasets on the server.
users: Users
property
¶
A collection of users on the server.
__init__(api_url=DEFAULT_HTTP_CONFIG.api_url, api_key=DEFAULT_HTTP_CONFIG.api_key, timeout=DEFAULT_HTTP_CONFIG.timeout, retries=DEFAULT_HTTP_CONFIG.retries, **http_client_args)
¶
Inits the Argilla
client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_url |
Optional[str]
|
the URL of the Argilla API. If not provided, then the value will try
to be set from |
api_url
|
api_key |
Optional[str]
|
the key to be used to authenticate in the Argilla API. If not provided,
then the value will try to be set from |
api_key
|
timeout |
int
|
the maximum time in seconds to wait for a request to the Argilla API
to be completed before raising an exception. Defaults to |
timeout
|
retries |
int
|
the number of times to retry the HTTP connection to the Argilla API
before raising an exception. Defaults to |
retries
|
Source code in src/argilla/client.py
SpacesDeploymentMixin
¶
Bases: LoggingMixin
Source code in src/argilla/_helpers/_deploy.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
deploy_on_spaces(api_key, repo_name='argilla', org_name=None, hf_token=None, space_storage=None, space_hardware='cpu-basic', private=False)
classmethod
¶
Deploys Argilla on Hugging Face Spaces.
Args:
api_key (str): The Argilla API key to be defined for the owner user and creator of the Space.
repo_name (Optional[str]): The ID of the repository where Argilla will be deployed. Defaults to "argilla".
org_name (Optional[str]): The name of the organization where Argilla will be deployed. Defaults to None.
hf_token (Optional[Union[str, None]]): The Hugging Face authentication token. Defaults to None.
space_storage (Optional[Union[str, SpaceStorage]]): The persistant storage size for the space. Defaults to None without persistant storage.
space_hardware (Optional[Union[str, SpaceHardware]]): The hardware configuration for the space. Defaults to "cpu-basic" with downtime after 48 hours of inactivity.
private (Optional[Union[bool, None]]): Whether the space should be private. Defaults to False.
Returns:
Argilla: The Argilla client.
Example:
```Python
import argilla as rg
api client = rg.Argilla.deploy_on_spaces(api_key="12345678") ```