# CLI

> pip install floe-python installs the floe command (see installation.md). floe --help and floe <command> --help list every flag; floe --version prints the…

Source: https://openlakeforge.dev/floe/reference/cli/

`pip install floe-python` installs the `floe` command (see [installation.md](https://openlakeforge.dev/floe/get-started/installation/)).
`floe --help` and `floe <command> --help` list every flag; `floe --version` prints the version.

## Commands

- `floe validate -c <config> [-p <profile>] [--entities <name[,name...]>]`
  - Validate YAML config and exit with non-zero code on errors.
  - `-p` applies an environment profile first. With `-p` and no `-c`, only the profile is validated.

- `floe run (-c <config> | --manifest <manifest.json>) [-p <profile>] [--run-id <id>] [--entities <name[,name...]>] [--domain <name[,name...]>] [-F|--full-refresh] [--dry-run] [--log-format off|text|json] [--quiet|--verbose]`
  - Execute ingestion using the config, or a manifest generated by `floe manifest generate`.
  - Run reports are written under `<report.path>/run_<run_id>/...` as defined in the config,
    or `<report.path>/<domain>/run_<run_id>/...` when every selected entity has one domain (D37).
  - `-c` takes a local path. `--manifest` also takes an `s3://`, `gs://` or `abfss://` URI. `s3://` is read with the AWS default credential
    chain (`AWS_ENDPOINT_URL_S3` and `AWS_S3_FORCE_PATH_STYLE` for S3-compatible stores); `gs://` and `abfss://` with
    `GOOGLE_*` and `AZURE_*` from the environment (`AZURE_STORAGE_ENDPOINT` for an emulator). Relative local
    paths in a remote manifest resolve under its `work_root`, else `FLOE_WORK_ROOT`, else `/work` for an
    `image` manifest or the current directory for a `cli` one. An `s3://` `report_base_uri` writes the
    reports there.
  - `-p` applies an environment profile (a usage error with `--manifest`: the manifest is already compiled).
    It takes a local path, an `s3://`, `gs://` or `abfss://` URI read as `--manifest` is, or `env:NAME`, the profile YAML held in environment
    variable `NAME` (every command that takes `-p` does the same).
  - `--domain` selects every entity of the named domains (repeatable or comma-separated), in config order.
    An unknown domain is an error, and `--domain` cannot be combined with `--entities`.
  - `-F` / `--full-refresh` rebuilds the accepted output from every input: files the incremental state
    already lists are read again, `append` writes as `overwrite`, and with `sink.archive` the archived files are read
    too (D24). `merge_scd1` replaces the table with the inputs' rows in one commit, so a row deleted at the source
    leaves the table; a key in several inputs keeps the latest file's row. It is rejected with `merge_scd2`, whose
    version history cannot be rebuilt from the inputs.
  - `--log-format json` emits NDJSON events to stdout (useful for orchestrators); `off` is the default.
  - `--dry-run` resolves entity inputs and output targets without running ingestion.
  - `--quiet` reduces console output to run totals.
  - `--verbose` expands run output details.
  - An entity aborted by its policy fails only that entity; the run continues and exits `2` (D36).

- `floe manifest generate -c <config> -o <path|s3://...|-> [-p <profile>] [--entities <name[,name...]>] [--deterministic] [--manifest-name <name>] [--default-domain <domain>] [--manifest-path-mode default|resolved-uri] [--runtime image|cli]`
  - Validate config and generate a common orchestrator manifest JSON (`spec_version` = the Floe major.minor).
  - `-p` applies an environment profile (variables, storages, catalogs, lineage) as `floe run -p` does, and records its `profile_uri` and `profile_checksum`. Its `execution` block sets `execution.orchestration` and, for a `kubernetes_job` or `databricks_job` runner, the `default` runner definition.
  - `-o -` writes manifest JSON to stdout; an `s3://`, `gs://` or `abfss://` output is uploaded.
  - `--deterministic`, `--manifest-name`, `--default-domain`, `--manifest-path-mode` and
    `--runtime` are described in [manifest.md](https://openlakeforge.dev/floe/guides/manifest/).

- `floe add-entity -c <config> --input <path|file://...> [--format csv|json|parquet|xlsx] [--name <entity>] [--domain <domain>] [--source <ref> --resource <name>]`
  - Infer a schema from an input file and add a new entity to the config.
  - If `--domain` matches an included domain and `--output` is omitted, writes `<domain folder>/<name>.yml`; fields supplied by domain defaults are omitted from that file.
  - If `-c` points to a missing file, Floe creates a minimal config and adds the entity.
  - If `--format` is omitted, Floe infers it from the input file extension (`.csv`, `.json`, `.parquet`, `.xlsx`).
  - XLSX inference requires `floe-python[xlsx]`. Floe uses the first worksheet, reads its first row as column names, and gives each column type `string`.
  - If `--name` is omitted, Floe infers it from the input filename stem.
  - `--source` and `--resource` write a reference to a declared `sources:` entry; `--input` remains the file used for schema inference.
  - Generates defaults for `sink`, `policy`, and `schema.mismatch`.
  - JSON inference is v0.3 bootstrap-focused: top-level keys only; nested objects/arrays are inferred as `string`.
  - `--dry-run` prints the YAML that would be written without creating the file.
  - `--output <new.yml>` writes the updated root config to a new file instead of overwriting `-c`; with an included domain, this keeps the existing inline entity behavior.

- `floe state inspect -c <config> --entity <name> [-p <profile>]`
  - Print the resolved incremental state URI for an entity and the current state JSON when present.
  - Shows processed-file and active-claim counts.
  - Helpful for confirming what Floe has already seen in `incremental_mode: file`.
  - See [docs/incremental.md](https://openlakeforge.dev/floe/concepts/incremental/) for state file and CAS details.

- `floe state reset -c <config> --entity <name> --yes [-p <profile>]`
  - Remove the local or remote state object for an entity.
  - Requires `--yes` because the next incremental run may reprocess previously tracked files.
  - Remote resets write the empty state conditionally (version or ETag), as remote incremental state does.
  - See [docs/incremental.md](https://openlakeforge.dev/floe/concepts/incremental/) for reset behavior and permissions.

- `floe state forget -c <config> --entity <name> --file <uri> [--file <uri> ...] --yes [-p <profile>]`
  - Remove the named files from an `incremental_mode: file` entity's state so the next run ingests them again, for example a corrected file a partner re-sent. The other files, claims and watermark are untouched.
  - `--file` is the exact URI `floe state inspect` prints, no normalization. Refused, with nothing written, when a URI is not tracked, is under a live claim, or (with `source.partitioning`) falls before the listing window (use `--full-refresh`), and when the entity is not in `file` mode.
  - Requires `--yes`. The state is written conditionally, as for `reset`.
  - See [docs/incremental.md](https://openlakeforge.dev/floe/concepts/incremental/#re-ingest-a-changed-file).

- `floe maintain -c <config> [-p <profile>] [--entities <name[,name...]>] [--older-than-days <n>] [--retain-last <n>] [--orphan-delay-days <n>] [--dry-run] [--compact --experimental]`
  - Expire old snapshots of each selected entity's Iceberg accepted table, then remove its orphan files; entities with other sinks are skipped.
  - A snapshot is expired only if it is older than `--older-than-days` (default 7) **and** outside the newest `--retain-last` (default 10). Branch and tag heads are never expired.
  - The retention floor is 7 days and 10 snapshots: a request below it fails, it is not clamped. The run's retry guard reads recent snapshot summaries, so it relies on this floor.
  - Expiry changes table metadata only and deletes no file; time travel to an expired snapshot fails afterwards.
  - Orphan removal then deletes every object under the table location that the retained metadata no longer references (the files only expired snapshots used, and files of failed writes), once it is older than `--orphan-delay-days` (default 3, at least 1). The delay keeps the files an in-flight `floe run` has written but not committed yet, so keep it longer than your longest run. Don't keep other files under a table's location: they count as orphans.
  - The scan lists S3 through Floe's storage client (`list` permission on the table prefix) and fails without deleting anything if the listing misses the table's current metadata file.
  - `--dry-run` commits nothing and deletes nothing: it prints the snapshots it would expire, and the orphan files and their total bytes as of now. Files that only the expired snapshots reference show up on the next run.
  - `--compact --experimental` (experimental) first compacts the table: it reads the whole table at its current snapshot through DuckDB, with the MERGE position deletes applied, and rewrites it into target-sized files (`write.target-file-size-bytes`). It then commits one `replace` snapshot that drops every old data and delete file. `--compact` without `--experimental` is refused, and `--compact` has no dry run.
    - It subclasses private PyIceberg 0.12 internals, so a PyIceberg upgrade can break it. A test pins the PyIceberg version.
    - Unpartitioned tables only, and no equality deletes. Every rewritten row is counted before the commit; on a mismatch nothing is committed.
    - An append that lands during the compaction is kept. A MERGE that commits against the files being rewritten fails the compaction, so rerun it. A MERGE that started before the compaction committed fails at its own commit instead.
    - Memory: DuckDB's resident memory overshoots its `memory_limit` by about 1.9x on large tables. Size the pod at `memory_limit` + ~3.5 GB (500M rows: 7.4 GB peak at a 4 GB limit).
    - The replaced files are reclaimed by orphan removal once the snapshots that reference them are expired.
  - Run it after ingestion, not beside it.

- `floe contract import <workbook.xlsx> --output-dir <dir> [--domain NAME] [--dry-run] [--check] [--accept-breaking] [-c config.yml]`
  - Offline: turns a business-owned domain workbook into one entity file per table plus a fail-closed `_domain.yml` scaffold (only if absent). Needs the `xlsx` extra and no `config.yml`. The workbook's `Guide` sets the domain; `--domain` only guards that it matches.
  - Any workbook error fails the command with cell diagnostics before anything is planned. Output: `created / updated / unchanged / blocked` counts, one line per file, then the changes grouped by `breaking`, `tightening`, `loosening`, `additive`, `metadata`.
  - Reimport rewrites only the business-owned keys and leaves every other byte alone. A file whose owned keys were edited by hand, or that was not generated, is `blocked`. Nothing is ever deleted: an entity file with no row in the workbook is reported as breaking.
  - Any `blocked` file, unsafe path, or breaking change without `--accept-breaking` fails and writes nothing.
  - `--dry-run` prints the plan and writes nothing. `--check` writes nothing and exits non-zero when a file would be created or updated.
  - `-c config.yml` validates the project as it would be after the import (in a temporary copy) before writing, and lists engineer settings that weaken the contract. Failures that only name `TODO_` placeholders are reported as "complete `_domain.yml`, then run `floe validate`"; any other failure blocks. `--output-dir` must be inside the config's directory.
  - See [Business contract](https://github.com/OpenLakeForge/floe/blob/v1.1.0/docs/guides/business-contract.md).

### Dry-run behavior

- Dry-run resolves input files/objects using the same planning path as real runs.
- For cloud sources, dry-run lists matching objects but does not download them.
- Console preview prints resolved file count and a capped list (`50` entries by default).
- Use `--verbose` to print the full resolved file list.

## Examples

- Validate the sample config:
  - `floe validate -c example/config.yml --entities customer`

- Run with default paths from the config:
  - `floe run -c example/config.yml --entities customer`
- Run every entity of a domain:
  - `floe run -c example/config.yml --domain sales`
- Full refresh of one entity:
  - `floe run -c example/config.yml --entities customer --full-refresh`
- Run from a manifest:
  - `floe run --manifest manifest.json --entities customer`
- Run with JSON logs:
  - `floe run -c example/config.yml --entities customer --log-format json`
- Dry-run preview:
  - `floe run -c example/config.yml --entities customer --dry-run`
- Generate common manifest:
  - `floe manifest generate -c example/config.yml --output orchestrators/airflow-floe/example/manifest.airflow.json`
- Print common manifest to stdout:
  - `floe manifest generate -c example/config.yml --output -`
- Add an entity from a CSV file:
  - `floe add-entity -c example/config.yml --input ./in/customers.csv --format csv --name customers`
- Bootstrap a new config file and infer name/format:
  - `floe add-entity -c new-config.yml --input ./in/orders.csv`
- Inspect incremental state:
  - `floe state inspect -c example/config.yml --entity customer`
- Reset incremental state:
  - `floe state reset -c example/config.yml --entity customer --yes`
- Expire old snapshots of an Iceberg entity (preview first):
  - `floe maintain -c config.yml --entities orders --dry-run`
- Report output:
  - `example/report/run_<run_id>/run.summary.json`
  - `example/report/run_<run_id>/customer/run.json`

- Set a run id:
  - `floe run -c example/config.yml --entities customer --run-id dev-001`

---

<small>Synced from floe @ `v1.1.0` (`313b534`), [docs/reference/cli.md](https://github.com/OpenLakeForge/floe/blob/313b53441b3b088290403ed1adb2f3894833b6c5/docs/reference/cli.md).</small>
