TACO
stable v0.6.3 ⌄
asterisk-labs/taco

Write

Creating a TACO dataset

Declare the shared contract, describe the collection, add samples, and produce a validated folder or immutable ZIP.

Declare the sample structure

The contract fixes the paths shared by every sample.

Python
import taco

contract = taco.Contract(
    structure=["image.tif", "label.tif"]
)

Describe the dataset

Python
collection = taco.Collection(
    contract=contract,
    id="land-cover",
    dataset_version="1.0.0",
    description="Images and land-cover labels",
    licenses=["MIT"], providers=["Asterisk Labs"],
    tasks=["semantic-segmentation"],
)

Attach the assets

Python
sample = taco.Sample(assets=[
    taco.Asset("image.tif", path="image.tif"),
    taco.Asset("label.tif", path="label.tif"),
])

Write and validate

Python
with taco.open_writer(collection, "land-cover.zip") as writer:
    writer.add(sample)
    writer.run()

assert taco.validate("land-cover.zip").ok

Write a subset

Pass sample rows returned by Dataset.sql(); the subset keeps the contract and inherits collection fields unless you replace them.

Python
dataset = taco.open_dataset("land-cover.zip")
rows = dataset.sql("SELECT * FROM data WHERE sample_id < 100")
taco.export(
    "land-cover.zip",
    "land-cover-sample.zip",
    samples=rows,
    id="land-cover-sample",
    description="First 100 land-cover samples",
)