API Reference
download_dataset is the canonical public API for downloading dataset archives.
save_dataset_to_disk is still available as a deprecated alias for backward compatibility.
datacollective.datasets
download_dataset(dataset_id, download_directory=None, show_progress=True, overwrite_existing=False, enable_logging=False)
Download the dataset archive to a local directory and return the archive path.
Skips download if the target file already exists (unless overwrite_existing=True).
Automatically resumes interrupted downloads if a matching .checksum file exists from a previous attempt.
Note: Previously called save_dataset_to_disk, which remains available as a
deprecated alias for backward compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset ID (as shown in MDC platform) or slug. |
required |
download_directory
|
str | None
|
Directory where to save the downloaded archive file. If None or empty, falls back to env MDC_DOWNLOAD_PATH or default. |
None
|
show_progress
|
bool
|
Whether to show a progress bar during download. |
True
|
overwrite_existing
|
bool
|
Whether to overwrite the existing archive file. |
False
|
enable_logging
|
bool
|
Whether to enable SDK logging to console and a local log file. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the downloaded dataset archive. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dataset_id is empty. |
FileNotFoundError
|
If the dataset does not exist (404). |
PermissionError
|
If access is denied (403) or download directory is not writable. |
RuntimeError
|
If rate limit is exceeded (429) or unexpected response format. |
HTTPError
|
For other non-2xx responses. |
Source code in src/datacollective/datasets.py
get_dataset_details(dataset_id)
Return dataset details from the MDC API as a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset ID (as shown in MDC platform) or slug. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dict with dataset details as returned by the API. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dataset_id is empty. |
FileNotFoundError
|
If the dataset does not exist (404). |
PermissionError
|
If access is denied (403). |
RuntimeError
|
If rate limit is exceeded (429). |
HTTPError
|
For other non-2xx responses. |
Source code in src/datacollective/datasets.py
load_dataset(dataset_id, download_directory=None, show_progress=True, overwrite_existing=False, overwrite_extracted=False, enable_logging=False)
Download (if needed), extract (if not already extracted), and load the dataset into a pandas DataFrame.
If the dataset archive already exists in the download directory, it will not be re-downloaded
unless overwrite_existing=True.
If there is a directory with the same name as the archive file without the suffix extension, we assume
it has already been extracted, and it will not be re-extracted unless overwrite_extracted=True.
Uses the dataset schema to determine task-specific loading logic.
Automatically resumes interrupted downloads if a .checksum file exists from a previous attempt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset ID (as shown in MDC platform) or slug. |
required |
download_directory
|
str | None
|
Directory where to save the downloaded archive file. If None or empty, falls back to env MDC_DOWNLOAD_PATH or default. |
None
|
show_progress
|
bool
|
Whether to show a progress bar during download. |
True
|
overwrite_existing
|
bool
|
Whether to overwrite existing archive. |
False
|
overwrite_extracted
|
bool
|
Whether to overwrite existing extracted files by re-extracting the archive file. Only makes sense when overwrite_existing is False. Will check in the download directory for existing extracted files with the default naming of the folder. |
False
|
enable_logging
|
bool
|
Whether to enable SDK logging to console and a local log file. |
False
|
Returns: A pandas DataFrame with the loaded dataset.
Raises:
| Type | Description |
|---|---|
ValueError
|
If dataset_id is empty or schema is unsupported. |
FileNotFoundError
|
If the dataset does not exist (404). |
PermissionError
|
If access is denied (403) or download directory is not writable. |
RuntimeError
|
If rate limit is exceeded (429) or unexpected response format. |
HTTPError
|
For other non-2xx responses. |
Source code in src/datacollective/datasets.py
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 | |
resolve_dataset_id(dataset_id)
Resolves a dataset ID or slug to its canonical MDC ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset ID (as shown in MDC platform) or slug. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The canonical dataset ID. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the dataset does not exist. |
Source code in src/datacollective/datasets.py
save_dataset_to_disk(dataset_id, download_directory=None, show_progress=True, overwrite_existing=False, enable_logging=False)
Deprecated alias for download_dataset.
Use download_dataset instead. This name is kept for backward compatibility.
Source code in src/datacollective/datasets.py
datacollective.download
datacollective.api_utils
datacollective.submissions
create_submission_draft(submission)
Create a draft dataset submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
submission
|
DatasetSubmission
|
Dataset submission model containing at least |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The full API response dict (contains a |
dict[str, Any]
|
the created submission). |
Source code in src/datacollective/submissions.py
create_submission_with_upload(file_path, submission, state_path=None, enable_logging=False)
Single point function to create a submission, upload a file, update metadata, and submit for review. Allows for resuming an upload if interrupted by persisting state to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to dataset archive. |
required |
submission
|
DatasetSubmission
|
Dataset submission model with metadata fields. |
required |
state_path
|
str | None
|
Optional path to persist upload state. |
None
|
enable_logging
|
bool
|
Whether to enable detailed logging during the process. |
False
|
Source code in src/datacollective/submissions.py
submit_submission(submission_id, submission)
Submit a dataset submission for review.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
submission_id
|
str
|
Dataset submission ID. |
required |
submission
|
DatasetSubmission
|
Dataset submission model with |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The full API response dict (contains a |
dict[str, Any]
|
the submission whose status should be |
Source code in src/datacollective/submissions.py
update_submission(submission_id, submission)
Update metadata on an existing dataset submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
submission_id
|
str
|
Dataset submission ID. |
required |
submission
|
DatasetSubmission
|
Dataset submission model containing update fields. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The full API response dict (contains a |
Source code in src/datacollective/submissions.py
datacollective.upload
upload_dataset_file(file_path, submission_id, state_path=None, show_progress=True, enable_logging=False)
Upload a dataset file using multipart uploads with resumable state.
Uploads are limited to 80GB and use the application/gzip MIME type.
Pass the submission ID of the target dataset submission. This works for
both draft submissions and for uploading a new .tar.gz version to an
already approved dataset submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the dataset archive on disk. |
required |
submission_id
|
str
|
Dataset submission ID (not the dataset ID). |
required |
state_path
|
str | None
|
Optional path to persist upload state. Defaults to
|
None
|
enable_logging
|
bool
|
Whether to enable detailed logging during the upload. |
False
|
show_progress
|
bool
|
Whether to show a progress bar during upload. |
True
|
Source code in src/datacollective/upload.py
27 28 29 30 31 32 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 | |
datacollective.models
DatasetSubmission
Bases: NonEmptyStrModel
DatasetSubmission schema aligned with the backend DB representation used for draft creation, metadata updates, and final submission.
Note: Fields are camelCase to match the API payloads.
Source code in src/datacollective/models.py
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 | |
License
Bases: str, Enum
List of pre-defined dataset licenses.
Source code in src/datacollective/models.py
NonEmptyStrModel
Bases: BaseModel
Base model that trims string fields and rejects empty values.
Source code in src/datacollective/models.py
Task
Bases: str, Enum
Valid ML task types for a dataset submission.
Source code in src/datacollective/models.py
datacollective.schema
ColumnMapping
Bases: BaseModel
A single column mapping entry inside a schema.
Used by index-based tasks to describe how columns in the index file map to logical fields and their data types.
Source code in src/datacollective/schema.py
ContentMapping
Bases: BaseModel
Describes how file contents / metadata map to DataFrame columns.
Used by glob-based tasks (e.g. LM) to specify how to extract text and metadata from files found via glob patterns. For example, the text content might come from the file contents, while metadata (e.g. language code) might come from the file name or parent directory.
Source code in src/datacollective/schema.py
DatasetSchema
Bases: BaseModel
Task-agnostic representation of a dataset schema, as defined by a schema.yaml file.
Every schema must have dataset_id and task. The remaining
fields depend on the task type and the root_strategy
("index" vs "glob").
New task types only need to populate the fields they care about; the loader registered for that task will decide which fields are required at load time.
Source code in src/datacollective/schema.py
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 | |
to_yaml_dict()
Serialise the schema to a plain dict suitable for YAML output.
Excludes fields that are at their default values so that the
generated schema.yaml stays compact and readable. The
extra dict is merged into the top level.
Source code in src/datacollective/schema.py
datacollective.schema_loaders.base
BaseSchemaLoader
Bases: ABC
Interface that every task-specific loader must implement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
DatasetSchema
|
The parsed schema for the dataset. |
required |
extract_dir
|
Path
|
The directory where the dataset files have been extracted. |
required |
Source code in src/datacollective/schema_loaders/base.py
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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 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 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
Strategy
Bases: StrEnum
Loading strategies recognised by schema loaders.
Source code in src/datacollective/schema_loaders/base.py
datacollective.schema_loaders.registry
datacollective.schema_loaders.cache_schema
datacollective.schema_loaders.tasks.asr
ASRLoader
Bases: BaseSchemaLoader
Load an ASR dataset described by a DatasetSchema.
Source code in src/datacollective/schema_loaders/tasks/asr.py
datacollective.schema_loaders.tasks.tts
TTSLoader
Bases: BaseSchemaLoader
Load a TTS dataset described by a DatasetSchema.
See docs/loaders/tts.md for details on supported loading strategies and schema fields.