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.
webhooks: Webhooks
property
¶
A collection of webhooks 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
Users
¶
Bases: Sequence['User']
, ResourceHTMLReprMixin
A collection of users. It can be used to create a new user or to get an existing one.
Source code in src/argilla/client.py
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
Workspaces
¶
Bases: Sequence['Workspace']
, ResourceHTMLReprMixin
A collection of workspaces. It can be used to create a new workspace or to get an existing one.
Source code in src/argilla/client.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
Datasets
¶
Bases: Sequence['Dataset']
, ResourceHTMLReprMixin
A collection of datasets. It can be used to create a new dataset or to get an existing one.
Source code in src/argilla/client.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
add(dataset)
¶
Add a new dataset to the Argilla platform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
Dataset
|
Dataset object. |
required |
Returns:
Name | Type | Description |
---|---|---|
Dataset |
Dataset
|
The created dataset. |
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") ```