quilt

Understanding Quilt: Core Concepts and Mental Model

This guide explains the fundamental concepts behind Quiltโ€™s data management system. Think of it as your roadmap to understanding how Quilt organizes, versions, and manages data.

๐ŸŽฏ The Big Picture

Quilt treats data like code - with versioning, immutability, and collaboration built-in. Instead of managing individual files scattered across storage systems, you work with packages that bundle related data together with metadata and provenance.

Traditional Approach          โ†’    Quilt Approach
โ”œโ”€โ”€ file1.csv                      ๐Ÿ“ฆ myteam/customer-data
โ”œโ”€โ”€ file2.json                     โ”œโ”€โ”€ ๐Ÿ“„ customers.csv
โ”œโ”€โ”€ file3.parquet                  โ”œโ”€โ”€ ๐Ÿ“„ transactions.json  
โ””โ”€โ”€ README.txt                     โ”œโ”€โ”€ ๐Ÿ“„ analytics.parquet
                                   โ”œโ”€โ”€ ๐Ÿ“„ README.md
                                   โ””โ”€โ”€ ๐Ÿท๏ธ  metadata + version hash

๐Ÿ“ฆ Core Concept: Packages

What is a Package?

A package is Quiltโ€™s fundamental unit of data organization. Think of it as a versioned, immutable collection of related files with a clear identity and history.

Key Properties:

Package Anatomy

Every package consists of:

๐Ÿ“ฆ Package: myteam/customer-data
โ”œโ”€โ”€ ๐Ÿท๏ธ  Name: "myteam/customer-data"
โ”œโ”€โ”€ ๐Ÿ” Hash: "a1b2c3d4..." (unique version identifier)
โ”œโ”€โ”€ ๐Ÿ“‹ Manifest: (maps logical โ†’ physical locations)
โ”œโ”€โ”€ ๐Ÿ“ Files:
โ”‚   โ”œโ”€โ”€ customers.csv
โ”‚   โ”œโ”€โ”€ transactions.json
โ”‚   โ””โ”€โ”€ README.md
โ””โ”€โ”€ ๐Ÿ“Š Metadata: {"description": "Q3 customer analysis", "version": "2.1"}

Real-World Example

import quilt3

# Load a package (using public example)
pkg = quilt3.Package.browse("examples/hurdat", "s3://quilt-example")

# Package info
print(f"Package hash: {pkg.top_hash}")     # Unique version identifier
print(f"Files: {len(pkg)}")                # Number of files in package

# List available files
for key in pkg:
    print(f"File: {key}")

๐Ÿ—‚๏ธ The Manifest System

Understanding Manifests

The manifest is Quiltโ€™s โ€œtable of contentsโ€ - it maps user-friendly names to actual file locations and includes integrity information.

Manifest Entry Structure:

(LOGICAL_KEY, PHYSICAL_KEYS, HASH, METADATA)

Logical vs Physical Keys

Aspect Logical Key Physical Key
Purpose User-friendly name Actual storage location
Example "data/customers.csv" "s3://bucket/a1b2c3/customers.csv?versionId=xyz"
Stability Stable across versions Changes with storage
Usage Code references Internal system use

Example Manifest Entry

{
    "logical_key": "data/customers.csv",
    "physical_keys": [
        "s3://company-data/datasets/customers_v2.csv?versionId=abc123"
    ],
    "size": 1048576,
    "hash": {
        "type": "SHA256",
        "value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
    },
    "meta": {
        "schema_version": "2.1",
        "last_updated": "2024-08-26",
        "data_quality": "validated"
    }
}

Why This Matters:

๐Ÿข Registries: Where Packages Live

Registry Concept

A registry is where Quilt stores package manifests and optionally the data itself. Think of it as a โ€œdatabaseโ€ of packages.

Supported Registry Types:

Registry Examples

import quilt3

# Different registry types
local_packages = quilt3.list_packages()                    # Local registry
cloud_packages = quilt3.list_packages("s3://my-bucket")   # S3 registry
public_data = quilt3.list_packages("s3://quilt-example")  # Public registry

๐ŸŒŠ Buckets as Branches

The Git Analogy

In Quilt, S3 buckets function like Git branches - each represents a different stage or environment in your data lifecycle.

Git Workflow              โ†’    Quilt Workflow
โ”œโ”€โ”€ feature-branch             โ”œโ”€โ”€ s3://dev-bucket
โ”œโ”€โ”€ develop                    โ”œโ”€โ”€ s3://staging-bucket  
โ”œโ”€โ”€ staging                    โ”œโ”€โ”€ s3://prod-bucket
โ””โ”€โ”€ main                       โ””โ”€โ”€ s3://archive-bucket
graph LR
    A[Raw Data] --> B[s3://company-raw]
    B --> C[s3://company-staging] 
    C --> D[s3://company-prod]
    D --> E[s3://company-archive]
    
    B -.-> F[Data Validation]
    C -.-> G[Quality Assurance]
    D -.-> H[Production Use]

Three-Bucket Minimum:

  1. ๐Ÿ”ด Raw Bucket (s3://company-raw)
    • Ingested data, minimal processing
    • Experimental datasets
    • Temporary analysis results
  2. ๐ŸŸก Staging Bucket (s3://company-staging)
    • Validated and cleaned data
    • Ready for testing and QA
    • Pre-production datasets
  3. ๐ŸŸข Production Bucket (s3://company-prod)
    • Fully validated, production-ready data
    • Used by live applications and dashboards
    • Strict access controls and governance

Package Promotion Workflow

# Promote a package through environments
import quilt3

# 1. Start in raw environment
raw_pkg = quilt3.Package()
raw_pkg.set("data.csv", "raw_data.csv")
raw_pkg.push("myteam/dataset", registry="s3://company-raw")

# 2. Validate and promote to staging
staging_pkg = quilt3.Package.browse("myteam/dataset", registry="s3://company-raw")
# ... perform validation ...
staging_pkg.push("myteam/dataset", registry="s3://company-staging")

# 3. Final promotion to production
prod_pkg = quilt3.Package.browse("myteam/dataset", registry="s3://company-staging")
# ... final checks ...
prod_pkg.push("myteam/dataset", registry="s3://company-prod")

๐Ÿ”„ Immutability and Versioning

Why Immutability Matters

Immutable packages mean that once created, a package version never changes. This provides:

Version Management

# Working with package versions
import quilt3

# Get latest version (using public example)
latest = quilt3.Package.browse("examples/hurdat", "s3://quilt-example")
print(f"Latest hash: {latest.top_hash}")

# Get specific version
specific = quilt3.Package.browse("examples/hurdat", "s3://quilt-example", top_hash=latest.top_hash)
print(f"Specific version")

# Compare versions
if latest.top_hash == specific.top_hash:
    print("Same version")

๐ŸŽฏ Practical Mental Model

Think of Quilt Likeโ€ฆ

If youโ€™re familiar withโ€ฆ Think of Quilt asโ€ฆ
Git Git for data - versioning, branching (buckets), immutable commits (packages)
Docker Container images for data - immutable, portable, with manifests
Package Managers npm/pip for datasets - named packages, versions, dependencies
Databases Schema-aware data warehouse with built-in versioning and lineage

Key Principles to Remember

  1. ๐Ÿ“ฆ Package-Centric: Always think in terms of related collections, not individual files
  2. ๐Ÿ”’ Immutable: Versions never change - create new versions instead of modifying
  3. ๐Ÿท๏ธ Named & Hashed: Every package has a human name and cryptographic identity
  4. ๐ŸŒŠ Bucket Workflows: Use different buckets for different data lifecycle stages
  5. ๐Ÿ“‹ Manifest-Driven: Logical names abstract away physical storage details

๐Ÿš€ Next Steps

Now that you understand Quiltโ€™s mental model:

  1. Try It: Follow the Quick Start to create your first package
  2. Learn Workflows: Explore package workflows
  3. Set Up Team Access: Configure team access and roles
  4. Advanced Topics: Learn about schemas and validation

Remember: Quilt transforms chaotic data management into organized, versioned, collaborative workflows. The mental model is simple - treat your data like code, and Quilt handles the complexity!