S3
Use the S3 source to load files from a bucket prefix. JSON (including gzip), CSV, and Parquet are supported. Parquet objects are decoded row group by row group into Arrow IPC. On restart, objects Mfd has already committed are skipped.
Before you begin
- A bucket and prefix the caller can
ListBucketandGetObject. - AWS credentials in the environment or an instance role.
bash
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_DEFAULT_REGION="us-east-1"Public sample data used in the quickstarts is s3://mfd-public-sample-data/bike-hire/. Any AWS account can read it.
Configure
python
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"),
)
cfg.pipeline("bikehire", Pipeline(data_source=src))
cfg.save()bash
mfd --workspace bikehire --storage-mode local connect data-source s3 \
--pipeline bikehire \
--name sample \
--s3-bucket mfd-public-sample-data \
--s3-prefix bike-hireyaml
data_sources:
sample:
S3:
s3_bucket: mfd-public-sample-data
s3_prefix: bike-hirebash
mfd discover --pipeline bikehire
mfd sync --pipeline bikehire --once --logOptions
| Key | Type | Required/Default | Description |
|---|---|---|---|
s3_bucket | string | Required | Bucket name |
s3_prefix | string | Not set | Key prefix to list |
format | string | json | json, csv, xml, parquet, avro, or arrow_ipc |
batch_size_seconds | integer | Not set | Max seconds per read batch |
batch_size_bytes | integer | Not set | Max bytes per read batch |
endpoint_url | URL | Not set | S3-compatible endpoint |
region | string | Not set | Region if it is not inferred |
s3_prefix_ordered_depth | integer | 0 | How many prefix levels to walk in order |
s3_delimiter | string | / | Listing delimiter |
Environment variables
| Variable | Description |
|---|---|
AWS_ACCESS_KEY_ID | Access key |
AWS_SECRET_ACCESS_KEY | Secret key |
AWS_DEFAULT_REGION | Region |
What gets synced
Each object under the prefix becomes records in a namespace derived from the key. Progress is the object key plus last-modified time. New objects and updated objects are read; deleted objects are not retracted. Parquet is decoded one row group at a time as Arrow IPC; only the last chunk uses the object key, so a restart skips objects Mfd has already committed.
Troubleshooting
| Symptom | Fix |
|---|---|
Access Denied | Grant s3:GetObject and s3:ListBucket |
NoSuchBucket | Check the name and region |
No files found | Check s3_prefix matches the keys (no leading s3://) |
| Wrong parse | Set format explicitly |
