Document Review Gate

View as Markdown

This recipe demonstrates workflow chaining with a review boundary. It generates synthetic document pages, runs a weak detector to a named review_candidates stage, exports that intermediate dataset, writes a simulated reviewed artifact, and resumes the downstream stages from that reviewed artifact.

The recipe is headless and does not call a model provider. It accepts --model-alias for compatibility with the recipe runner, but all stages use local custom columns.

Run the Recipe

$uv run document_review_gate.py --artifact-path ./workflow-artifacts --num-records 12 --overwrite
$uv run document_review_gate.py --artifact-path ./workflow-artifacts --num-records 12 --review-pages 4 --overwrite
$uv run document_review_gate.py --help

The run writes generated images, exported stage parquet files, the simulated reviewed parquet file, and the final dataset under --artifact-path.

Workflow Pattern

The important part is the boundary contract. The downstream workflow does not care whether review_candidates came from the original detector, a dashboard, a script, or another service. It only consumes the selected stage output. This excerpt uses the setup and path helpers defined in the complete recipe.

1from pathlib import Path
2
3import data_designer.config as dd
4
5base_dir = Path("./workflow-artifacts")
6workflow = build_workflow(base_dir)
7results = workflow.run(targets="review_candidates")
8review_path = review_candidates_path(base_dir)
9results.export_stage("review_candidates", review_path)
10
11reviewed_path = write_simulated_review_artifact(base_dir)
12
13workflow.run(
14 resume=dd.ResumeMode.ALWAYS,
15 stage_output_overrides={"review_candidates": reviewed_path},
16)

Use this pattern when an intermediate dataset needs inspection, policy checks, cleanup, or human review before downstream stages should run.