Skip to main content

MIDI ETL

This repository contains an implementation of a modern data stack for building and analyzing MIDI datasets at scale. The stack is composed of several open source technologies, including DBT, Dagster, Trino, and Minio.

DBT (Data Build Tool) is used to transform and optimize MIDI data as it is ingested from various sources into a data warehouse. DBT scripts are used to clean and preprocess the data, extract relevant metadata, and load it into a staging table.

Dagster is used to define and execute data pipelines that fetch MIDI data from online sources using web scraping and API calls, and then load the data into the staging table in the data warehouse. It provides a framework for building, testing, and deploying these pipelines in a robust and scalable way.

Trino is used to analyze the MIDI datasets stored in the data warehouse. It provides a distributed SQL query engine that can handle complex queries and large volumes of data efficiently. This allows data analysts and scientists to extract insights and trends from the MIDI datasets.

Minio is used to store and retrieve the MIDI datasets and other data used in the stack. It is a lightweight, scalable object storage solution that can handle large volumes of data.

Overall, this data stack provides a powerful and scalable platform for building and analyzing MIDI datasets. It can be used by data engineers, data scientists, and data analysts to extract insights and trends from music data at scale.

Prerequisites

Before you can use this repository, you will need to install the following:

Installation

You can install midi_etl using pip:

pip install midi_etl

Usage

To use this repository, follow these steps:

  1. Clone the repository to your local machine:
git clone git@gitlab.com:nintorac-audio/midi_etl.git
  1. Navigate to the repository directory:
cd midi_etl
  1. Build and start the Docker containers:
docker-compose up --build

This will build the Docker containers for the etl platform and deploy all the infra needed to run the project

  1. Navigate to dagit to initiate jobs

  2. Download DBeaver (or your favourite DB IDE) to run queries over your data lake, navigate to minio to review the files in your data lake or use pyarrow to load the dataset in python eg.

# First, import the necessary libraries
import pyarrow as pa
import pyarrow.parquet as pq
import s3fs
import duckdb

# Connect to Minio using s3fs
fs = s3fs.S3FileSystem(
    anon=False,
    use_ssl=False,
    client_kwargs={
        "region_name": "us-east-1",
        "endpoint_url": "http://localhost:9000",
        "aws_access_key_id": "minio",
        "aws_secret_access_key": "minio123",
        "verify": False,
    }
)

# Create a Parquet dataset for the path "midi_etl/midi" in the "datasets" bucket
note_ons = pq.ParquetDataset("midi_etl/midi/note_ons", filesystem=fs).read()

# Open a connection to a DuckDB database
conn = duckdb.connect()

# Now you can run SQL queries on the table using the connection
cursor = conn.cursor()
cursor.execute("SELECT * FROM note_ons LIMIT 10")
print(cursor.fetchall())

Makefile

load_env is a make target that exports variables from a .env file into your local shell

get_trino_cli is a make target that downloads the Trino command-line interface (CLI) from a URL. This is then mounted into the trino container to provide CLI Trino access.

Available Datasets

  • Lakh MIDI Dataset: The Lakh MIDI dataset is a collection of 176,581 MIDI files, 45,129 of which have been matched and aligned to entries in the Million Song Dataset, and is intended for use in large-scale music information retrieval

License

This repository is licensed under the MIT license. See LICENSE for more information.

Versioning

For now consider every version change a potentially breaking change. If I ever get around to adding tests and such then I will add semantic versioning.

Metadata

Release files for midi-etl 0.0.5

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

Source distribution (sdist)

Source distribution for midi-etl 0.0.5
File Size Uploaded Provenance Actions
midi_etl-0.0.5.tar.gz 7.1 kB Without provenance Details for midi_etl-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for midi-etl 0.0.5
File Interpreter ABI Platform Actions
midi_etl-0.0.5-py3-none-any.whl Python 3 none any Details for midi_etl-0.0.5-py3-none-any.whl

Total release size: 14.7 kB

Release files / midi_etl-0.0.5.tar.gz

Download URL midi_etl-0.0.5.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d031e38e2b5ac3728054627b5057a7b20ea2fcd2750afb20bc3a8e72fa40e356
BLAKE2b-256 checksum
How to use checksums
6ceb66b8903d39f82e8baa244e02b9241c8dea7ec5014d88fb41e06522a87308
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / midi_etl-0.0.5-py3-none-any.whl

Download URL midi_etl-0.0.5-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0e512742b1dc7ebda2ae134b248b92405fb94b44fa33a32e375ef12bf1ca410
BLAKE2b-256 checksum
How to use checksums
4621f05375d62dce87c2bd94a37de9a1ee6d9286d5cf05557555177bdca2c5a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for midi-etl 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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