Skip to main content

fw-dataset

fw-dataset provides the classes and functions used to create, manage, and serve Flywheel Datasets — a way to organize, share, and query data derived from the Flywheel Data Model.

[!WARNING] This package is under active development and should be considered unstable. It is provided as-is, with no guarantee of support or maintenance at this stage. Features may be incomplete, change without notice, or be removed in future versions. Use it at your own risk, for experimental or development purposes only.

Overview

A Flywheel Dataset is a versioned, columnar snapshot of a Flywheel project's data, stored in cloud or local object storage and queryable with standard tabular tools. The package exposes three primary entry points:

  • DatasetBuilder — renders a dataset from a Flywheel project snapshot.
  • FWDatasetClient — accesses, queries, and manages existing datasets.
  • Dataset / Table — object models representing a dataset and its tables.

Documentation

The Dataset Definition document is the authoritative reference for the dataset format. It covers:

Installation

fw-dataset requires Python 3.12 or later. Install it with pip:

pip install fw-dataset

Usage

Rendering datasets

Use DatasetBuilder to render a Flywheel dataset from a project. See notebooks/quickstart_dataset_creation.ipynb for a complete walkthrough.

Accessing and managing datasets

Use FWDatasetClient to access and query an existing dataset. See notebooks/quickstart_dataset_management.ipynb for a complete walkthrough.

Working with unassociated datasets

A valid dataset that is not associated with a Flywheel project can still be accessed directly. Provide the type, bucket, prefix, and credentials of the cloud or local filesystem to instantiate and query it — no API key or client instantiation required:

from fw_dataset import FWDatasetClient

fs_type = "s3"  # or "gcs", "azure", "fs", "local"
bucket = "your-bucket"
prefix = "your-prefix"
credentials = {"url": "{bucket-specific-credential-string}"}

dataset = FWDatasetClient.get_dataset_from_filesystem(fs_type, bucket, prefix, credentials)

Merging related datasets

Multiple datasets with related tables can be merged into a single dataset so their tables can be queried together.

[!NOTE] Federated querying across datasets is not yet enabled; this is a work in progress.

Merging requires that both datasets satisfy the following:

  1. A valid tables directory structure.

  2. A valid schemas directory structure, where:

    • every table in tables has a corresponding schema file in schemas;

    • each schema file is named {table_name}.schema.json; and

    • each schema file is valid JSON with at least the following structure:

      {
          "schema": "http://json-schema.org/draft-07/schema#",
          "id": "{table_name}",
          "description": "",
          "properties": {},
          "required": [],
          "type": "object"
      }
      
  3. Tables and schemas selected from the source must not share names with existing tables or schemas in the destination.

Once these requirements are met, merge the datasets by copying or moving the selected tables and schemas from the source dataset into the destination dataset.

Flywheel project requirements

For the Flywheel Dataset client and the Dataset objects to function, a project must provide valid custom-information metadata and a well-formed storage layout.

Project metadata

The Flywheel project must carry the following custom information:

{
    "dataset": {
        "type": "s3",
        "bucket": "{bucket-name}",
        "prefix": "{path/to/dataset}",
        "storage_id": "storage-id-of-fw-storage-object"
    }
}
Field Description
type Storage backend: s3, gcs, azure, or fs/local.
bucket Name of the bucket or container holding the dataset.
prefix Path to the dataset within the bucket or container.
storage_id Flywheel ID of the storage record for the bucket or filesystem.

The directory structure beneath prefix must follow the Dataset structure described below.

Dataset structure

A dataset is stored beneath its prefix with the following layout:

{bucket}/{prefix}/
└── versions/
    └── {version}/
        ├── provenance/
        │   ├── dataset_description.json
        │   ├── snapshot.db.gz
        │   ├── snapshot_info.json
        │   └── project.json
        ├── tables/
        │   └── {table_name}/
        │       └── {hash}.parquet
        └── schemas/
            └── {table_name}.schema.json

Each version lives in its own subdirectory, named with its version identifier (typically a BSON ID such as 66cf6701af1c6f3855f1ee61). The "latest" version is determined dynamically by comparing the creation dates recorded in each version's dataset_description.json.

This layout is described more completely in the Dataset definition document.

Schema files

Schema files describe the schema of each table and live in the schemas directory. Each is named {table_name}.schema.json. Schemas should ideally be fully descriptive, but a minimal schema is sufficient to make a table queryable:

{
    "schema": "http://json-schema.org/draft-07/schema#",
    "id": "{table_name}",
    "description": "Table derived from tabular data file: conditions.csv",
    "properties": {},
    "required": [],
    "type": "object"
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fw_dataset-0.4.2-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

Details for the file fw_dataset-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: fw_dataset-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 59.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.25.0_alpha20260805","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fw_dataset-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32b4026dd361e089e7647ef15731ded12b78065a98b597985a71c33730996be2
MD5 d573c2ea7d781da1e88e695d46c802b6
BLAKE2b-256 a0ed8568c362463656bbc422253f1a7732e94ab0ee7882dcbf069baaa1248542

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page