Skip to content

fastflowtransform.cli.seed_cmd

seed

seed(project='.', env_name='dev', engine=None, vars=None)
High-level entry to run seeding for a project

1) Prepare the runtime context and executor. 2) Resolve per-file targets using seeds/schema.yml. 3) Materialize each seed via the engine-specific path.

Source code in src/fastflowtransform/cli/seed_cmd.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def seed(
    project: ProjectArg = ".",
    env_name: EnvOpt = "dev",
    engine: EngineOpt = None,
    vars: VarsOpt = None,
) -> None:
    """
    High-level entry to run seeding for a project:
      1) Prepare the runtime context and executor.
      2) Resolve per-file targets using seeds/schema.yml.
      3) Materialize each seed via the engine-specific path.
    """
    ctx = _prepare_context(project, env_name, engine, vars)
    execu, _, _ = ctx.make_executor()

    # You can still pass a global default schema; per-file CFG will override it.
    default_schema: str | None = None
    if getattr(ctx.profile, "engine", None) == "postgres":
        default_schema = getattr(getattr(ctx.profile, "postgres", None), "db_schema", None)

    n = seed_project(ctx.project, execu, default_schema)
    echo(f"✓ Seeded {_human_int(n)} table(s)")