rg.Dataset
¶
Dataset
is a class that represents a collection of records. It is used to store and manage records in Argilla.
Usage Examples¶
Creating a Dataset¶
To create a new dataset you need to define its name and settings. Optional parameters are workspace
and client
, if you want to create the dataset in a specific workspace or on a specific Argilla instance.
dataset = rg.Dataset(
name="my_dataset",
settings=rg.Settings(
fields=[
rg.TextField(name="text"),
],
questions=[
rg.TextQuestion(name="response"),
],
),
)
dataset.create()
For a detail guide of the dataset creation and publication process, see the Dataset how to guide.
Retrieving an existing Dataset¶
To retrieve an existing dataset, use client.datasets("my_dataset")
instead.
Dataset
¶
Bases: Resource
, HubImportExportMixin
, DiskImportExportMixin
Class for interacting with Argilla Datasets
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the dataset. |
records |
DatasetRecords
|
The records object for the dataset. Used to interact with the records of the dataset by iterating, searching, etc. |
settings |
Settings
|
The settings object of the dataset. Used to configure the dataset with fields, questions, guidelines, etc. |
fields |
list
|
The fields of the dataset, for example the |
questions |
list
|
The questions of the dataset defined in the settings. For example, the |
guidelines |
str
|
The guidelines of the dataset defined in the settings. Used to provide instructions to labelers. |
allow_extra_metadata |
bool
|
True if extra metadata is allowed, False otherwise. |
Source code in src/argilla/datasets/_resource.py
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 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 214 215 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 |
|
__init__(name=None, workspace=None, settings=None, client=None)
¶
Initializes a new Argilla Dataset object with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the dataset. Replaced by random UUID if not assigned. |
None
|
workspace |
UUID
|
Workspace of the dataset. Default is the first workspace found in the server. |
None
|
settings |
Settings
|
Settings class to be used to configure the dataset. |
None
|
client |
Argilla
|
Instance of Argilla to connect with the server. Default is the default client. |
None
|
Source code in src/argilla/datasets/_resource.py
create()
¶
Creates the dataset on the server with the Settings
configuration.
Returns:
Name | Type | Description |
---|---|---|
Dataset |
Dataset
|
The created dataset object. |
Source code in src/argilla/datasets/_resource.py
update()
¶
Updates the dataset on the server with the current settings.
Returns:
Name | Type | Description |
---|---|---|
Dataset |
Dataset
|
The updated dataset object. |
progress(with_users_distribution=False)
¶
Returns the team's progress on the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
with_users_distribution |
bool
|
If True, the progress of the dataset is returned with users distribution. This includes the number of responses made by each user. |
False
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The team's progress on the dataset. |
An example of a response when with_users_distribution
is True
:
{
"total": 100,
"completed": 50,
"pending": 50,
"users": {
"user1": {
"completed": { "submitted": 10, "draft": 5, "discarded": 5},
"pending": { "submitted": 5, "draft": 10, "discarded": 10},
},
"user2": {
"completed": { "submitted": 20, "draft": 10, "discarded": 5},
"pending": { "submitted": 2, "draft": 25, "discarded": 0},
},
...
}
Source code in src/argilla/datasets/_resource.py
DiskImportExportMixin
¶
Bases: ABC
A mixin for exporting and importing datasets to and from disk.
Source code in src/argilla/datasets/_io/_disk.py
33 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 |
|
to_disk(path, *, with_records=True)
¶
Exports the dataset to disk in the given path. The dataset is exported as a directory containing the dataset model, settings and records as json files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to export the dataset to. Must be an empty directory. |
required |
with_records |
bool
|
whether to load the records from the Hugging Face dataset. Defaults to |
True
|
Source code in src/argilla/datasets/_io/_disk.py
from_disk(path, *, name=None, workspace=None, client=None, with_records=True)
classmethod
¶
Imports a dataset from disk as a directory containing the dataset model, settings and records.
The directory should be defined using the to_disk
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the directory containing the dataset model, settings and records. |
required |
name |
str
|
The name to assign to the new dataset. Defaults to None and the dataset's source name is used, unless it already exists, in which case a unique UUID is appended. |
None
|
workspace |
Union[Workspace, str]
|
The workspace to import the dataset to. Defaults to None and default workspace is used. |
None
|
client |
Argilla
|
The client to use for the import. Defaults to None and the default client is used. |
None
|
with_records |
bool
|
whether to load the records from the Hugging Face dataset. Defaults to |
True
|
Source code in src/argilla/datasets/_io/_disk.py
HubImportExportMixin
¶
Bases: DiskImportExportMixin
Source code in src/argilla/datasets/_io/_hub.py
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 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 214 215 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 309 310 311 312 313 314 315 316 317 |
|
to_hub(repo_id, *, with_records=True, generate_card=True, **kwargs)
¶
Pushes the Dataset
to the Hugging Face Hub. If the dataset has been previously pushed to the
Hugging Face Hub, it will be updated instead of creating a new dataset repo.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_id |
str
|
the ID of the Hugging Face Hub repo to push the |
required |
with_records |
bool
|
whether to load the records from the Hugging Face dataset. Defaults to |
True
|
generate_card |
Optional[bool]
|
whether to generate a dataset card for the |
True
|
**kwargs |
Any
|
the kwargs to pass to |
{}
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in src/argilla/datasets/_io/_hub.py
from_hub(repo_id, *, name=None, workspace=None, client=None, with_records=True, settings=None, split=None, subset=None, **kwargs)
classmethod
¶
Loads a Dataset
from the Hugging Face Hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_id |
str
|
the ID of the Hugging Face Hub repo to load the |
required |
name |
str
|
The name to assign to the new dataset. Defaults to None and the dataset's source name is used, unless it already exists, in which case a unique UUID is appended. |
None
|
workspace |
Union[Workspace, str]
|
The workspace to import the dataset to. Defaults to None and default workspace is used. |
None
|
client |
Optional[Argilla]
|
the client to use to load the |
None
|
with_records |
bool
|
whether to load the records from the Hugging Face dataset. Defaults to |
True
|
settings |
Optional[Settings]
|
the settings to use to load the |
None
|
split |
Optional[str]
|
the split to load from the Hugging Face dataset. If not provided, the first split will be loaded. |
None
|
**kwargs |
Any
|
the kwargs to pass to |
{}
|
Returns:
Type | Description |
---|---|
Dataset
|
A |
Source code in src/argilla/datasets/_io/_hub.py
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|