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.
This is a public endpoint: no API key (MDC_API_KEY) is required and none is sent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset ID (as shown in MDC platform) or slug. |
required |
Returns:
| Type | Description |
|---|---|
DatasetDetails
|
A DatasetDetails model with the dataset details as returned by the API. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dataset_id is empty. |
FileNotFoundError
|
If the dataset does not exist (404). |
RuntimeError
|
If rate limit is exceeded (429). |
HTTPError
|
For other non-2xx responses. |
ValidationError
|
If the API response is missing the |
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, return_format='pandas')
Download (if needed), extract (if not already extracted), and load the dataset into memory.
By default, the dataset is returned as a pandas DataFrame. Pass return_format="hf"
to get a HuggingFace datasets object instead (requires the optional dependency datacollective[hf]).
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 the loading strategy.
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
|
return_format
|
Literal['pandas', 'hf']
|
Format of the returned object. |
'pandas'
|
Returns:
A pandas DataFrame with the loaded dataset, or a HuggingFace Dataset /
DatasetDict when return_format="hf".
Raises:
| Type | Description |
|---|---|
ValueError
|
If dataset_id is empty, schema is unsupported, or |
MissingDependencyError
|
If |
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
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 | |
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, part_size=DEFAULT_PART_SIZE, sample_file_path=None, sample_state_path=None)
Single point function to create a submission, update metadata, upload a file, 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
|
part_size
|
int
|
Multipart part size in bytes. Ignored when resuming an existing upload, which keeps the part size recorded in its state file. |
DEFAULT_PART_SIZE
|
sample_file_path
|
str | None
|
Optional path to a sample archive to upload alongside the dataset archive. A sample file is not required to submit a dataset. |
None
|
sample_state_path
|
str | None
|
Optional path to persist the sample upload state. |
None
|
Source code in src/datacollective/submissions.py
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 | |
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, part_size=DEFAULT_PART_SIZE)
Upload a dataset file using multipart uploads with resumable state.
Uploads 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
|
part_size
|
int
|
Multipart part size in bytes. Ignored when resuming an existing upload, which keeps the part size recorded in its state file. |
DEFAULT_PART_SIZE
|
Source code in src/datacollective/upload.py
upload_sample_file(file_path, submission_id, state_path=None, show_progress=True, enable_logging=False, part_size=DEFAULT_PART_SIZE)
Upload an optional sample file for a dataset submission.
A sample file is a small, representative excerpt of the dataset that
users can inspect without downloading the full archive. It is uploaded
exactly like the dataset archive (resumable multipart upload,
application/gzip MIME type) but through the submission's sample endpoints,
and it does not replace the dataset file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the sample 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
|
part_size
|
int
|
Multipart part size in bytes. Ignored when resuming an existing upload, which keeps the part size recorded in its state file. |
DEFAULT_PART_SIZE
|
Source code in src/datacollective/upload.py
datacollective.models
Dataset
Bases: BaseModel
Dataset fields shared by the platform's dataset and dataset-submission API payloads.
DatasetDetails inherits this class and is tolerant to new fields that are not declared here in order to prevent breaking changes when the API returns new fields. DatasetSubmission inherits this class and overrides the enum-like fields with strict types for validation.
Note: Fields are camelCase to match the API payloads.
Source code in src/datacollective/models.py
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 | |
DatasetDetails
Bases: Dataset
Dataset details as returned by the MDC API (read model).
Tolerant of platform schema changes by design: fields the API adds are
kept as extra attributes, fields the API removes simply read as None,
and enum-like fields (task, visibility) are plain strings so new
platform values don't fail validation. Only id is required.
Dict-style access (details["id"], details.get("checksum")) is
supported for backward compatibility with the previous dict return type.
Source code in src/datacollective/models.py
DatasetSubmission
Bases: NonEmptyStrModel, Dataset
DatasetSubmission schema aligned with the DB representation used for draft creation, metadata updates, and final submission.
Shared datasheet fields come from Dataset. This model overrides the enum-like ones with strict types so user input is validated before it is sent to the API.
Source code in src/datacollective/models.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 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
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
UploadPart
Visibility
Bases: str, Enum
Dataset visibility levels.
PUBLIC: visible to everyone, downloadable by everyone.RESTRICTED: visible to everyone, downloadable by your organization and approved requesters (seeautoApproveAccessRequests).PRIVATE: visible only to your organization, downloadable by your organization via the SDK.
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.
Unknown keys and unknown dtype values are rejected at parse time.
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, to be loadable, a
root_strategy. The remaining fields depend on the strategy; the
loader registered for that strategy decides which fields are required
at load time.
task is optional. When set to a task with a known contract (e.g. ASR,
TTS), the loaded DataFrame is validated to contain the task's required
logical columns.
Source code in src/datacollective/schema.py
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 | |
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
Strategy
Bases: StrEnum
Loading strategies recognised by schema loaders.
The values are the valid root_strategy schema field entries; the
registry maps each member to its loader class.
Source code in src/datacollective/schema.py
datacollective.schema_loaders.base
BaseSchemaLoader
Bases: ABC
Interface that every strategy 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
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 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 683 684 685 686 687 688 689 690 691 | |
Strategy
Bases: StrEnum
Loading strategies recognised by schema loaders.
The values are the valid root_strategy schema field entries; the
registry maps each member to its loader class.
Source code in src/datacollective/schema.py
datacollective.schema_loaders.registry
datacollective.schema_loaders.cache_schema
datacollective.schema_loaders.contracts
datacollective.schema_loaders.strategies.index
IndexLoader
Bases: BaseSchemaLoader
Load a dataset from a single delimited index file (the default strategy).
An index file (e.g. CSV/TSV) holds one row per sample. When the schema declares column mappings they are applied (renaming, dtype conversion, file-path resolution); otherwise the raw DataFrame is returned as-is.
Source code in src/datacollective/schema_loaders/strategies/index.py
datacollective.schema_loaders.strategies.multi_split
MultiSplitLoader
Bases: BaseSchemaLoader
Load a dataset spread across one delimited file per split.
All split files whose stems match the splits list are read, a
split column is added to each, column mappings are applied when
declared, and the parts are concatenated.
Source code in src/datacollective/schema_loaders/strategies/multi_split.py
datacollective.schema_loaders.strategies.multi_sections
MultiSectionsLoader
Bases: BaseSchemaLoader
Load a dataset organised as one index file per section directory.
Each section directory under section_root holds its own index file.
A section column (the directory name) is added to each part, column
mappings are applied when declared, and the parts are concatenated.
Source code in src/datacollective/schema_loaders/strategies/multi_sections.py
datacollective.schema_loaders.strategies.paired_glob
PairedGlobLoader
Bases: BaseSchemaLoader
Load a dataset where each audio file is paired with a sidecar file.
Two variants exist, selected by schema.format:
format: "json": each audio file has a JSON sidecar (matched viafile_pattern); column mappings are required and are applied to the normalised JSON records.- otherwise: each audio file has a matching text sidecar containing the
transcription; requires
file_patternandaudio_extension. Column mappings, when declared, are applied over the derivedaudio_path/transcription/splitsources.
Source code in src/datacollective/schema_loaders/strategies/paired_glob.py
17 18 19 20 21 22 23 24 25 26 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 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 | |
datacollective.schema_loaders.strategies.glob
GlobLoader
Bases: BaseSchemaLoader
Load a directory-structured dataset by globbing for files.
Metadata (e.g. speaker ID, language) is derived from each matched file's path rather than from an index file or sidecar pairing.
When the schema declares columns, each mapping's source_column
names a path-derived source instead of a file column:
path: absolute path to the matched filename: file name (with extension)stem: file name without extensionparent: parent directory name (same asparents[0])parents[N]: name of the Nth ancestor directory (0 = parent); empty string when the path is not that deepcontent: text content of the matched file (read withschema.encoding, stripped)
Without columns the loader falls back to its default output:
audio_path (absolute path), language (parent directory name) and
speaker_id (grandparent directory name).
Source code in src/datacollective/schema_loaders/strategies/glob.py
20 21 22 23 24 25 26 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 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 | |
load()
Glob for files and derive metadata from each matched path.
When splits is set, each split name is treated as a subdirectory
under extract_dir and a split column is added. Otherwise
the glob runs from extract_dir directly.