Skip to main content

Project logo

Published Docs Tests

Mozilla Data Collective Python Client Library

The official Python SDK for accessing and contributing to the Mozilla Data Collective platform.

Installation

pip install datacollective

Quick Start

IMPORTANT NOTE: Before trying to access any dataset, make sure you have thoroughly read and agreed to the specific dataset's conditions & licensing terms.

  1. Get your API key from the Mozilla Data Collective dashboard

  2. Set the API key in your environment variable:

Option A: Run this command in your terminal (replace your-api-key-here with your actual API key):

export MDC_API_KEY=your-api-key-here

Option B: Create a .env file in your project directory and add this line:

MDC_API_KEY=your-api-key-here
  1. Get your dataset ID and/or slug from the dataset's page at the MDC website.
  1. Save a dataset locally:
from datacollective import download_dataset

dataset_path = download_dataset("your-dataset-id")
  1. Get information & metadata about a dataset:
from datacollective import get_dataset_details

details = get_dataset_details("your-dataset-id")
  1. Load the dataset into a pandas DataFrame (Alpha version: Only certain MDC datasets are supported right now):
from datacollective import load_dataset

dataset = load_dataset("your-dataset-id")
  1. Or load it as a HuggingFace Dataset object (requires the optional hf extra: pip install / uv add "datacollective[hf]"):
from datacollective import load_dataset

dataset = load_dataset("your-dataset-id", return_format="hf")

Returns a Dataset, or a DatasetDict keyed by split name for datasets with multiple splits. See our docs for more details, including how to lazily decode audio with the Audio() feature.

Programmatic submissions and uploads

[!ΝΟΤΕ] In order to be able to upload datasets in the MDC platform you will first need to Request Access to Upload by navigating to your profile under the Upload tab. Only the credentials (API keys) created after your request has been approved will be able to upload datasets. Any credentials created before your request was approved will not be able to upload datasets.

You can create dataset submissions and upload files with resumable uploads into the MDC platform programmatically using our Python SDK:

from datacollective import DatasetSubmission, License, Task, create_submission_with_upload

submission = DatasetSubmission(
    name="Dataset Name",
    longDescription="A detailed description of the dataset.",
    shortDescription="A brief description of the dataset.",
    locale="en-US",
    task=Task.ASR,
    format="TSV",
    licenseAbbreviation=License.CC_BY_4_0,
    other="This text should provide a detailed description of the dataset, "
          "including its contents, structure, and any relevant information "
          "that would help users understand what the dataset is about "
          "and how it can be used.",
    restrictions="Any restrictions you want to impose on the dataset",
    forbiddenUsage="Use cases that are not allowed with this dataset",
    additionalConditions="Any additional conditions for using the dataset",
    pointOfContactFullName="Jane Doe",
    pointOfContactEmail="jane@example.com",
    fundedByFullName="Funder Name",
    fundedByEmail="funder@example.com",
    legalContactFullName="Legal Name",
    legalContactEmail="legal@example.com",
    createdByFullName="Creator Name",
    createdByEmail="creator@example.com",
    intendedUsage="Describe the intended usage of the dataset, including "
                  "potential applications and use cases.",
    ethicalReviewProcess="Describe the ethical review process that was "
                         "followed for this dataset, including any approvals "
                         "or considerations related to data collection and usage.",
    isPaid=False,  # True = the dataset is compensated and requires `basePriceCents`,
                   # False (default) = the dataset is free to access
    exclusivityOptOut=False,  # True = This dataset is non-exclusive to Mozilla Data Collective, 
                              # False = Dataset is exclusively hosted in Mozilla Data Collective
    agreeToSubmit=True,  # True = You confirm that you have the right to submit this dataset and 
                         # that all information provided in the datasheet is accurate. 
                         # Required to be True to complete the submission process
)

response = create_submission_with_upload(
    file_path="/path/to/dataset.tar.gz",
    submission=submission
)

print(response)

For predefined licenses, pass licenseAbbreviation=License.<VALUE> and leave licenseUrl and license unset. For custom licenses, pass a custom string to license and optionally include licenseUrl and licenseAbbreviation.

To publish a compensated dataset, set isPaid=True and a basePriceCents price in USD cents (US Dollars), e.g. basePriceCents=100_000 for $1,000.00.

For more details, visit our docs

License

This project is released under MPL (Mozilla Public License) 2.0.

Metadata

Release files for datacollective 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datacollective 0.6.3
File Size Uploaded
datacollective-0.6.3.tar.gz 52.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datacollective 0.6.3
File Interpreter ABI Platform
datacollective-0.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 119.6 kB

Release files / datacollective-0.6.3.tar.gz

Download URL datacollective-0.6.3.tar.gz
Size 52.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b8214838cade5de95bc439a311552a8e47f416409e9c8b8f43fc339ce9a06f98
BLAKE2b-256 checksum
How to use checksums
6f0161dbd1c63427ba8d122ff9a751851d7c9a33fc37282fdd1ee8118c7223af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / datacollective-0.6.3-py3-none-any.whl

Download URL datacollective-0.6.3-py3-none-any.whl
Size 66.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52609efd85036cc219ab66e594d9c067ec5af6c650927a317985305d95fe9b51
BLAKE2b-256 checksum
How to use checksums
32ed55c6aa25263f4985ef790ba533d61feacc52a57ca7cb0de125e6e4e15157
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.6.4

2 release files

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.27

2 release files

0.0.23

2 release files

0.0.16

2 release files

0.0.11

2 release files

0.0.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page