Skip to content

pyflightstream.run.matrix (stable)

Generated from the docstrings at build time: every one of the 9 names in the __all__ of pyflightstream.run.matrix has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

Planning and running a bound run matrix.

Pipeline role: the run-layer half of the run matrix, and the one-call first-class entry of the file-managed modality. :func:plan_matrix pre-flights a matrix without executing anything and :func:run_matrix takes it all the way to manifest records, composing the binding step of :mod:pyflightstream.workspace.matrix with the campaign loop of :mod:pyflightstream.run.

It sits here rather than beside the reader because that is where its dependencies are. The reader in :mod:pyflightstream.cases.matrix carried these two entry points and imported the campaign loop inside their bodies, which recorded the upward dependency without declaring it (OPS-2007.01, PFS-2009.05); at this layer the same imports are ordinary module-level ones. Nothing about the matrix format, the flags or the records moved with them.

it also carries the ADDITIONAL POST (G12): :func:plan_additional_post and :func:run_additional_post reopen each recorded point's final saved simulation and extract a second pproc from it with no solve, choosing the executor as :func:run_matrix does.

:mod:pyflightstream.run deliberately does NOT import this module, so importing it can never be part of an import cycle: the dependency runs one way, from here into the campaign loop.

Size exemption: the plan, run and additional-post entry points share one resolved-matrix binding. Each binds the matrix rows to builds, executors and recipes the same way; parting the additional post from the run is a cut of its own, not the facade cut (AD-14).

Used in the guides

pyflightstream.run.matrix.run_matrix

run_matrix(
    path: str | Path,
    workspace: CampaignWorkspace,
    *,
    warning_refusals: bool | None = None,
    name: str,
    recipes: Mapping[str, str],
    assess: OutcomeAssessor,
    default_fs_version: str | None = None,
    fs_exe: str | Path | None = None,
    executor: Executor | None = None,
    recipe_registry: dict[str, ScriptRecipe] | None = None,
    resume: bool = False,
    force_rerun: Sequence[str] | None = None,
    force_rerun_all: bool = False,
    sims: Sequence[str] | None = None,
    points: Sequence[str] | None = None,
    progress_every: int = PROGRESS_EVERY_DEFAULT,
    hidden: bool | None = None,
    fs_version: str | None = None,
    name_from: str | None = None,
    ignore_missing_families: bool = True,
    accept_unregistered_build: bool = False,
    sweep_csv: object = None,
    local: bool = False,
    require_plan: bool = False,
    parallel: int | str | None = None,
) -> list[RunRecord]

Read a run matrix and run it: the one-call first-class entry.

In order: the matrix converts through the canonical campaign form, its codes resolve against the workspace input library (:func:pyflightstream.workspace.matrix.resolve_matrix), the whole campaign pre-flights in dry run, and only then the points execute through :func:pyflightstream.run.run_campaign, landing one manifest record per point. A blocked pre-flight refuses to execute at all, so a broken recipe or missing artifact costs no solver time. A row whose build declares a version of its own pre-flights and runs under that version (PFS-2009.05.02; :func:plan_matrix says how the version is read).

A matrix whose rows build native geometry with the solver runs in three phases, so no refusal that does not depend on the geometry spends a seat (R28-008): first the independent pre-flight (the plan receipt when require_plan, and, with a native row selected, every row's recipe and its REF, SET and PPROC codes; preflight_before_native_build), then the native build through the run's executor (a submitting executor is refused before anything is submitted), then the pre-flight that needs the built geometry (the binding, the receipt's per-simulation build contract and the dry run of every point, which refuses a blocked point).

Parameters:

Name Type Description Default
warning_refusals bool

Restore demoted refusals for this call; None uses the runtime option.

None
path str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix; the executable comes from the FS_BUILD column through the build registry, or from the explicit fs_exe override (mandatory for MANUAL rows).

required
workspace str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix; the executable comes from the FS_BUILD column through the build registry, or from the explicit fs_exe override (mandatory for MANUAL rows).

required
name str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix; the executable comes from the FS_BUILD column through the build registry, or from the explicit fs_exe override (mandatory for MANUAL rows).

required
recipes str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix; the executable comes from the FS_BUILD column through the build registry, or from the explicit fs_exe override (mandatory for MANUAL rows).

required
fs_exe str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix; the executable comes from the FS_BUILD column through the build registry, or from the explicit fs_exe override (mandatory for MANUAL rows).

required
default_fs_version str

FlightStream version for rows whose FS_BUILD column names no build; a DEFAULT rather than an override (PFS-2009.08.01).

None
fs_version None

The former name of default_fs_version: any other value is refused with a :class:MatrixError naming default_fs_version.

None
assess OutcomeAssessor

Solver-quality judgment, for example :class:pyflightstream.run.LoadsAssessor; required because the loop refuses to invent convergence evidence.

required
executor Executor

Replacement executor; by default a :class:pyflightstream.run.LocalExecutor is built from the resolved executable. Given one, it answers for EVERY row, including a row whose FS_BUILD cell names a second installation: a caller who hands in an executor has bound the run to it, and building a local executor beside it would send some rows to a process the caller never asked for. Left out, one local executor is built per distinct executable the matrix names, each with the window setting hidden resolves to.

None
recipe_registry dict of str to ScriptRecipe

Named recipe registry (name to callable), forwarded to the pre-flight and the campaign loop.

None
force_rerun sequence of str

The points to REDO rather than refuse, each by its point name, its full run_id, or the job id of a swept row. For a row that was wrong: the record and the point's collected outputs are archived first, and nothing is deleted. It names points rather than being a switch because redoing a whole matrix over one wrong row spends a licensed seat per point. Refused together with resume.

None
force_rerun_all bool

REDO every recorded point of the matrix (G44): each recorded point, and each recorded steady job as a whole, is archived and runs again, with the count of points and jobs said before anything runs. A point recorded as SUBMITTED, or of a batch whose job has not ended, is redone with a warning; its old job is not cancelled. Refused together with resume and with force_rerun, and when nothing of the selection is recorded.

False
progress_every int

How often a local unsteady point says its progress, in completed time steps, read from the run's own step counter (G43); 10 by default, 0 to say nothing.

PROGRESS_EVERY_DEFAULT
sims sequence of str

The simulations to run, by their ids as the matrix spells them (leading zeros kept); the run then touches those simulations only (FR-326). With force_rerun_all, the simulations to redo. An id the matrix does not carry is refused before anything runs.

None
points sequence of str

With sims, the points of those simulations to run, by the point names the plan prints (FR-326); every other point is left untouched. A point the matrix does not carry is refused before anything runs, and force_rerun_all refuses a selection of points.

None
resume bool

With True, points already in the manifest are skipped, so a grown matrix re-runs only its new points; with False (the default) an already-recorded point raises before anything executes, as in :func:pyflightstream.run.run_campaign.

False
ignore_missing_families bool

Whether a pproc entry naming a family the opened mesh does not carry is left out (the default, True) or BLOCKS the point (False), in which case the blocked pre-flight refuses the whole run before a seat is spent. Forwarded to :func:pyflightstream.workspace.matrix.resolve_matrix (PFS-2035.13); the command line spells it --ignore-missing-families.

True
sweep_csv object

Retired with the table it named; any value but None is refused naming the successor.

None
local bool

Keep the run on this machine: the cluster is not asked, so a Linux box carrying a submission profile runs the solver itself, as Windows does, and every point's executor entry says forced_local. Refused beside a submitting executor. The command line spells it --local.

False
parallel int or str

Solver runs alive at once, as run_campaign(parallel=...); None reads the setup's [runtime] block and otherwise runs one at a time. The command line spells it --parallel.

None
hidden bool or None

Windowless solver runs, forwarded to the default executor only and ignored when executor is given. The default is None, meaning the matrix decides through its HIDDEN column: the run is windowless only if EVERY active row asks for it, so one row saying 0 makes the whole campaign visible. An explicit True or False wins over the column, because a caller who names it means it.

None
name_from str

Where the campaign name came from, option or directory, recorded in the plan and the run records; None when the caller does not say.

None
accept_unregistered_build bool

Run on an installed build other than the one registered for the version a row names instead of refusing it; the run warns and every record says the flag was used.

False
require_plan bool

Require a matching receipt after resolving the effective build and its acceptance. The CLI sets this; Python callers default to False.

False

Returns:

Type Description
list of pyflightstream.workspace.RunRecord

The records executed by this call, in execution order. Each one names the installation it ran on (fs_exe, hashed into fs_exe_sha256), the version its script was emitted under (fs_version_requested), and which of the two possible sources chose the installation (fs_version_source: row for a point whose FS_BUILD cell named the build, campaign_default for one that named none and for every point of a run given the explicit fs_exe override, which overrules the column). Those three reproduce the run without the matrix (PFS-2009.08.02).

The first two are PER ROW since PFS-2009.05: a row naming a build is recorded against that build's own executable, and against the version its registry entry declares where it declares one. A row that names none, and every row of a registry written as bare path strings, is recorded against the campaign default exactly as before.

Raises:

Type Description
MatrixError

Layout or build-selection problems, a blocked pre-flight (the message carries the plan summary; nothing was executed), no default version given under either spelling, or a default that strips to empty. The last names every active row whose FS_BUILD cell strips to empty too, by row number and POL, and is raised before the matrix is bound: no campaign is built, no executable is resolved and no executor is constructed (PFS-2009.08.03).

InputArtifactError

A REF, SET or ENTRY code, or a GEOMETRY stem, that the input library cannot resolve. Raised during resolution, before the pre-flight and before any executor is constructed. This uses the same resolver as :func:plan_matrix.

ExecutorConfigurationError

When the identity pre-flight finds the wrong build installed; raised before any point executes.

CampaignErrors

After the loop, when at least one executed point failed.

Examples:

>>> from pyflightstream.run import LoadsAssessor
>>> from pyflightstream.run.matrix import run_matrix
>>> from pyflightstream.workspace import CampaignWorkspace
>>> records = run_matrix(
...     "matrix.fs",
...     CampaignWorkspace("campaign"),
...     name="wing_steady",
...     default_fs_version="26.120",
...     recipes={"003": "recipes.steady_polar:build"},
...     assess=LoadsAssessor(),
... )

Advanced

pyflightstream.run.matrix.AdditionalPointPlan dataclass

AdditionalPointPlan(
    run_id: str,
    sim_id: str,
    point_name: str | None,
    pproc: str | None,
    status: str,
    reason: AdditionalSkip | None = None,
    message: str = "",
    unsteady: bool = False,
    fsm: str | None = None,
    script_text: str | None = None,
    context: Mapping[str, object] = dict(),
)

What the additional post will do for one recorded point.

Attributes:

Name Type Description
run_id str

The point's run id.

sim_id str

Its simulation, the matrix POL.

point_name str or None

Its point name.

pproc str or None

The additional pproc id its row states, or None.

status str

READY or SKIPPED.

reason AdditionalSkip or None

Why a skipped point was skipped.

message str

The sentence that says so, naming the path or the hashes involved.

unsteady bool

Whether the point marched in time, so its extraction is one instant.

fsm str or None

The saved simulation, relative to the simulation folder.

script_text str or None

The extraction script of a READY point, built before any launch.

pyflightstream.run.matrix.AdditionalSkip

Bases: StrEnum

Why a recorded point was not extracted, one word each (G12).

pyflightstream.run.matrix.ONE_INSTANT module-attribute

ONE_INSTANT = "the saved simulation holds the LAST instant of this unsteady run (RPT-062): this extraction is that one instant and not the run's per-step history; its plots history is the run's own"

pyflightstream.run.matrix.REOPENED_SUFFIX module-attribute

REOPENED_SUFFIX = '.reopened.fsm'

pyflightstream.run.matrix.plan_additional_post

plan_additional_post(
    matrix: str | Path,
    workspace: CampaignWorkspace,
    *,
    default_fs_version: str | None = None,
    recipes: Mapping[str, str] | None = None,
    fs_exe: str | Path | None = None,
) -> list[AdditionalPointPlan]

Say, per recorded point of a matrix, what the additional post would do.

Nothing is written and nothing is launched. The matrix is bound exactly as pyfs-matrix run binds it, so a key the plan refuses is refused here too; then every record of the manifest naming this matrix, one per point, is checked in this order: the row is active, it states ADDITIONAL_PPROC, no continuation replaced it, it is not in a queue, its saved simulation is on disk, that file hashes as the record says, it was not already extracted over those bytes with that artifact into files that still hash as recorded (the post's own test of an extraction, so an extraction whose file changed is made again), its build is the one the row names today, it did not average its surface in time, and the run's recorded script created the frames and declared the boundaries the row gives today. A point passing every check is READY with its extraction script built.

Parameters:

Name Type Description Default
matrix str or Path

The run matrix; its file stem selects the records.

required
workspace CampaignWorkspace

The campaign root holding runs.json and the input library.

required
default_fs_version str

The build a row whose FS_BUILD cell names none falls back to, as for pyfs-matrix run.

None
recipes mapping of str to str

A LEGACY row's RECIPE code to its reference, so a matrix mixing them binds.

None
fs_exe str or Path

The explicit executable override, as for pyfs-matrix run.

None

Returns:

Type Description
list of AdditionalPointPlan

One per recorded point, in manifest order.

Raises:

Type Description
CampaignConfigError

An extraction script that cannot be built (a distribution citing a frame the run did not create, a family the geometry refuses), before anything is launched; and every refusal of the plan of the matrix.

MatrixError

As pyfs-matrix plan raises it.

InputArtifactError

As pyfs-matrix plan raises it.

Warns:

Type Description
PyflightstreamWarning

Once per READY unsteady point: its extraction is one instant, the last.

pyflightstream.run.matrix.plan_matrix

plan_matrix(
    path: str | Path,
    workspace: CampaignWorkspace,
    *,
    warning_refusals: bool | None = None,
    name: str,
    recipes: Mapping[str, str],
    default_fs_version: str | None = None,
    fs_exe: str | Path | None = None,
    recipe_registry: dict[str, ScriptRecipe] | None = None,
    write_plan: bool = True,
    fs_version: str | None = None,
    name_from: str | None = None,
    ignore_missing_families: bool = True,
    cost: bool = False,
    accept_unregistered_build: bool = False,
    inflow_fft: bool = False,
    sims: Sequence[str] | None = None,
    points: Sequence[str] | None = None,
) -> CampaignPlan

Pre-flight a run matrix without executing anything.

Resolution (:func:pyflightstream.workspace.matrix.resolve_matrix) plus the campaign pre-flight (:func:pyflightstream.run.plan_campaign): every recipe resolves, every script builds in dry run, and points already in the manifest are marked ALREADY_RECORDED, exactly what run_matrix(..., resume=True) would skip.

A row naming a build with its own registry version is pre-flighted under that version, even when no executable is bound. The campaign default does not override the row's build.

Parameters:

Name Type Description Default
warning_refusals bool

Restore demoted refusals for this call; None uses the runtime option.

None
path str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix.

required
workspace str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix.

required
name str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix.

required
recipes str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix.

required
fs_exe str | Path

As in :func:pyflightstream.workspace.matrix.resolve_matrix.

required
default_fs_version str

FlightStream version for rows whose FS_BUILD column names no build; a DEFAULT rather than an override, which is what the name says (PFS-2009.08.01). Required in practice: it defaults to None only so the former spelling below can be refused by name.

None
fs_version None

The former name of default_fs_version: any other value is refused with a :class:MatrixError naming default_fs_version; the pyfs-matrix command line keeps --fs-version.

None
recipe_registry dict of str to ScriptRecipe

Named recipe registry (name to callable) consulted before treating a recipe reference as module:function, forwarded to the campaign pre-flight.

None
write_plan bool

Write the JSON summary as post/<matrix stem>/plan.json in the workspace (default True), the matrix's own folder so several matrices of one workspace keep their own (PFS-2031.04).

True
ignore_missing_families bool

Whether a pproc entry naming a family the opened mesh does not carry is left out (the default, True) or BLOCKS the point (False). Forwarded to :func:pyflightstream.workspace.matrix.resolve_matrix (PFS-2035.13); the command line spells it --ignore-missing-families.

True
sims sequence of str

Plan only these simulations, or these points of them (FR-326), as :func:run_matrix runs them; the matrix file is not written.

None
points sequence of str

Plan only these simulations, or these points of them (FR-326), as :func:run_matrix runs them; the matrix file is not written.

None
inflow_fft bool

For every quasi-steady WHEEL point in a custom inflow, read the inflow's harmonic content as ONE BLADE meets it over a revolution (:func:pyflightstream.cases.workflows.qsteady_inflow_fft): per station n95 and k_eff = n95 k_1P; per point k_eff min, max, mean and the per cent of the span above 0.1, n_max and the suggested PASSAGE_POSITIONS >= n_max / N + 1, WARNED when the row states fewer. With it the reduced-frequency warning reads k_eff. The command line spells it --inflow-fft.

False
name_from str

Where the campaign name came from, option or directory, recorded in the plan and the run records; None when the caller does not say.

None
cost bool

Also compute the cost table of every point (FR-82) into the plan's costs.

False
accept_unregistered_build bool

Run on an installed build other than the one registered for the version a row names instead of refusing it; the run warns and every record says the flag was used.

False

Returns:

Type Description
CampaignPlan

One status per matrix point; inspect blocked before running, or print summary().

Raises:

Type Description
MatrixError

Layout or build-selection problems, no default version given under either spelling, or a default that strips to empty. The last names every active row whose FS_BUILD cell strips to empty too, by row number and POL, and is raised before the matrix is bound, so no campaign is built and no executable is resolved (PFS-2009.08.03).

InputArtifactError

A REF, SET or ENTRY code, or a GEOMETRY stem, that the input library cannot resolve. An OBJ with no sidecar whose groups are not read, naming the line (G30): an OBJ with none is otherwise given one, written from its groups, when the matrix is bound (:func:pyflightstream.workspace.matrix.resolve_matrix).

Warns:

Type Description
PyflightstreamWarning

Naming every LEGACY row whose OUTPUTS declare no .fsm, so no final saved simulation of it is collected or hashed. And naming every unsteady row stating ADDITIONAL_PPROC, whose additional post extracts one instant, the last, and not the run's history (G12, RPT-062). And naming both lists when an OBJ's sidecar lists other boundaries than its groups make (G30). None blocks anything.

Examples:

>>> from pyflightstream.run.matrix import plan_matrix
>>> from pyflightstream.workspace import CampaignWorkspace
>>> plan = plan_matrix(
...     "matrix.fs",
...     CampaignWorkspace("campaign"),
...     name="wing_steady",
...     default_fs_version="26.120",
...     recipes={"003": "recipes.steady_polar:build"},
... )
>>> print(plan.summary())

pyflightstream.run.matrix.record_additional_extraction

record_additional_extraction(
    workspace: CampaignWorkspace,
    base: Mapping[str, object],
    *,
    status: ExtractionStatus,
    error: str | None,
    original: Path,
    outputs: list[str] | None = None,
) -> AdditionalRecord

Hash the original again, then write the record; an original that moved fails it.

Parameters:

Name Type Description Default
workspace CampaignWorkspace

The workspace whose manifest of additional records is appended to.

required
base mapping of str to object

The record's fields so far, with the sim_id and the original's fsm_sha256 before the extraction.

required
status ExtractionStatus

The extraction's status; FAILED_EXECUTION when the original moved.

required
error str or None

What went wrong, if anything.

required
original Path

The original saved simulation, hashed again.

required
outputs list of str

The files the extraction wrote, in the simulation folder; each is hashed into the record.

None

Returns:

Type Description
AdditionalRecord

The record, appended to the workspace.

pyflightstream.run.matrix.run_additional_post

run_additional_post(
    matrix: str | Path,
    workspace: CampaignWorkspace,
    *,
    default_fs_version: str | None = None,
    recipes: Mapping[str, str] | None = None,
    fs_exe: str | Path | None = None,
    executor: Executor | None = None,
    local: bool = False,
    hidden: bool | None = None,
) -> tuple[
    list[AdditionalPointPlan], list[AdditionalRecord]
]

Extract every READY point's additional pproc from its saved simulation, with no solve.

The plan first (:func:plan_additional_post), so every script is built before the first launch and a refusal costs nothing. Then, per READY point, ONE launch: anything already in the extraction's folder moves to its archive/<stamp>/ (nothing is deleted); the saved simulation is COPIED there and the copy must hash as the record says; the script is written under scripts/additional/<pid>/ and run with the extraction's folder as the working directory; every declared output must exist and is hashed; the copy is removed; the ORIGINAL is hashed again, and an original that moved fails the extraction loudly. One record per launch goes to additional.json; runs.json is never opened for writing.

Parameters:

Name Type Description Default
matrix str | Path

As :func:plan_additional_post.

required
workspace str | Path

As :func:plan_additional_post.

required
default_fs_version str | Path

As :func:plan_additional_post.

required
recipes str | Path

As :func:plan_additional_post.

required
fs_exe str | Path

As :func:plan_additional_post.

required
executor Executor

A caller's executor, which answers for every build; by default the one pyfs-matrix run would build for this matrix.

None
local bool

Keep the extraction on this machine, as pyfs-matrix run --local.

False
hidden bool or None

Windowless solver runs; None lets the matrix's HIDDEN column decide.

None

Returns:

Type Description
tuple of (list of AdditionalPointPlan, list of AdditionalRecord)

The plan of every recorded point and the record of every launch.

Raises:

Type Description
ExecutorConfigurationError

Where local=True is given beside an executor that submits to a scheduler: the extraction cannot both stay on this machine and be submitted, so it is refused before anything is written. A scheduler executor without local=True submits the extraction, and :func:~pyflightstream.run.collect.collect_once completes it.

CampaignConfigError

As :func:plan_additional_post.