Skippr is now Manifold.

Skip to content

Python ​

The mfd package runs the Mfd engine inside Python. You build a pipeline with Config, run it with Session, and read the results as Arrow tables. It is the same engine as the mfd command, and both read and write the same mfd.yml, so you can build a config in a notebook and run it from cron with the CLI.

Before you begin ​

  • Python 3.10 or later on macOS arm64 or Linux x86_64.
  • Install the package, and the pandas extra if you want .to_pandas():
bash
pip install mfd
pip install "mfd[pandas]"   # optional
python -c "import mfd; print(mfd.Session)"

The package ships type stubs, so your editor, mypy, and coding assistants see every connector class, field, and docstring. Connectors download on first use from install.manifold.soundingworks.uk. See Install for details.

Run a pipeline ​

Session binds the engine to one pipeline. Each Python call has a CLI equivalent.

python
import mfd

cfg = mfd.Config.discover()
s = mfd.Session(cfg.get_pipeline("bikehire"))
s.doctor()
s.discover()
s.migrate()
s.sync(once=True)
s.df()
bash
mfd doctor
mfd discover --pipeline bikehire
mfd migrate --pipeline bikehire
mfd sync --pipeline bikehire --once
mfd df --pipeline bikehire
  • Config.discover() loads mfd.yml from the current directory, or starts an empty config that saves there. Config.load(path) loads a specific file.
  • Session takes a PipelineRef from a Config, never a name string. To run another pipeline, open another Session.
  • discover() samples the source and records the schema. migrate() applies migrations/*.sql (see mfd migrate). sync(once=True) runs one pass and returns. sync() keeps running, one pass every sync_frequency_seconds (900 by default).

Author those SQL files with Migration. Migrate never loads .py:

python
from mfd import Migration

Migration(
    "20261020_rename_region",
    up="ALTER TABLE bikehire.trips RENAME COLUMN region TO region_code;",
    down="ALTER TABLE bikehire.trips RENAME COLUMN region_code TO region;",
).write("migrations")
s.migrate()

Declared compute is Transform(compute=...) (type: sql, type: sdl, or type: py). ComputeItemPy(path=..., handler=...) names a .py file relative to mfd.yml and a function in that file. Mfd loads it in a bounded python3 worker (sys.path is that file's directory, so sibling import lookup works). Inline value: is an unknown field. The same IR journals in Manifold Store. See Transforms and Materialised views.

When you create a Session, it takes a snapshot of its pipeline's config and resolves every ${NAME} reference from the environment, including a .env file next to mfd.yml. A missing variable raises ValueError there, before any data moves, not halfway through a sync.

Build a config ​

Every connector is a typed class named for its role: DataSourceS3, DataSinkPostgres. Required fields are required keyword arguments. Registering a connector returns a typed ref, and Pipeline takes refs, not "data_sources.x" strings, so a typo is an error in your editor.

python
import mfd
from mfd import Config, DataSourceS3, LocalStorage, Pipeline

cfg = Config().workspace("bikehire").storage(LocalStorage())
src = cfg.data_source(
    "sample",
    DataSourceS3(s3_bucket="mfd-public-sample-data", s3_prefix="bike-hire"),
)
bikehire = cfg.pipeline("bikehire", Pipeline(data_source=src, sync_frequency_seconds=60))
cfg.save("mfd.yml")

s = mfd.Session(bikehire)
s.discover()
bash
mfd --workspace bikehire --storage-mode local connect data-source s3 \
  --pipeline bikehire \
  --name sample \
  --s3-bucket mfd-public-sample-data \
  --s3-prefix bike-hire

mfd discover --pipeline bikehire
yaml
mfd:
  workspace: bikehire
  mfd_el_storage_mode: local

pipelines:
  bikehire:
    data_source: data_sources.sample
    sync_frequency_seconds: 60

data_sources:
  sample:
    S3:
      s3_bucket: mfd-public-sample-data
      s3_prefix: bike-hire

Where Mfd keeps its own state is a class too:

  • LocalStorage() keeps state in the local data directory (./data by default). Good for trying things out and single-machine runs.
  • S3Storage("your-state-bucket") keeps state in an S3 bucket instead of on local disk.

cfg.store(...) chooses the local Manifold Store: FjallStore() (the default). See Manifold Store.

cfg.to_yaml() shows the config as YAML without writing it. cfg.save() writes back to the file the config was loaded from; cfg.save(path) writes somewhere else. save writes YAML only and refuses .json and .toml paths.

Update an existing config ​

Registering a name again, save, and mfd connect all merge the same way, so Python and the CLI never fight over a file:

  • Each top-level field you set replaces that field. A nested field such as object_store is replaced whole.
  • Fields you did not set, other pipelines, and other entries are kept.
  • An entry cannot change connector type. Re-registering sample as DataSourceFile when the file has S3 is an error.
  • LocalStorage() removes any mfd_s3_bucket.
python
from mfd import Config, DataSourceS3

disk = Config.discover()
disk.data_source("sample", DataSourceS3(s3_bucket="mfd-public-sample-data", s3_prefix="bike-hire-2026"))
disk.save()
bash
mfd connect data-source s3 \
  --pipeline bikehire \
  --name sample \
  --s3-bucket mfd-public-sample-data \
  --s3-prefix bike-hire-2026

Registration and save check the whole merged config, so you find problems when you write the file rather than when a pipeline runs:

  • every entry names a known connector, and unknown keys outside connector blocks are an error;
  • every secret is a ${NAME} reference — a plaintext secret already in the file blocks save until you replace it;
  • every pipeline with a source is valid;
  • no two ManifoldLake or DuckDB destinations write to the same table namespace;
  • leftover schema_sinks YAML or schema_sink on a data sink is a load error.

Keep secrets out of the file ​

Secret fields accept only EnvRef, never a plain string, so a password cannot reach mfd.yml. Export the variable before you create the Session:

bash
export POSTGRES_PASSWORD="your-password"
python
from mfd import Config, DataSinkPostgres, EnvRef, Pipeline

cfg = Config.discover()
src = cfg.get_data_source("sample")
warehouse = cfg.data_sink(
    "warehouse",
    DataSinkPostgres(
        host="localhost",
        user="mfd",
        password=EnvRef("POSTGRES_PASSWORD"),
        database="analytics",
    ),
)
cfg.pipeline("bikehire", Pipeline(data_source=src, data_sink=warehouse))
cfg.save()
bash
mfd connect data-sink postgres \
  --pipeline bikehire \
  --name warehouse \
  --host localhost \
  --user mfd \
  --password '${POSTGRES_PASSWORD}' \
  --database analytics
yaml
data_sinks:
  warehouse:
    Postgres:
      host: localhost
      user: mfd
      password: ${POSTGRES_PASSWORD}
      database: analytics

All three write password: ${POSTGRES_PASSWORD}. Path-like fields typed as str, such as Snowflake private_key_path, take the "${NAME}" string directly.

Nested and tagged fields ​

Nested settings are their own frozen classes, named after their connector. A field that accepts one of several shapes takes one class per variant. For example, a ManifoldLake destination whose files live in Cloudflare R2:

python
from mfd import Config, DataSinkManifoldLake, DataSinkManifoldLakeWarehouseObjectStoreR2, EnvRef

cfg = Config.discover()
lake = cfg.data_sink(
    "lake",
    DataSinkManifoldLake(
        warehouse="s3://my-iceberg-warehouse/",
        catalog_table="my-iceberg-catalog",
        object_store=DataSinkManifoldLakeWarehouseObjectStoreR2(
            endpoint="https://<account>.r2.cloudflarestorage.com",
            access_key_id="<access-key-id>",
            secret_access_key=EnvRef("OBJECTS_SECRET_ACCESS_KEY"),
        ),
    ),
)

Fields with a fixed set of values are frozen enum classes. Pass the class member, not a string. Pipeline(data_source=src, type="copy") is a type error; use type=PipelineType.COPY. Time partitions take batch_time_unit=BatchTimeUnit.DAY, not "day". Connector fields such as cdc_mode and stream_profile follow the same pattern.

Dest schema ​

The destination publishes its own tables on the first compact. Athena Hive takes glue_database_name on that entry:

python
from mfd import Config, DataSinkAthena, Pipeline

cfg = Config.discover()
src = cfg.get_data_source("sample")
athena = cfg.data_sink(
    "athena",
    DataSinkAthena(
        s3_bucket="your-output-bucket",
        s3_prefix="bikehire",
        glue_database_name="bikehire",
        athena_workgroup_name="primary",
        athena_results_s3_bucket="your-output-bucket",
    ),
)
cfg.pipeline("bikehire", Pipeline(data_source=src, data_sink=athena))
cfg.save()

Refs belong to the Config that returned them. Passing a ref from one Config to another is an error.

Read data with df and query ​

df() and query() read the data Mfd holds for this pipeline — the same views mfd query shows. They read the WAL, combined with the destination's Iceberg tables when the destination is ManifoldLake, AthenaIceberg, or Duckdb. For any other destination they read the WAL only.

python
import mfd

s = mfd.Session(mfd.Config.discover().get_pipeline("bikehire"))
s.df()                                          # every namespace in this pipeline
s.df("rides")                                   # one namespace: bikehire.rides
s.query("SELECT count(*) FROM bikehire.rides")  # any SQL over this pipeline's views
s.df().schema                                   # the Arrow schema
s.df("rides").to_pandas()                       # needs mfd[pandas]
bash
mfd df --pipeline bikehire
mfd df --pipeline bikehire --namespace rides
mfd query --sql "SELECT count(*) FROM bikehire.rides"

A namespace is one table's worth of records. By default a pipeline has one namespace, named after the pipeline; transforms can split records into several. The examples assume a transform has split out a rides namespace. Both methods return a pyarrow.Table.

Check a config before a long run ​

doctor() (or mfd doctor) checks that the config is complete and consistent: at least one pipeline and source, every reference points at an entry that exists, the source format and mode are legal, the storage mode, and the whole-config rules above. It returns a dict with ok and a list of checks. It does not connect to your source or destination; discover() is the first call that does.

Session is bound to one pipeline. A missing ${NAME} or a dangling data_sources.foo raises ValueError when you construct Session, before doctor() runs. The CLI reports a dangling ref as a failed doctor check, and a missing ${NAME} as [mfd] config failed: .... mfd doctor without --pipeline checks every pipeline in the file; mfd doctor --pipeline bikehire is the CLI equivalent of this Session.

python
import mfd

s = mfd.Session(mfd.Config.discover().get_pipeline("bikehire"))
result = s.doctor()
if not result["ok"]:
    for check in result["checks"]:
        print(check)

Run without a destination ​

Leave out data_sink and the pipeline still syncs. The WAL is the dataset, and df() and query() read it. When you want a warehouse, register the destination, register the pipeline again with data_sink=, and open a new Session. Mfd does not compact or reclaim the WAL until the pipeline has a destination, so plan disk space for long WAL-only runs.

dbt and Soda ​

Session loads raw (bronze) data. It does not run dbt.

  1. s.sync(once=True) lands bronze data in the WAL, and in the destination if you set one.
  2. dbt run builds your silver and gold models in the warehouse.
  3. dbt test and soda scan check the results in that warehouse.

Next steps ​