10. Ship it
Ship the city report with its reusable child, SQL score, Gate, file outputs, and catalog table. The complete script builds the complete pipeline, saves it, and runs it headlessly.
flow_path = output_dir / "city_report.yaml"
routed.flow_graph.save_flow(str(flow_path))
ff.register_flow(routed, name="Tutorial city report")
routed.flow_graph.print_tree()
The standalone YAML goes into the city_report folder; registration also writes a catalog-managed copy named Tutorial city report. The child Tutorial city summary was registered earlier in the script. The writers take the absolute paths they were built with, so the saved flow writes to the same files wherever it runs from.
Run without the UI
subprocess.run(
[sys.executable, "-m", "flowfile", "run", "flow", str(flow_path), "--param", "min_quantity=1"],
check=True,
stdout=subprocess.DEVNULL,
)
print(ff.read_parquet(str(output_dir / "city_report.parquet")).collect())
This is the same command you can run in a terminal from the folder that holds city_report:
flowfile run flow city_report/city_report.yaml --param min_quantity=1
The --param override broadens the report to all positive-quantity invoices. check=True stops the script if the run fails; the script then reads the Parquet file the run wrote.
Open in the Designer
ff.open_graph_in_editor(routed.flow_graph)
The script ends by opening the graph in the Designer, starting the Flowfile server if it is not running. Inspect the Run Flow, SQL Query, Gate, and writer nodes built by the preceding chapters.
Export code
In the Designer's Code panel (Code in the header), select FlowFrame, then Export Code. This report uses Run Flow and Catalog Writer nodes, which require FlowFrame export; the Polars exporter cannot export the complete graph.
Schedule the registered report
In the Catalog, select Tutorial city report. Under Schedules, choose Add. Set When should it run? to On a schedule, choose Daily under Repeats, and set At to your reporting time. Review the time zone shown in the schedule preview, then choose Create schedule. See Scheduling for the scheduler setup and parameter overrides.
Keep runtime dependencies together
The runtime needs the child registration, access to the CSV URL, and the output locations. Copying only the parent YAML to another installation does not install its registered child.
Check it
The script prints the saved graph, then the report the headless run wrote:
● Read data (11) Supermarket invoices
│
● Drop duplicates (12)
│
● Filter data (13)
│
● Formula (14)
├─┐
● │ Filter data (15)
│ ● Filter data (16)
├─┘
● Union data (17)
│ ● Manual input (18)
├─┘
● Join (19)
│
● Run Flow (27)
│
● SQL Query (28) SELECT *, ROUND(100.0 * shortfall / target, 2) ...
│
● Gate (29)
├─┐
● │ Formula (31) [then]
│ ● Formula (33) [else]
├─┘
● Union data (34)
├─┬─┐
● │ │ Write data (35)
● │ Write data (36)
● Write to Catalog (37)
shape: (5, 7)
┌───────────┬────────┬──────────┬─────────┬───────────┬───────────────┬───────┐
│ city ┆ orders ┆ revenue ┆ target ┆ shortfall ┆ shortfall_pct ┆ route │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ u32 ┆ f64 ┆ f64 ┆ f64 ┆ f64 ┆ str │
╞═══════════╪════════╪══════════╪═════════╪═══════════╪═══════════════╪═══════╡
│ Bago ┆ 204 ┆ 59064.26 ┆ 30000.0 ┆ -29064.26 ┆ -96.88 ┆ ready │
│ Mandalay ┆ 215 ┆ 68589.82 ┆ 35000.0 ┆ -33589.82 ┆ -95.97 ┆ ready │
│ Naypyitaw ┆ 176 ┆ 48556.03 ┆ 25000.0 ┆ -23556.03 ┆ -94.22 ┆ ready │
│ Taunggyi ┆ 199 ┆ 67220.88 ┆ 30000.0 ┆ -37220.88 ┆ -124.07 ┆ ready │
│ Yangon ┆ 206 ┆ 64001.27 ┆ 35000.0 ┆ -29001.27 ┆ -82.86 ┆ ready │
└───────────┴────────┴──────────┴─────────┴───────────┴───────────────┴───────┘
The graph is the whole pipeline: the preparation from chapters 1–3, Run Flow calling the child, the SQL Query score, the Gate, and three writers. With min_quantity=1 every city is above its target, so the headless run puts all five on the ready route, from 1,000 invoices. The example script does not create a schedule; the schedule above is the operational setup step.
Complete script
Show the complete runnable script
"""Save the finished city report, run it without the Designer, and open it on the canvas."""
import subprocess
import sys
from pathlib import Path
import flowfile as ff
# Chapters 1-3: read, clean, and enrich the invoices.
SALES = "https://raw.githubusercontent.com/edwardvaneechoud/flowfile/main/data/templates/supermarket_sales.csv"
sales = ff.read_csv(SALES, description="Supermarket invoices")
valid = sales.unique().filter(flowfile_formula="[quantity] > 0 and [unit_price] > 0")
orders = valid.with_columns(flowfile_formulas=["[unit_price] * [quantity]"], output_column_names=["revenue"])
members = orders.filter(ff.col("customer_type") == "Member")
regulars = orders.filter(ff.col("customer_type") == "Normal")
combined = ff.concat([members, regulars], how="diagonal_relaxed")
targets = ff.from_dict(
{
"city": ["Bago", "Mandalay", "Naypyitaw", "Taunggyi", "Yangon"],
"target": [30000.0, 35000.0, 25000.0, 30000.0, 35000.0],
}
)
enriched = combined.join(targets, on="city", how="left")
# Chapters 4, 5 and 8: the report comes from the reusable child flow.
incoming = ff.FlowInput("invoices", schema=enriched.schema)
child_minimum = ff.add_flow_parameter(incoming, ff.Parameter("min_quantity", default=8, type="integer"))
child_summary = (
incoming.filter(ff.col("quantity") >= child_minimum)
.group_by("city")
.agg(
ff.col("invoice_id").count().alias("orders"),
ff.col("revenue").sum().alias("revenue"),
ff.col("target").first().alias("target"),
)
)
child_report = child_summary.with_columns((ff.col("target") - ff.col("revenue")).alias("shortfall")).sort("city")
child_report.to_flow_output("city_report")
report_flow = ff.register_flow(child_report, name="Tutorial city summary")
minimum = ff.add_flow_parameter(enriched, ff.Parameter("min_quantity", default=8, type="integer"))
report = ff.RunFlow(report_flow, invoices=enriched, params={"min_quantity": minimum})["city_report"]
# Chapter 9: the shortfall percentage.
scored = ff.sql("SELECT *, ROUND(100.0 * shortfall / target, 2) AS shortfall_pct FROM report", report=report)
# Chapter 6: route the whole report.
gate = ff.Gate(scored, ff.col("shortfall") > 0)
review = gate.then.with_columns(ff.lit("review").alias("route"))
ready = gate.otherwise.with_columns(ff.lit("ready").alias("route"))
routed = ff.concat([review, ready], how="diagonal_relaxed")
# Chapter 7: the file and catalog writers.
output_dir = Path("city_report").resolve()
output_dir.mkdir(exist_ok=True)
routed.write_csv(output_dir / "city_report.csv")
routed.write_parquet(output_dir / "city_report.parquet")
reports = ff.CatalogReference("tutorial_sales", auto_create=True).schema("reports", auto_create=True)
reports.write_table(routed, "city_report", write_mode="overwrite")
# Chapter 10: ship it.
flow_path = output_dir / "city_report.yaml"
routed.flow_graph.save_flow(str(flow_path))
ff.register_flow(routed, name="Tutorial city report")
routed.flow_graph.print_tree()
subprocess.run(
[sys.executable, "-m", "flowfile", "run", "flow", str(flow_path), "--param", "min_quantity=1"],
check=True,
stdout=subprocess.DEVNULL,
)
print(ff.read_parquet(str(output_dir / "city_report.parquet")).collect())
ff.open_graph_in_editor(routed.flow_graph)
Recap
The same supermarket pipeline now runs from Python, opens as a graph, calls a reusable child, and produces checked report outputs through the CLI. Keep its threshold as a run parameter and its targets as explicit input data.
Next: Operate the saved flow