Skip to content

pyflightstream.run.cli (stable)

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

The pyfs-matrix command line.

Pipeline role: drives the run matrix as a first-class interface of the file-managed modality from a terminal. The matrix is the campaign declaration; campaign-file conversion is refused. pyfs-matrix plan binds the matrix codes to the workspace input library and pre-flights every point without executing anything; pyfs-matrix run takes the same matrix all the way to manifest records and products.

The assessor is :class:pyflightstream.run.LoadsAssessor; no flag selects another one. --workflow CODE=NAME names a run type from the package's table (:mod:pyflightstream.cases.workflows), so a study built from those types needs no Python (PFS-2025.09).

--recipe CODE=REFERENCE still points at a function of your own on plan and run; what it may not do is name the same code a --workflow names, which is refused before anything is read.

The command-line entry point belongs to the run layer because it binds planning and execution.

The console entry point is pyfs-matrix (FR-44). Plan's human output uses titled blocks; its machine-readable outputs are exit codes and plan.json.

The dispatcher of every pyfs-matrix subcommand, each command's logic beside it. The argument parser is :mod:pyflightstream.run._cli_parsers (AD-14, built by family (AD-18)) and the console printing of plan and storage is :mod:pyflightstream.run._cli_print; what stays is the commands themselves, which share the workspace, matrix and records helpers.

Used in the guides

pyflightstream.run.cli.CampaignWorkspace

CampaignWorkspace(
    root: str | Path, naming: NamingTemplate | None = None
)

The managed folder layout of one campaign root.

Parameters:

Name Type Description Default
root str or Path

User-chosen campaign root; everything below it is managed by this class and never hand-built.

required
naming NamingTemplate

Output-only naming template for generated scripts, rendered export names, and archive names; the default reproduces the historical names ({point} stems, sim_<sim_id> zips). Identity always stays in the manifest, never in a name.

None

Attributes:

Name Type Description
root Path

The campaign root, ABSOLUTE. A relative root is resolved once, here, against the working directory of the process that built the workspace; see the constructor's own note for why that is a correctness property rather than a convenience.

naming NamingTemplate

The active naming template.

manifest_path property

manifest_path: Path

Location of the authoritative manifest, runs.json.

additional_path property

additional_path: Path

Location of the extraction manifest of the additional post, additional.json.

inputs_dir property

inputs_dir: Path

Root of the input-artifact library, inputs/.

init classmethod

init(
    root: str | Path, naming: NamingTemplate | None = None
) -> CampaignWorkspace

Create the full campaign tree under root, idempotently.

Creates the input-artifact library skeleton (one inputs/<kind> folder for each of geometries, references, setups, pproc, profiles, freestreams, calibrations, hpc, fsi, matrices and management), sims/, post/, and archive/; existing folders and files are kept untouched, so re-running init on a live campaign root is safe. When no build registry exists yet, a comment-only inputs/executables.toml template is written showing the entry shape.

Parameters:

Name Type Description Default
root str or Path

Campaign root to create or complete.

required
naming NamingTemplate

Naming template of the returned workspace.

None

Returns:

Type Description
CampaignWorkspace

The workspace over the created tree.

Raises:

Type Description
InputArtifactError

If the library already holds two files answering to one geometry or profile id. The creation contract is untouched: every folder and the registry template are written first, and only the RETURN becomes a refusal, so re-running init on a campaign that has grown an ambiguity still completes the tree and then says what is wrong with it (:func:check_unique_stems).

open classmethod

open(
    root: str | Path, naming: NamingTemplate | None = None
) -> CampaignWorkspace

Open an existing campaign root, checking what it already holds.

The validating constructor. CampaignWorkspace(root) READS NOTHING OF THE CAMPAIGN, refuses nothing and raises nothing, so a campaign can be described before its tree exists; this one asks the questions that are worth asking once, when the library opens, rather than when a single id happens to resolve.

The constructor normalises the root with :meth:pathlib.Path.resolve, which consults the working directory and the filesystem without reading campaign contents.

Parameters:

Name Type Description Default
root str or Path

Existing campaign root.

required
naming NamingTemplate

Naming template of the returned workspace.

None

Returns:

Type Description
CampaignWorkspace

The workspace over that root.

Raises:

Type Description
InputArtifactError

If two files under inputs/geometries/ or inputs/profiles/ answer to one id (:func:check_unique_stems).

Examples:

>>> from pyflightstream.workspace import CampaignWorkspace
>>> workspace = CampaignWorkspace.open("campaign")

resolve_reference

resolve_reference(artifact_id: str) -> ReferenceArtifact

Load the reference-data artifact one id names.

See :func:pyflightstream.workspace.inputs.resolve_reference; the id is the file name stem under inputs/references/, and a miss lists the available ids.

resolve_setup

resolve_setup(artifact_id: str) -> SetupArtifact

Load the solver-setup preset one id names.

See :func:pyflightstream.workspace.inputs.resolve_setup; the raw settings table is kept verbatim for the future formal solver-setup model.

resolve_pproc

resolve_pproc(artifact_id: str) -> PprocArtifact

Load the post-processing artifact one id names.

See :func:pyflightstream.workspace.inputs.resolve_pproc; group members are boundary labels or indices, stored verbatim.

expand_group

expand_group(
    artifact_id: str,
    name: str,
    *,
    boundaries: Mapping[str, int] | None = None,
) -> dict[str, int]

Expand one named boundary group into its per-member names.

The group Blade becomes Blade1 through BladeN over the members' 1-based positions. See :func:expand_group, which this loads the artifact for.

Parameters:

Name Type Description Default
artifact_id str

File name stem under inputs/pproc/.

required
name str

Group to expand, and the stem of the generated names.

required
boundaries mapping of str to int

Boundary label to 1-based index; members written as names resolve through it.

None

Returns:

Type Description
dict of str to int

{name}1 to {name}N mapped to boundary indices.

Raises:

Type Description
InputArtifactError

Unknown artifact or group, or members that are labels with no inventory.

reference_points

reference_points() -> dict[str, PointXyz]

Read the named reference points this campaign declares.

The points live in inputs/reference_points.toml, one TOML table per name, and the user writes them once: ARP for the airframe reference point, ERP for the rotor one with a single propulsor, ERP1 through ERPn with more. Nothing emitted to the solver takes a pivot, so a named point becomes a local coordinate system at those coordinates, which is why the declaration is the authority and not a downstream guess (PFS-2025.15).

Returns:

Type Description
dict of str to PointXyz

Declared points keyed by name, in declaration order. Empty when the campaign declares no points, which is the ordinary case for a study that needs none.

Raises:

Type Description
InputArtifactError

If the file is not valid TOML, does not validate as coordinates, or declares names outside the convention (:func:check_reference_point_names).

Examples:

>>> from pyflightstream.workspace import CampaignWorkspace
>>> workspace = CampaignWorkspace("campaign")
>>> workspace.reference_points()
{'ARP': PointXyz(x_m=1.5, y_m=0.0, z_m=0.25)}

reference_point

reference_point(name: str) -> PointXyz

Resolve one named reference point by name.

Parameters:

Name Type Description Default
name str

Point name, for example "ARP" or "ERP2".

required

Returns:

Type Description
PointXyz

Its coordinates in the simulation geometry frame, m.

Raises:

Type Description
InputArtifactError

If the campaign declares no reference points at all, or declares none by that name; the message lists the ones it does declare, because a point the workspace never defined cannot be turned into a coordinate system.

engine_point

engine_point(name: str) -> PointXyz

Refuse the spelling of :meth:rotor_point, naming it.

The retirement registry supplies a refusal naming rotor_point so callers receive the replacement instead of a bare missing-attribute error.

Raises:

Type Description
RetiredAttributeError

Always. The message names :meth:rotor_point. It is an AttributeError, so the obvious reading still catches it, AND a :class:~pyflightstream.exceptions.PyflightstreamError, so a caller who wraps workspace work in the one category this package documents gets the sentence rather than a traceback.

rotor_point

rotor_point(name: str) -> PointXyz

Resolve a declared reference point that a rotor may turn about.

PFS-2029.11.02, the design decision recorded in the plan: a point's KIND is stated, kind = "rotor", or left to the convention, where ERP and ERPn are rotors and ARP is the airframe; a motion on a point that is not a rotor is refused naming the point and its kind, so a rotor turning about the airframe reference point is a decision the file shows and never a side effect of a name.

Raises:

Type Description
InputArtifactError

The point is not declared (as :meth:reference_point), or it is declared and is not a rotor point.

resolve_geometry

resolve_geometry(artifact_id: str) -> Path

Resolve the staged geometry file one id (file stem) names.

See :func:pyflightstream.workspace.inputs.resolve_geometry.

resolve_profile

resolve_profile(artifact_id: str) -> Path

Resolve the input profile file one id (file stem) names.

See :func:pyflightstream.workspace.inputs.resolve_profile.

resolve_executable

resolve_executable(
    build_id: str, override: str | Path | None = None
) -> Path

Resolve the FlightStream executable of one build id.

Registry mode reads inputs/executables.toml; an explicit override path bypasses the registry and is the only way to run an unregistered build. See :func:pyflightstream.workspace.inputs.resolve_executable.

Returns the PATH alone, which is what it has always returned and what most callers want. Use :meth:resolve_build where the version the registry declares for the build matters too.

resolve_build

resolve_build(
    build_id: str, override: str | Path | None = None
) -> RegisteredBuild

Resolve the executable AND the declared version of one build id.

The sibling of :meth:resolve_executable, and the one a caller wants when a run matrix sends different rows to different builds: a registry entry written as a table declares the version that build's scripts are emitted under, and a bare path entry declares none.

Parameters:

Name Type Description Default
build_id str

Build identifier key of the registry.

required
override str or Path

Explicit executable path bypassing the registry. It declares no version, exactly as it declares no registry entry.

None

Returns:

Type Description
RegisteredBuild

The path, and the declared version or None.

See Also

pyflightstream.workspace.inputs.resolve_build : the free function this delegates to, which carries the full refusal rules.

plan_dir

plan_dir(matrix_stem: str | None) -> Path

Where plan.json lands: post/<matrix stem>/, or the root without a matrix.

sweep_dir

sweep_dir(matrix_stem: str | None) -> Path

Where the sweep tables land: post/<matrix stem>/, or post/ without one.

products_dir

products_dir(matrix_stem: str | None) -> Path

Where the products and products.json land.

post/<matrix stem>/ for a matrix, post/products/ without one.

The matrix-less fallback is the historical products folder.

reports_root

reports_root(matrix_stem: str | None) -> Path

Return the folder whose reports/ receives a post's measurement reports.

The products folder (:meth:products_dir): post/<matrix>/reports/. A post of other records (:class:pyflightstream.run.records.ManifestWorkspace) names its own products folder, so its reports sit apart too.

sim_dir

sim_dir(sim_id: str) -> Path

Return the managed folder of one simulation.

Parameters:

Name Type Description Default
sim_id str

Simulation identity; letters, digits, underscore, and hyphen only, so the derived folder name is stable and portable (NFR-10).

required

create_sim

create_sim(sim_id: str) -> Path

Create the managed subfolders of one simulation and return its path.

Creates inputs/, scripts/ and datapoints/; existing folders are kept, so the call is idempotent. Existing legacy parsed/ (PFS-2032.01), outputs/ and raw/ (FR-92) folders are retained but not created.

stage_inputs

stage_inputs(
    sim_id: str, sources: Sequence[str | Path]
) -> dict[str, str]

Stage input files under inputs/ and record their hashes.

Staging happens before execution so the manifest can tie the run to the exact input content (NFR-07).

THROUGH A LINK, NOT A COPY (PFS-2029.17, the first sentence of item #6). in legacy releases every point carried a byte copy of the geometry it opened, and production meshes are the size that sends every .fsm to cloud storage rather than to git. When every source sits in the workspace's own geometry library, sims/<sim>/inputs is made a directory junction on Windows and a symbolic link elsewhere, pointing at that library, so the staged path resolves to the one file on disk and the hash recorded is that file's. A filesystem that refuses the link, a source outside the library, or an inputs folder that already holds copies from an earlier release each fall back to a copy, and :meth:staged_as says which was made and why, because a junction is not a copy and a scan that crosses one double-counts; the run record carries the answer.

AT THE GEOMETRY'S OWN FOLDER WHEN IT HAS ONE (PFS-2032.04). A library laid out one folder per geometry (inputs/geometries/30_WB/30_WB.fsm) is linked at that folder, so the point's inputs show that geometry's files, its boundary inventory beside it, and never the whole library; a flat library is linked as before. A link left by an earlier staging that points elsewhere, the whole library after a migration for instance, is replaced rather than kept.

Parameters:

Name Type Description Default
sim_id str

Target simulation.

required
sources sequence of str or Path

Files to stage; each must exist.

required

Returns:

Type Description
dict of str to str

sha256 per staged file name, ready for :attr:RunRecord.inputs_sha256.

staging_would_change

staging_would_change(
    sim_id: str, sources: Sequence[str | Path]
) -> str | None

Say what staging sources would change in a simulation's inputs, or None.

A dry run of :meth:stage_inputs that writes nothing, for a simulation with a point still in a scheduler's queue: that job opens what the inputs folder presents when it starts, so staging may leave it exactly as it is and nothing else. A folder that links to the library keeps its target only when the sources sit in that same folder; a folder of copies is left alone only when every source already has its bytes there. Anything else (a link retargeted, removed or made, a copy with other bytes) is named.

staged_as

staged_as(sim_id: str) -> tuple[str | None, str | None]

Say how one simulation's inputs were staged: link or copy, and why.

Returns (None, None) for a simulation with nothing staged. A simulation this object did not stage is read off the disk, where a link is a link and a folder with files is a copy whose reason was not kept.

recorded_inventory

recorded_inventory(
    record: RunRecord,
) -> tuple[str, ...] | None

Return the boundary names of the geometry one record's run opened, or None.

A record written states them (:attr:RunRecord.inventory) and they are returned as written, with nothing hashed. An older record states none, and they are read from the mesh block of the file whose sha256 the record carries in inputs_sha256 (R04): the simulation's own staged copy first, then the geometry library's file of that name, flat or in its own folder.

THE HASH, NEVER THE NAME, SAYS A FILE IS THE ONE THAT RAN. A geometry edited or deleted since the run recovers nothing, and neither does a file carrying no mesh block. The file is hashed on each call, before and after its names are read, and both digests must be the recorded one; nothing is remembered by path, size or time, which a replacement can keep. The <stem>.boundaries.toml sidecar is not read, because nothing hashed it; at run time the builder refused a sidecar that disagreed with the mesh block, so the block of the hash-matched file is the authority.

Parameters:

Name Type Description Default
record RunRecord

The run whose geometry is asked for.

required

Returns:

Type Description
tuple of str or None

The names in the solver's order, the name at position i being boundary i, or None where nothing carries them.

write_script

write_script(
    sim_id: str, name: str, text: str
) -> tuple[Path, str]

Write one generated script into scripts/ and hash it.

Parameters:

Name Type Description Default
sim_id str

Target simulation.

required
name str

Script file name, for example "a+02.0_b+00.0.txt".

required
text str

Rendered script text from the builder.

required

Returns:

Type Description
Path

Location of the written script.

str

sha256 of the written text, for :attr:RunRecord.script_sha256.

collect_outputs

collect_outputs(
    sim_id: str,
    produced: Sequence[str | Path],
    *,
    datapoint: PointName,
    ran_in_datapoint: bool = False,
) -> list[str]

Move declared solver outputs into the datapoint's folder (FR-92).

Parameters:

Name Type Description Default
sim_id str

Target simulation.

required
ran_in_datapoint bool

Accept a declared output that is ALREADY in this point's own folder and record it without moving it. For a job that RAN in that folder, which is a submitted point whose solver wrote its outputs where they are filed. Keyword-only and False by default, and the default is the guard: a caller who has not said the job ran there is refused a file sitting in a datapoint folder, because that file is otherwise a record an earlier run already collected.

False
datapoint PointName

THE POINT these outputs belong to, by its checked name (:class:~pyflightstream.workspace.naming.PointName), whose folder under datapoints/ this renders with :func:datapoint_dir_name. Required, with no default, because every collection this package makes is a datapoint's: each point's evidence alone in its own folder is what makes a swept row judgeable, and nothing downstream then has to work out which of several files belongs to which point.

A CHECKED NAME AND NOT A BARE STRING, deliberately. A string argument once accepted a tag with the DP- prefix forgotten, or remembered twice; the files then landed in a folder the assessor never looks in. A PointName refuses the prefix and an unportable token, and a bare str is refused by :func:datapoint_dir_name .

required
produced sequence of str or Path

Output files the run declared it would produce. Anywhere OUTSIDE this campaign root, which is where a solver working directory normally sits; inside the root, only in this simulation's own folder and not in one of its managed subdirectories. See Raises.

required

Returns:

Type Description
list of str

Collected names relative to the simulation folder ("datapoints/DP-<point>/<name>"), ready for :attr:RunRecord.outputs. A record written in legacy releases names "outputs/<name>" or "raw/<name>" and is read through unchanged, which is what keeps its point from being orphaned by a layout it predates.

Raises:

Type Description
MissingOutputsError

If a declared output does not exist, AFTER every declared output that does has been filed: its collected lists them and its message names only the missing ones. The campaign loop records the point FAILED_INCOMPLETE_OUTPUT with those outputs, never a silently shorter output set and never an empty one. in legacy releases this refused before anything moved, and one missing log left every other export of the point uncollected in the solver's working directory, under a record naming no output at all. The refusals below are still asked first, over the outputs that exist, and still move nothing.

WorkspaceError

If a declared output RESOLVES INSIDE this campaign root but outside this simulation's own folder, or inside one of that folder's managed subdirectories. Collection MOVES, so without this a run could take another run's collected evidence: naming sims/sim_OTHER/outputs/loads.txt as an output moved it into this simulation's outputs/, and both manifests then named a file only one of them had.

A source resolving OUTSIDE the root is still accepted, and that is deliberate rather than an oversight: it is the ordinary case, since the solver's working directory is not managed by this class.

NamingTemplateError if datapoint is not a :class:PointName, from :func:datapoint_dir_name.

If two declared outputs of one call would collect to the same name, or if a declared output's base name is already held in the destination folder from an earlier run. Both are FR-33e and neither takes an overwrite argument: the remedies are a per-point output name and an archived simulation.

THE SECOND ONE NARROWED and that is the fix for the swept row, not a relaxation: the destination is now one datapoint rather than the whole simulation, so re-running a point still refuses to overwrite its own evidence, while the NEXT point of the same sweep never meets the previous point's files at all.

Both are pre-scans (PFS-2038.06, GEO-039-F07). A refusal must leave sources and destinations untouched rather than moving some outputs before discovering a later collision.

Notes

An existing <stem>_wakes.vtk beside a declared surface VTK is collected and recorded with it. This solver-created companion is optional, so its absence never makes collection incomplete: the default selection of the VTK export writes it and -1 DISABLE does not (reports/RPT-074, 2026-09-25).

Collection MOVES rather than copies. Every refusal here exists because of that and a reader has had to infer it from the collision message until now.

output_digests

output_digests(
    sim_id: str, collected: Sequence[str]
) -> dict[str, str]

Return the sha256 of each collected output, keyed by its name.

:attr:RunRecord.outputs_sha256 carries these hashes so collected evidence can be checked for edits, truncation or replacement (PYFS-006).

Parameters:

Name Type Description Default
sim_id str

Simulation the outputs were collected into.

required
collected sequence of str

Names as :meth:collect_outputs returned them, relative to the simulation folder ("outputs/<name>", or "raw/<name>" on a record written in legacy releases).

required

Returns:

Type Description
dict of str to str

Hex sha256 keyed by the same relative name.

Raises:

Type Description
WorkspaceError

If a named output is not there to hash. Collection has just moved these files, so a miss here means something removed one in between, and hashing what remains would produce a record quieter than the truth.

read_raw_manifest

read_raw_manifest() -> list[dict]

Read runs.json as written, without validating or defaulting.

This is the manifest AS EVIDENCE: the fields each row actually carries, with nothing filled in. :meth:read_manifest is the typed view built from it, and :meth:append_record writes through this one so that reading a historical manifest cannot change it (REV010-014).

Returns:

Type Description
list of dict

One dict per row, in file order; empty when the manifest does not exist yet.

read_manifest

read_manifest() -> list[RunRecord]

Read and validate every record of runs.json.

Returns an empty list when the manifest does not exist yet. The typed view fills defaults for fields a row does not carry; use :meth:read_raw_manifest when the question is what the row actually asserts rather than how this version reads it.

Raises:

Type Description
WorkspaceError

When a waived_commands entry carries no source_version, naming the manifest and the stamp the row was written under (PFS-2012.03); or when a solver-setup snapshot marks a selection flag explicit with an empty selection, naming the manifest, the run and the flag (PFS-2012.01); or when a recorded surface averaging window has invalid bounds or missing provenance, naming the run and invalid fields.

append_record

append_record(record: RunRecord) -> None

Append one record to the manifest, atomically.

The manifest is rewritten through a temporary file and an atomic replace, so a crash never leaves it half-written; a duplicate run_id is rejected because the manifest is the run identity (PP-6).

Existing rows are carried across AS THEY WERE WRITTEN. REV010-014: do not re-serialize existing rows through validated models, which would add defaulted fields and a manifest_schema not recorded by their writer. Historical evidence is not this method's to edit; migrating a manifest is a separate, deliberate, auditable act.

Raises:

Type Description
WorkspaceError

If the run_id is already in the manifest, or if the record carries a waiver row that this version may not write: one whose source_version names no build, or one under any stamp but :data:MANIFEST_SCHEMA. Refused before anything is written, because the row would be one :meth:read_manifest refuses and nothing here migrates a manifest (PFS-2012.03).

read_additional

read_additional() -> list[AdditionalRecord]

Read every record of the extraction manifest, additional.json (G12).

Returns an empty list when no extraction has been recorded. Several records may share an extraction_id: the manifest is append-only and the latest record of an identity is the one that counts.

Returns:

Type Description
list of AdditionalRecord

One per recorded extraction, in the order they were written.

append_additional

append_additional(record: AdditionalRecord) -> None

Append one extraction record to additional.json, atomically (G12).

Under a lease of its own, never the lease of runs.json, and through a temporary file and an atomic replace, as :meth:append_record writes the manifest of runs. Existing records are carried across as they were written, and runs.json is not opened.

Parameters:

Name Type Description Default
record AdditionalRecord

The extraction to record.

required

changed_extraction_file

changed_extraction_file(
    record: AdditionalRecord,
) -> str | None

Say which file of one extraction is gone or changed, or None while all are (G12).

THE ONE PREDICATE of whether an extraction's files are still the ones it wrote, read by both halves of the additional post: an extraction is reused (ALREADY_EXTRACTED) only while this answers None, and the post writes its products only while this answers None. A file the post refuses is therefore one the next --additional-pproc extracts again, where a check of existence alone would call it done forever. Every file is hashed on each call against outputs_sha256; an extraction that recorded no file has nothing to vouch for it and answers too.

Parameters:

Name Type Description Default
record AdditionalRecord

The extraction whose files are asked for.

required

Returns:

Type Description
str or None

The sentence naming the first file gone or no longer hashing as recorded, or None when every one does.

supersede_records

supersede_records(
    run_ids: Sequence[str], *, stamp: datetime | None = None
) -> Path | None

Copy the manifest into archive/ and take the named rows out of it.

For a FORCED RE-RUN: a point whose matrix row was wrong keeps its identity when the correction does not change its name, so the recorded row has to leave before the point can run again. The copy is made FIRST and the write is atomic, so there is no instant at which the workspace holds neither the old manifest nor a whole one.

THE COPY GOES WHERE THIS PACKAGE ALREADY PUTS ONE. pyfs-matrix rename archives the manifest to archive/runs-<stamp>.json before rewriting it, and a second home for one artifact name is how a reader who knows the first never finds the second.

Parameters:

Name Type Description Default
run_ids sequence of str

The run identities to remove. One that the manifest does not hold is not an error here: the caller decides what an unmatched name means, and for a forced re-run it refuses before reaching this.

required
stamp datetime

The moment the copy is named for. Injected so a test does not race the clock; the default is now.

None

Returns:

Type Description
Path or None

Where the manifest was copied, or None when there is no manifest to copy, which is a workspace nothing has run in yet.

archive_datapoint

archive_datapoint(
    sim_id: str,
    datapoint: PointName,
    *,
    stamp: datetime | None = None,
) -> Path | None

Move a datapoint's collected outputs aside, under a day-and-hour stamp.

A continuation archives what it replaces into folders stamped with the day and the hour, the same structure post already uses, because there can be more than one restart. Two continuations of one point would collide in a flat folder, and the stamp orders them for free.

IT APPLIES PER DATAPOINT FOLDER, which every point has even under warm start: FR-95 shares the SCRIPT across a steady sweep and never the folder, so datapoints/DP-<tag>/ is a stable address whatever the run model is.

The datapoint folder stays where it is and its CONTENTS move into archive/<stamp>/ inside it. That keeps the address a reader already knows and makes the history a subfolder of it rather than a sibling nobody finds.

Returns:

Type Description
Path or None

Where the outputs were moved, or None where the datapoint folder does not exist or holds nothing to move. NOTHING IS NOT AN ERROR: a first run of a point has no previous outputs, and a continuation of one that was never collected is the ordinary case rather than a mistake.

complete_submitted_record

complete_submitted_record(record: RunRecord) -> None

Replace a SUBMITTED row with the completed run it became (FR-99).

THE ONE METHOD THAT REWRITES A ROW, and the narrowness is the whole design. :meth:append_record carries existing rows across AS THEY WERE WRITTEN because historical evidence is not this class's to edit; a manifest that any code may rewrite is a manifest whose rows are opinions.

A SUBMITTED row is the ONE deliberate exception, and it is an exception in a precise sense: it is not a finished record that a later reading disagrees with, it is a record that says in its own status that the run has not come back yet. Completing it is not editing evidence. It is the evidence ARRIVING.

So the refusal is on the existing row rather than on the new one: a row in any other status is a run that finished, and this refuses to touch it whatever the caller passes. That is what stops this method becoming the general-purpose rewrite that append_record's docstring exists to prevent.

Raises:

Type Description
WorkspaceError

When the manifest holds no row with that run_id, or when the row it holds is not SUBMITTED. Both name the run and the status found, because a collector pointed at the wrong workspace and a collector pointed at a finished run are different mistakes and the message has to tell them apart.

archive_sim

archive_sim(
    sim_id: str, campaign: str | None = None
) -> Path

Zip one recorded simulation into archive/ and remove its folder.

The zip name comes from the workspace naming template (default sim_<sim_id>.zip); like every generated name it is output only and never parsed back.

Parameters:

Name Type Description Default
sim_id str

Recorded simulation to archive.

required
campaign str

Campaign name, needed only when the archive template uses the {campaign} placeholder.

None

Returns:

Type Description
Path

Location of the written zip file.

Raises:

Type Description
WorkspaceError

If the manifest is missing, does not record sim_id, or the simulation folder does not exist: file management never destroys an unrecorded run. Also when the archive name is already taken, because writing it would replace one archived run with another and then delete the folder the first came from.

clean_sim

clean_sim(sim_id: str) -> None

Remove one recorded simulation folder without archiving it.

Raises:

Type Description
WorkspaceError

Same refusals as :meth:archive_sim.

pyflightstream.run.cli.LoadsAssessor

LoadsAssessor(
    loads_file: str | None = None,
    *,
    log_file: str | None = None,
    requested_version: str | FsVersion | None = None,
)

The standard solver-quality judgment, built on the run outputs.

Reads the collected loads spreadsheet and, when available, the exported solver log. Its judgments are CONVERGED, COMPLETED_MAX_ITER, MAX_ITER_REACHED, FAILED_DIVERGED and FAILED_INCOMPLETE_OUTPUT. Other execution and submission outcomes belong to the run orchestration; :class:pyflightstream.workspace.manifest.RunStatus defines the full set. The Notes below explain refusals to judge the collected evidence.

  • NaN or infinite Total coefficients: FAILED_DIVERGED.
  • A native log with consecutive frozen time steps: FAILED_DIVERGED.
  • With a log: the final velocity and pressure residuals against the run's convergence limit (FSM-26.120 p.200). A NaN or infinite residual in EITHER column is a divergence, judged before the two are combined: reducing them first cannot preserve the invalidity of one of them.
  • A steady run at its requested iteration limit with a final residual above the convergence limit is MAX_ITER_REACHED. The counter comes from the log or the loads footer; the footer alone cannot supply the residual verdict. Forced iterations and unsteady runs do not receive this status.
  • Without a log, steady mode: an iteration counter below the requested limit means the threshold stopped the solver (CONVERGED); reaching the limit means COMPLETED_MAX_ITER. Unless the run forced all iterations, which disables that threshold: an early stop is then a refusal, because the one mechanism that could have ended the loop legitimately was off (PYFS-008).
  • Without a log, unsteady mode: the time loop always runs to its prescribed end, so completion is recorded as COMPLETED_MAX_ITER. EXPORTING a log is what changes that; naming it is not required, because a collected file that parses as a residual history is found by content.

Parameters:

Name Type Description Default
loads_file str

Name of the loads spreadsheet among the collected outputs, by file name (any directory part of the declared name is dropped by collection). None, the default, finds the collected output that parses as a loads table, the same rule :func:pyflightstream.results.tables.parse_run_loads uses on the manifest: a swept case names its outputs per point (loads_{point}.txt), so no single literal could name them all, and the content is what identifies the file anyway.

None
log_file str

Name of the exported solver log (EXPORT_LOG). None, the default, finds the collected output that parses as a residual history, the same rule loads_file follows and for the same reason: a swept case names its outputs per point, so no single literal could name them all.

NAMING IT IS STRICTER, not weaker: a named file that was not collected is a refusal, while the default falls back to the iteration-count judgment when nothing parses. Name it when the run must not be judged without residuals.

None
requested_version str or FsVersion

Version the campaign requested; enables the FR-18 cross-check against the version printed in the loads footer.

None
Notes

A refusal to judge missing, unusable or mismatched evidence carries FAILED_INCOMPLETE_OUTPUT. It must not look like a judged result.

COMPLETED_MAX_ITER records an ended run without evidence of convergence, including an unsteady run reaching its prescribed end. MAX_ITER_REACHED records the steady limit and residual evidence described above (FR-434). Both are ended runs, not failures and not claims of convergence. CONVERGED is the threshold verdict; FAILED_DIVERGED records divergence evidence.

The refusals, in the order they are tested:

  1. The file named by loads_file is not among the collected outputs. The error lists what was collected, because the usual cause is a swept case whose recipe names its outputs per point.
  2. No loads_file was named and no single collected output reads as a loads table, either because none parses or because several do. Choosing one would be a guess about which point ran.
  3. The loads spreadsheet is unparseable or truncated.
  4. The export is evidence of a different operating point from the one the case requested, beyond tolerance (REV010-001).
  5. The loads footer prints a solver mode this package has not been taught (REV010-002).
  6. The file named by log_file is not among the collected outputs; or log_file was not named and SEVERAL collected outputs parse as a residual history, because choosing one would be a guess about which is this point's. Zero candidates is not a refusal: it is the iteration-count judgment, which is what every campaign that exports no log has always received.
  7. The solver log is present but no residual history can be read from it.
  8. Steady mode with all iterations forced, and the solver stopped early (PYFS-008), as described above.

Items 4 and 5 prevent success from being inferred from a valid export belonging to another case or from an unrecognised solver mode. Parsing alone cannot establish operating-point identity or choose the correct convergence rule.

Item 4 is also tested BEFORE divergence, deliberately. Divergence is a physical outcome, and attributing one to a case that never produced the file is a worse error than reporting that the evidence could not be matched to the case.

Examples:

The assessor is built once per campaign and handed to the loop, which calls it for each executed point; building it reads nothing:

>>> from pyflightstream.run import LoadsAssessor
>>> assess = LoadsAssessor(log_file="solver_log.txt")
>>> (assess.loads_file, assess.log_file, assess.requested_version)
(None, 'solver_log.txt', None)

pyflightstream.run.cli.PyflightstreamError

Bases: Exception

Base of every CATALOGUED exception this package defines (SRS FR-39).

Catch it instead of importing the leaf types one by one, or widening to ValueError. Read the word CATALOGUED before relying on it: a residual of bare standard-library raises survives in the package. Every site the guard's walk REACHES is named in the ratchet in tests/tier1_offline/test_exceptions_catalog.py, which is the single home of that list; the walk's own reach is stated in that same module (SRS FR-39 states only the one base), and at least one site sits outside it. Those escape this base.

The standard-library base of each catalogued class is kept as a second base, so except ValueError catches what it always did. That is the fallback for most of the residual and not for all of it: the residual is mostly ValueError and also holds TypeError and RuntimeError sites, and the ratchet names the type per site. A caller who needs to be exhaustive today catches PyflightstreamError and the standard-library bases together.

from pyflightstream.exceptions import PyflightstreamError from pyflightstream.versions import resolve try: ... resolve("25.3") ... except PyflightstreamError as error: ... print(type(error).name) UnknownVersionError

Every leaf also inherits its standard-library exception base: UnknownVersionError is a ValueError, WorkspaceError a RuntimeError, and OptionError a KeyError. Callers can catch either that specific standard-library category or the package base.

Not a parent of :class:~pyflightstream.results.VersionMismatchWarning, which is a warning rather than an error. FR-39 asks for a base of every raised EXCEPTION and for a catalog of every exception AND warning, and those are deliberately two different sets: a warning is delivered through :mod:warnings and selected by category, and calling it an Error would misname it for the one reader who matters, the one reading a traceback.

pyflightstream.run.cli.RunStatus

Bases: StrEnum

Terminal status of one executed campaign point (SAD Section 7).

Every executed point lands in exactly one of these; a silent skip is structurally impossible in the campaign loop.

Examples:

>>> from pyflightstream.workspace import RunStatus
>>> RunStatus("SUBMITTED") is RunStatus.SUBMITTED
True
>>> str(RunStatus.CONVERGED)
'CONVERGED'

pyflightstream.run.cli.main

main(argv: list[str] | None = None) -> int

Run pyfs-matrix; returns the process exit code.

Parameters:

Name Type Description Default
argv list of str

The command line without the program name; None reads sys.argv.

None

Returns:

Type Description
int

The process exit code: 0 on success, 2 for a refused argument or recipe, and the code the chosen subcommand returns otherwise.

pyflightstream.run.cli.matrix_stem

matrix_stem(text: str | Path) -> str

Return the matrix name a --matrix value stands for, removing only a final extension.

wing.v2.fs and wing.v2.toml are the matrix wing.v2, and the bare wing.v2 is itself: a dot inside the name is part of the name.

Parameters:

Name Type Description Default
text str or Path

A matrix path, a file name or a stem.

required

Returns:

Type Description
str

The name, without folder and without a final .fs or .toml.

Examples:

>>> matrix_stem("inputs/matrices/wing.v2.fs")
'wing.v2'
>>> matrix_stem("wing.v2")
'wing.v2'

pyflightstream.run.cli.option_context

option_context(*pairs: Any) -> Iterator[None]

Set options inside a with block, restoring them on exit.

Parameters:

Name Type Description Default
*pairs object

Alternating key and value arguments, pandas style: option_context("qa.probe_timeout_s", 10.0, ...).

()

Yields:

Type Description
None

Control returns to the with block with the options set; they are restored on exit.

Raises:

Type Description
OptionError

Unknown key or refused value, before anything is changed.

Examples:

>>> from pyflightstream.options import get_option, option_context
>>> previous = get_option("warning_refusals")
>>> with option_context("warning_refusals", True):
...     assert get_option("warning_refusals") is True
>>> get_option("warning_refusals") == previous
True

pyflightstream.run.cli.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(),
... )

pyflightstream.run.cli.sweep_table

sweep_table(
    workspace: _ManifestWorkspace,
    *,
    loads_file: str | None = None,
    require_loads: bool = True,
    matrix_stem: str | None = None,
) -> Table

Assemble the tidy table of a whole campaign sweep.

One row per manifest record, in manifest order: the run identity, sweep point, versions, and outcome of :func:run_table, joined with the Total coefficients of each run's loads spreadsheet resolved through :func:parse_run_loads. Runs without a loads spreadsheet (failed points) keep their identity row with NaN coefficients, so the sweep table always accounts for every executed point. Table.to_csv then writes the final csv; the table states its provenance in its own columns.

Parameters:

Name Type Description Default
workspace CampaignWorkspace

The managed campaign workspace, already constructed. A bare root path is NOT accepted, for the reason :func:parse_run_loads states: pass CampaignWorkspace(root).

required
loads_file str

Exact loads file name per run, forwarded to :func:parse_run_loads; needed when the recipes export more than one file that parses as a loads spreadsheet.

None
require_loads bool

Whether a sweep in which NO run yielded coefficients is an error. True by default, which is the historical behaviour and the right answer for a caller asking for a polar. Pass False where the table is being written as the record of what ran (PFS-2014.03): a campaign whose every point failed still has to leave a file a colleague can open, and raising here would leave nothing to write. The condition is warned about instead, and the identity rows are returned; per-record misses are already tolerated either way, as NaN coefficient rows. A record whose loads cannot be read for another reason (an output no longer on disk, an ambiguous, truncated or wrong-point spreadsheet) raises that error when True and, when False, keeps its NaN row and is warned about by run id.

True
matrix_stem str

The stem of one run matrix of the workspace; the table then holds the records that name it and no other's (PFS-2031.04). A record that names no matrix, written before the field existed or by a campaign authored in Python, is left out rather than counted in every matrix's table. None, the default, tabulates the whole manifest.

None

Returns:

Type Description
Table

The sweep table; sweep point axes are in their sweep units (alpha and beta in deg, advance_ratio dimensionless) and the coefficient columns follow each run's printed units, exposed in the force_units / moment_units columns. Every row also carries data_origin and reduction (PFS-2014.05), which is what lets a mixed steady and unsteady sweep be read without opening another file.

Raises:

Type Description
MalformedOutputError

When the manifest holds no records, or when workspace is a path rather than a constructed :class:~pyflightstream.workspace.CampaignWorkspace.

LoadsNotFoundError

When no successful run yields a coefficient table (which points at a wrong loads_file name) and require_loads is True.

Warns:

Type Description
UserWarning

In the same condition when require_loads is False, and once per record whose loads could not be read.

Examples:

>>> from pyflightstream.results import sweep_table
>>> from pyflightstream.workspace import CampaignWorkspace
>>> table = sweep_table(CampaignWorkspace("campaign"))
>>> table[["run_id", "alpha", "CL"]]

pyflightstream.run.cli.table

table(
    rows: Sequence[Sequence[str]], *, indent: str = "  "
) -> list[str]

Return rows as left-aligned columns, the first row being the heading.

Parameters:

Name Type Description Default
rows sequence of sequence of str

Rectangular rows of text, including the heading row.

required
indent str

Prefix of every output line.

' '

Returns:

Type Description
list of str

One padded line per row; an empty list for no rows.

Examples:

>>> from pyflightstream.run.cli import table
>>> table([["name", "value"], ["a", "1"]], indent="")[1].split()
['a', '1']

Advanced

pyflightstream.run.cli.CampaignConfigError

Bases: PyflightstreamError, ValueError

A campaign or case definition cannot be used as written.

A sweep point that cannot be tagged, a campaign file that does not load, a recipe that does not resolve to a callable or whose signature the loop cannot call. Distinct from :class:~pyflightstream.cases.matrix.MatrixError, which is about the pipe-delimited run-matrix format specifically.

Also inherits from ValueError.

pyflightstream.run.cli.CampaignErrors

CampaignErrors(
    failures: list[RunRecord],
    records: list[RunRecord] | None = None,
)

Bases: PyflightstreamError, RuntimeError

One or more campaign points failed; raised after the loop.

Every failed point is listed with its status and error text, and all points, failed or not, are already in the manifest: the exception reports, it never hides.

Attributes:

Name Type Description
failures list of RunRecord

The manifest records of the failed points.

records list of RunRecord

Every record the call wrote, failed or not, in the order it wrote them; the failures alone when the raiser did not pass them.

pyflightstream.run.cli.CampaignPlan dataclass

CampaignPlan(
    campaign: str,
    fs_version: str,
    points: list[PointPlan] = list(),
    campaign_name_from: str | None = None,
    plan_file: Path | None = None,
    build_groups: dict[str, list[str]] = dict(),
    costs: list[PlannedPointCost] = list(),
    guides: list[Path] = list(),
    setup_inspections: list[dict[str, object]] = list(),
    grouping: GroupingReceipt | None = None,
    planned_order: dict[str, list[str]] = dict(),
)

The pre-flight plan of one campaign: statuses per point, no execution.

Attributes:

Name Type Description
campaign str

Campaign name.

fs_version str

Canonical FlightStream version the scripts were validated against.

points list of PointPlan

One entry per campaign point, in campaign order.

plan_file Path or None

Where the JSON summary was written: post/<matrix>/plan.json for a campaign converted from a run matrix, plan.json in the campaign root otherwise (PFS-2031.04); None when writing was disabled.

build_groups dict of str to list of str

Which cases run on which solver installation, keyed by :attr:~pyflightstream.cases.SimCase.fs_build with the empty string standing for the campaign's own. Reported here because how many installations a study actually spans is usually a surprise, and the pre-flight is the one place it can be learned without spending a licensed seat (PFS-2009.09.01).

blocked property

blocked: list[PointPlan]

The points that cannot run as planned.

ready property

ready: list[PointPlan]

The points that built cleanly in dry run.

already_recorded property

already_recorded: list[PointPlan]

The points the manifest already holds (resume would skip them).

installation_label staticmethod

installation_label(key: str) -> str

Name one of :attr:build_groups the way a message should say it.

summary

summary() -> str

Return the one-paragraph human summary of the plan.

pyflightstream.run.cli.InputArtifactError

InputArtifactError(
    message: str,
    *,
    kind: str | None = None,
    artifact_id: str | None = None,
    available: tuple[str, ...] = (),
    where: dict | None = None,
)

Bases: PyflightstreamError, RuntimeError

An input artifact cannot be resolved or validated.

Raised when an id is unknown (the message lists the available ids of that kind), when an artifact file does not validate against its model, or when a geometry or profile id matches more than one staged file. Input mistakes must surface at resolution time, before any solver run consumes the artifact.

Import it from :mod:pyflightstream.workspace, which owns the input library it describes, or from :mod:pyflightstream.exceptions:

from pyflightstream.workspace import InputArtifactError

It is DEFINED here rather than there because two layers name it: the workspace layer raises it, and the layers that bind a run matrix to the input library catch it and re-raise with the row and the file they were resolving. Defining it in the workspace package made the lower one import upward, which is the deferred-import shape the layering guard refuses (OPS-2007.02.01). The public name is unchanged and so is the pair of bases, so except RuntimeError catches exactly what it always did.

Attributes:

Name Type Description
kind str or None

Artifact kind of the failed resolution ("reference", "setup", ...), when the refusal is a miss.

artifact_id str or None

The id that failed to resolve, when the refusal is a miss.

available tuple of str

Ids that would have resolved for the kind, so callers can offer choices without parsing the message. It is populated on a NOT-FOUND refusal and is EMPTY on a refusal about the id's own shape, which is about what the caller wrote rather than about what the library holds. The distinction is stated because an empty tuple would otherwise be read as an empty library; tests/tier1_offline/test_exceptions_catalog.py pins both branches.

where dict

Optional diagnostic locations: family names, zero-based mesh vertex indices in nodes, and mesh-coordinate triples in points.

pyflightstream.run.cli.InputValueError

Bases: PyflightstreamError, ValueError

A value given by the user cannot be used; the message names the cause and the remedy.

The family's home for a refusal that had been a bare ValueError and has no domain class of its own. ValueError stays a base, so except ValueError still catches it.

pyflightstream.run.cli.LIVE_LOG_COMMANDS module-attribute

LIVE_LOG_COMMANDS = (
    "sync",
    "restore",
    "free-space",
    "delete-sims",
    "collect",
    "post",
)

pyflightstream.run.cli.LoadsNotFoundError

Bases: PyflightstreamError, ValueError

No collected output of a run yields its loads spreadsheet.

Expected for failed points: a run that stopped before EXPORT_SOLVER_ANALYSIS_SPREADSHEET leaves no coefficient table behind, and :func:sweep_table turns this into a row without coefficient columns instead of dropping the run.

pyflightstream.run.cli.MATRIX_POINT_NAME module-attribute

MATRIX_POINT_NAME = '{polar}'

pyflightstream.run.cli.MalformedOutputError

Bases: PyflightstreamError, ValueError

An output file is present and whole but cannot be read as itself.

The sibling of :class:IncompleteOutputError, and deliberately a different type: incomplete means the solver stopped mid-write, this means the bytes are all there and do not describe what the file claims to be. A duplicated column, a second concatenated export, a fractional or negative count, and a token that is not a number all land here.

Also inherits from ValueError, so callers can catch either the package error base or the standard value-error base.

pyflightstream.run.cli.MatrixError

Bases: PyflightstreamError, ValueError

A run-matrix file does not match the verified layout.

The reader supports exactly the verified format (FR-10); a deviation means the file is not a run matrix or was edited beyond what the matrix workflow produces.

pyflightstream.run.cli.NamingTemplate

Bases: BaseModel

User-configurable output names for scripts, exports, and archives.

The template is output only: it decorates files for human reading, while run identity stays in the manifest. Configure it per workspace by passing it to :class:~pyflightstream.workspace.CampaignWorkspace.

Attributes:

Name Type Description
point_name str

Template of per-point file stems (generated scripts and rendered export names). Default "{point}" reproduces the historical script names, for example a+02.0_b+00.0.

archive_name str

Template of simulation archive stems; only {campaign} and {sim} apply (an archive spans every point of a simulation). Default "sim_{sim}" reproduces the historical zip names.

Examples:

>>> template = NamingTemplate()
>>> template.render_output("loads_{point}.txt", campaign="polar", sim="9001",
...                         point={"alpha": 2.0}, point_name="AL+020")
'loads_AL+020.txt'

render_point

render_point(
    *,
    campaign: str,
    sim: str,
    point: dict[str, float],
    mach: float | None = None,
    advance_ratio: float | None = None,
    name: str | None = None,
) -> str

Render the file stem of one sweep point.

Parameters:

Name Type Description Default
campaign str

Campaign name for {campaign}.

required
sim str

Case sim_id for {sim}.

required
point dict of str to float

Sweep point coordinates (alpha and beta in deg, advance_ratio dimensionless), as produced by :meth:pyflightstream.cases.SweepAxis.points; feeds {point} and the per-axis placeholders.

required
mach float

Free-stream Mach number of the case for {mach}; None when the case declares none. Where the sweep varies the Mach number the point carries its own under MACH, and that one is rendered: a placeholder describes the point being named.

None
advance_ratio float

The case's advance ratio for {advance_ratio} when the sweep does not vary it.

None
name str

The point's name (:func:pyflightstream.cases.point_name), for {point} and {polar}; a template naming either refuses without it.

None

Returns:

Type Description
str

The rendered stem, without extension.

render_output

render_output(
    name: str,
    *,
    campaign: str,
    sim: str,
    point: dict[str, float],
    mach: float | None = None,
    advance_ratio: float | None = None,
    stem: str | None = None,
    point_name: str | None = None,
) -> str

Render the placeholders inside one declared output name.

A name without placeholders passes through unchanged, which only a single-point case may declare: with placeholders (for example "loads_{point}.txt") each point exports under a unique name, and the campaign loop blocks a case whose points would render the same name, because a later point of the same simulation would otherwise overwrite an earlier export.

Parameters:

Name Type Description Default
name str

Declared output name, possibly holding placeholders.

required
campaign str

Same meaning as in :meth:render_point.

required
sim str

Same meaning as in :meth:render_point.

required
point str

Same meaning as in :meth:render_point.

required
mach str

Same meaning as in :meth:render_point.

required
stem str

The point's rendered stem, for {name}.

None
point_name str

The point's name, for {point} and {polar}.

None
advance_ratio float

The case's advance ratio for {advance_ratio} when the sweep does not vary it.

None

Returns:

Type Description
str

The rendered output name.

render_archive

render_archive(
    *, sim: str, campaign: str | None = None
) -> str

Render the archive file stem of one simulation.

Parameters:

Name Type Description Default
sim str

The sim_id for {sim}.

required
campaign str

Campaign name for {campaign}; required only when the archive template uses that placeholder (the workspace does not know the campaign name on its own).

None

Returns:

Type Description
str

The rendered stem; the workspace appends .zip.

pyflightstream.run.cli.NamingTemplateError

Bases: PyflightstreamError, ValueError

A naming template cannot be validated or rendered.

Raised when a template names an unknown placeholder, when a placeholder has no value on the current point (for example {mach} on a case without a Mach number), or when a rendered name would not be a portable file name. The message lists what is available, because a naming mistake must surface before any solver run, not as a cryptic OS error mid-campaign.

pyflightstream.run.cli.PyflightstreamWarning

Bases: UserWarning

The category that says a warning came from THIS package.

It exists for one job: the executable-examples run promotes warnings to errors so a stale example fails CI, and promoting every warning means a dependency's next release turns that build red for something nobody here can fix. Naming one category scopes the promotion to what this repository is responsible for.

UserWarning is kept as the base, so -W error::UserWarning, simplefilter("ignore", UserWarning) and every other selection a caller already had keep catching what they caught. The addition is widening, exactly as :class:PyflightstreamError was.

NOT a subclass of :class:PyflightstreamError, and the split is the same one that requirement FR-39 draws: the base is for every catalogued EXCEPTION, and a warning is delivered through :mod:warnings and selected by category rather than raised and caught. Calling it an Error would misname it for the reader of a traceback.

Import the category from :mod:pyflightstream.exceptions, the public exception and warning catalog. The package's warning categories derive from this class, so filtering it selects package warnings without selecting unrelated dependency warnings.

Examples:

>>> import warnings
>>> from pyflightstream.exceptions import PyflightstreamWarning
>>> with warnings.catch_warnings(record=True) as caught:
...     warnings.simplefilter("always")
...     warnings.warn("the campaign declares no outputs", PyflightstreamWarning)
>>> caught[0].category.__name__
'PyflightstreamWarning'
>>> issubclass(PyflightstreamWarning, UserWarning)
True

pyflightstream.run.cli.QUERY_COMMANDS module-attribute

QUERY_COMMANDS = (
    "status",
    "show",
    "log",
    "trace",
    "history",
    "diff",
    "support",
)

pyflightstream.run.cli.WorkflowCoverageError

Bases: PyflightstreamError, RuntimeError

A workflow was asked for a solver build it does not cover.

Raised BEFORE the first emission and before any executor is constructed, so nothing is spent and no half-built script exists (PFS-2025.18). The message names the build received, the builds the workflow covers in release order, and the commands whose absence forced the range.

RuntimeError is the standard-library base rather than ValueError, because this refusal is about the ENVIRONMENT the script would run in and not about an argument the caller passed: every argument may be perfectly well formed and the answer still be that this build cannot run this study.

There is deliberately NO override route. The escape already exists one level up, in :meth:pyflightstream.script.Script.allow_broken, which is a recorded waiver naming a reason; a second, quieter one here would be a way past the guard that leaves no record.

pyflightstream.run.cli.WorkspaceError

Bases: PyflightstreamError, RuntimeError

A file-management operation was refused or impossible.

The refusals protect run evidence: archiving or cleaning without a manifest record would destroy a run the manifest cannot account for, and collection of a declared output that the solver never produced points at an incomplete run.

pyflightstream.run.cli.blocks

blocks(
    sections: Iterable[tuple[str, Sequence[str]]],
) -> str

Return titled blocks separated by one blank line, leaving out every empty one.

Each section is (title, lines); the lines are printed as given, so the caller indents them.

Parameters:

Name Type Description Default
sections iterable of (str, sequence of str)

Each title and its already formatted content lines.

required

Returns:

Type Description
str

The nonempty sections joined with one blank line.

pyflightstream.run.cli.cli_entrypoint

cli_entrypoint(function: Callable[P, R]) -> Callable[P, R]

Report the actual CLI outcome once, without changing CLI semantics.

Parameters:

Name Type Description Default
function Callable[P, R]

Console entry point whose return value and exceptions are preserved.

required

Returns:

Type Description
Callable[P, R]

Wrapped entry point with scoped console reporting.

Examples:

>>> def main(argv=None):
...     return 0
>>> callable(cli_entrypoint(main))
True

pyflightstream.run.cli.cmd_mark_converged

cmd_mark_converged(args: Namespace) -> int

Run pyfs-workspace mark-converged and print what it did, or would do (FR-414).

Parameters:

Name Type Description Default
args Namespace

Parsed workspace, simulation ids, reason, point filter and apply flag.

required

Returns:

Type Description
int

0 for a clean preview or application; 2 for a refusal or read/write error.

pyflightstream.run.cli.cmd_search_log_batch

cmd_search_log_batch(args: Namespace) -> int

Run pyfs-workspace search-log-batch and print what it did, or would do.

Parameters:

Name Type Description Default
args Namespace

Parsed workspace, simulation ids, apply flag and master-log selection.

required

Returns:

Type Description
int

0 after a completed preview or write; 2 for a refusal or read/write error.

pyflightstream.run.cli.collect_interval_error

collect_interval_error(value: float | None) -> str | None

Return the refusal for an invalid settle interval from arguments or settings.

Parameters:

Name Type Description Default
value float or None

Requested collection settle interval in seconds.

required

Returns:

Type Description
str or None

Refusal text for a nonpositive or nonfinite interval; None otherwise.

pyflightstream.run.cli.command_console

command_console(
    program: str,
    command: str,
    *,
    what: str,
    workspace: str | Path | None = None,
    live_log: bool = False,
    header: bool = False,
    hold: bool = True,
) -> Iterator[None]

Open the console of one command (FR-200 to FR-204).

Prints the titled opening block on stderr: <program> <command>, then what the command is for (what), the workspace and, with live_log, where the live log is written. A command that prints its own header (header, the plan summary) has the block said only when some other line would come first. With hold every warning is held and printed as one block at the end, a refusal and an interruption included. With live_log in a campaign workspace, every line the console shows, standard output included, is written to logs/<command>-<stamp>.log as it is said. At quiet level ordinary stdout is held for the summary; requested data uses :func:say_data to remain visible at every level.

Only inside :func:command_terminal, and once: a nested command runs in the console already open.

Parameters:

Name Type Description Default
program str

Program name in the opening title.

required
command str

Command name in the title and optional live-log filename.

required
what str

Description of the command work.

required
workspace str or Path or None

Campaign root shown in the header and used for a live log.

None
live_log bool

Record console output in the workspace logs folder.

False
header bool

Defer the opening block until another line would be printed.

False
hold bool

Collect warnings and print them together when the command ends.

True

Yields:

Type Description
None

The console context, restoring the original streams on exit.

pyflightstream.run.cli.command_help

command_help(
    parser: ArgumentParser, names: Sequence[str]
) -> str

Return the one-line help a parser gives the (nested) command names.

The line each add_parser(..., help=...) states, which --help lists; an alias gets its command's line; the command's description where it states no help; and the empty string where it states neither.

Parameters:

Name Type Description Default
parser ArgumentParser

Root parser containing the command.

required
names sequence of str

Nested command names, from the root outward.

required

Returns:

Type Description
str

The deepest resolved command help, with whitespace collapsed.

pyflightstream.run.cli.continuation_block

continuation_block(points: Iterable[object]) -> list[str]

Return the plan's block of what RESTART does on each point that states it.

Parameters:

Name Type Description Default
points iterable of object

Plan entries exposing continuation and run_id attributes.

required

Returns:

Type Description
list of str

Run ids and indented descriptions for entries with a continuation.

pyflightstream.run.cli.derive_thin_blade

derive_thin_blade(
    geometry: str | Path,
    *,
    root_offset: float,
    overwrite: bool = False,
    boundary: str | None = None,
) -> ThinBlade

Derive the thin blade of a blade mesh and write it beside the source (FR-330).

Parameters:

Name Type Description Default
geometry str or Path

The blade mesh: a saved simulation (.fsm) or an OBJ holding one blade alone.

required
root_offset float

How far the root is moved outward along the span, in the mesh's own length unit, so the thin blade does not cross the spinner. Required, positive and shorter than the blade.

required
overwrite bool

Rewrite an existing thin blade and its sidecar. Without it an existing one is refused.

False
boundary str

The name of the one boundary (OBJ group) that is the blade, for a file that holds the blade with a spinner, a nacelle or other bodies (FR-636). Only its faces are read, and the output is written under the name :func:thin_blade_path gives for it. Without it a file holding more than one boundary is refused.

None

Returns:

Type Description
ThinBlade

The paths written and the frame and stations used.

Raises:

Type Description
InputArtifactError

Naming the source and the reason, with nothing written: a file that is not a saved simulation or an OBJ or cannot be read, one holding more than one boundary, an OBJ whose sidecar states a CAD or CCS conversion, a root offset that is not a positive length shorter than the blade, a blade whose root cannot be told from its tip, a section that is not one closed loop (open, or one of several) or whose two sides cannot be separated, and an existing output without overwrite.

pyflightstream.run.cli.failure_alias_lines

failure_alias_lines(
    failures: Sequence[Any],
    rows: list[dict[str, Any]],
    root: str | Path | None = None,
) -> list[str]

Name the run id alias beside each failed run id (FR-795).

Read as every other reader of an alias reads it (:func:planned_in_workspace), so a failed point recorded out of its sweep order is named by the alias that --points, show and mark-failed resolve back to it.

Parameters:

Name Type Description Default
failures sequence

The failed records (each with sim_id and run_id).

required
rows list of dict

The manifest rows, as CampaignWorkspace.read_raw_manifest returns them.

required
root str or Path

The workspace root, whose plan.json files give the sweep order; without it the records alone are read, in the order they were recorded.

None

Returns:

Type Description
list of str

" alias <alias> = <run id>" for each failure that has an alias.

pyflightstream.run.cli.format_cost_table

format_cost_table(costs: list[PlannedPointCost]) -> str

Render the cost table FR-82 asks for, with its basis under it.

Parameters:

Name Type Description Default
costs list of PlannedPointCost

One row per point, as :func:estimate_point_cost returns them.

required

Returns:

Type Description
str

The fixed-width table, one line per point, followed by one basis line per distinct run type; an empty list gives the header alone. The point column is as wide as the longest run id (38 at least), so no run id is shortened and distinct points never print alike.

pyflightstream.run.cli.held_warnings

held_warnings() -> Iterator[list[warnings.WarningMessage]]

Hold back every warning raised inside, so a command can print them as one block.

The filters in force still decide: an ignored warning is not held, and a warning turned into an error still raises. :func:release_warnings gives the held ones back to :mod:warnings.

Yields:

Type Description
list of warnings.WarningMessage

The mutable list populated by warnings admitted inside the context.

pyflightstream.run.cli.inflow_harmonics_line

inflow_harmonics_line(
    harmonics: Mapping[str, object],
) -> str

Return the words the plan prints for one point's --inflow-fft record.

nP is counted on ONE BLADE (how many times it meets the perturbation per revolution), not the blade-passing N P of a fixed surface nor the rotor total (:mod:pyflightstream.cases.qsteady).

Parameters:

Name Type Description Default
harmonics mapping of str to object

The point inflow harmonic summary, including any unavailable-data note.

required

Returns:

Type Description
str

The computed summary or the reason it could not be computed.

pyflightstream.run.cli.is_portable_name

is_portable_name(text: str) -> bool

Whether text is a plain file-name-safe token: no separators, no whitespace, not empty.

A name Windows reserves for a device (NUL, CON, COM1) is not a file name there and is not portable either.

Parameters:

Name Type Description Default
text str

The candidate name.

required

Returns:

Type Description
bool

True when the text is not empty and holds no separator, whitespace or reserved name.

pyflightstream.run.cli.listed_ids

listed_ids(values: Sequence[str] | None) -> list[str]

Read ids given as words, commas or both, through the one reader of the form.

Each value is split on whitespace (so one quoted "2006 2007" reads as two ids), the words are joined with commas and read by :func:pyflightstream.workspace.ledger.listed_sims, so 2006 2007, 2006,2007 and [2006,2007] read alike; a repeated id is read once.

Parameters:

Name Type Description Default
values sequence of str or None

Argument words containing simulation ids; None selects no ids.

required

Returns:

Type Description
list of str

Parsed ids in first-seen order, with duplicates removed.

pyflightstream.run.cli.listed_sims

listed_sims(text: str | Sequence[str]) -> list[str]

Read simulation ids as delete-sims spells them: 4001,2009 or [4001,2009].

"4001 2009" selects two simulation ids. Selection separates whitespace-delimited ids before matching records.

Parameters:

Name Type Description Default
text str or sequence of str

The ids, comma or blank separated, with or without square brackets.

required

Returns:

Type Description
list of str

The ids, in the order given, blanks dropped.

Examples:

>>> listed_sims("[2006, 2007]")
['2006', '2007']
>>> listed_sims("2006 2007")
['2006', '2007']

pyflightstream.run.cli.note_post_ran

note_post_ran() -> None

Record that this invocation ran a post, so its success is signed as one.

pyflightstream.run.cli.parsed

parsed(
    parser: ArgumentParser, argv: Sequence[str] | None
) -> argparse.Namespace

Parse a pyfs-matrix command line, taking what it does not state from the files (FR-436).

An option typed wins over pyfs.local.toml, which wins over pyfs.toml, which wins over the package default; a file the reader refuses stops the command, exit 2, before anything is written.

Parameters:

Name Type Description Default
parser ArgumentParser

Command parser whose defaults can come from workspace settings.

required
argv sequence of str or None

Arguments without the program name; None reads sys.argv.

required

Returns:

Type Description
Namespace

Parsed arguments with settings and invocation selection applied.

pyflightstream.run.cli.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.cli.plan_receipt_error

plan_receipt_error(
    workspace: CampaignWorkspace,
    matrix_path: str | Path | None,
    matrix_stem: str | None,
    *,
    fs_exe: str | Path | None = None,
    effective_builds: Mapping[str, object] | None = None,
) -> str | None

Return why this run may not proceed on the plan it has, or None.

FOUR ANSWERS, and the last two are the ones the pins exist for:

  • no matrix: a campaign authored in Python is not planned through a file and this gate does not apply to it.
  • no plan file: refused, naming the command that writes one.
  • a plan neither of whose matrix digests answers for the matrix on disk (matrix_sha256, or matrix_form_sha256 where it holds one): refused, because the plan measured a different study. A plan that predates the pin carries None and is refused the same way, which is right: it cannot say what it read. The matrix is read without its IDENTIFIERS (FR-3561), which do nothing in a run, and the second digest also ignores the spaces around its pairs and ending a row.
  • an instrument or an input that changed after planning (NL-EXEC-1, FR-1556): refused when fs_exe is not the executable the plan measured, when an executable the plan read now has another SHA-256, or when a geometry file the plan read does.

Parameters:

Name Type Description Default
workspace CampaignWorkspace

The campaign root whose plan folder is searched for plan.json.

required
matrix_path str or Path

The matrix file the run reads; None for a campaign authored in Python.

required
matrix_stem str

The matrix file name without extension, which names the plan folder under post/.

required
fs_exe str or Path

The executable the run names for the campaign's own installation, when it names one; None leaves the comparison to the digests.

None
effective_builds mapping

Resolved per-simulation build, version and acceptance to compare with the plan after workspace and executable-entry defaults are applied.

None

Returns:

Type Description
str or None

The refusal text, or None when the run may proceed.

pyflightstream.run.cli.planner_for

planner_for(
    args: Namespace, default: Callable[..., Any]
) -> Callable[..., Any]

Return the function plan calls to plan the matrix.

Parameters:

Name Type Description Default
args Namespace

The parsed plan options (polar_sweep and batch).

required
default callable

The per-point function, returned unchanged when no grouped mode is asked.

required

Returns:

Type Description
callable

default, or plan_grouped_matrix bound to the asked mode.

pyflightstream.run.cli.post_diagnostics

post_diagnostics(log_paths: Sequence[Path]) -> str

Render saved diagnostics through the post layer without running stages.

pyflightstream.run.cli.post_stage_options

post_stage_options(
    stage: object,
    *,
    sims: Sequence[str] | None = None,
    keep: bool = False,
) -> dict[str, object]

Return the PFS-2185.18 keywords a post stage takes: sims, keep_unrebuilt.

Each is passed only when asked and only to a stage that accepts it, by name or through **options, as check_frozen is, so a stage registered before them keeps working: one without sims rebuilds its matrix whole when the run posts a simulation, as every stage did before the run posted each polar as it finished.

Parameters:

Name Type Description Default
stage callable

Post stage whose accepted keywords are inspected.

required
sims sequence of str or None

Simulation ids to pass when the stage accepts sims.

None
keep bool

Request keep_unrebuilt when the stage accepts it.

False

Returns:

Type Description
dict of str to object

Only the requested options the stage can receive.

pyflightstream.run.cli.post_warning_policy

post_warning_policy() -> bool | None

Return CLI warning preference, or None for ordinary Python callers.

Returns:

Type Description
bool or None

The active command warning preference; None outside that context.

pyflightstream.run.cli.print_held_warnings

print_held_warnings(held: list[WarningMessage]) -> None

Print held warnings as one titled block on stderr, a blank line before and after.

The one printer of the Warnings (<count>) block (FR-201): plan prints it after its header, every other command at its end.

Parameters:

Name Type Description Default
held list of warnings.WarningMessage

Captured warnings to print together, in their original order.

required

pyflightstream.run.cli.qsteady_validity_line

qsteady_validity_line(
    validity: Mapping[str, object],
) -> str

Return the words the plan prints for one quasi-steady wheel point.

validity is one :attr:PointPlan.qsteady_validity.

Parameters:

Name Type Description Default
validity mapping of str to object

The point quasi-steady validity record.

required

Returns:

Type Description
str

The reduced-frequency summary or its unavailable-data note.

pyflightstream.run.cli.read_a_choice

read_a_choice(word: object, *, context: str) -> bool

Read a yes-or-no word, REFUSING anything outside the vocabulary.

A word this does not know is an error and never a default. The permissive reading, where everything but three spellings means yes, has no failure mode: --ignore-missing-families off would have given the user the SKIP, which is the silence they passed the flag to escape, on a run that planned green and said nothing. That is the same shape as the incident pyflightstream.script.toggles records in its own module docstring, and this reader is built the way that one is.

Parameters:

Name Type Description Default
word object

true, yes, 1, false, no or 0, in any case, with surrounding whitespace ignored. A bool passes through, so a Python caller may write the value it means.

required
context str

What is being read, quoted in the refusal, so the message names the flag or the row key the user actually wrote.

required

Returns:

Type Description
bool

The boolean stated by the word, or the original boolean value.

Raises:

Type Description
InputValueError

If the word is outside the vocabulary. The message lists both halves of it, because a user who wrote the wrong word for NO needs to see the right words for NO beside the ones for yes.

pyflightstream.run.cli.records_parser

records_parser() -> argparse.ArgumentParser

Return the parser of the pyfs-workspace verbs that :data:WORKSPACE_VERBS names.

Built by the same builders as the pyfs-matrix parser, under the program name pyfs-workspace, with the same global flags.

Returns:

Type Description
ArgumentParser

The parser; its subcommand is args.subcommand, as under pyfs-matrix.

pyflightstream.run.cli.refused_command

refused_command(
    program: str, argv: list[str] | None
) -> bool

Refuse a removed command of program by name, before parsing; True when refused.

The command words are those past the global flags, so --warning-refusals refine is found as well as refine, and --help after them changes nothing. A command of two words (a group and its verb) is looked up before its first word alone, each as REMOVED_FORMS["<program>.<word>[.<word>]"]; the message names the new command and nothing is run.

Parameters:

Name Type Description Default
program str

The program, such as pyfs-workspace.

required
argv list of str or None

The command line without the program name; None reads sys.argv.

required

Returns:

Type Description
bool

True when the command line is a removed form and its refusal was printed.

pyflightstream.run.cli.release_warnings

release_warnings(held: Sequence[WarningMessage]) -> None

Warn again, in order, each warning :func:held_warnings held back.

Through :func:warnings.warn_explicit, so each is printed by the printer in force (the short [warning] form of a console command) and a caller recording warnings still receives them. Each was admitted by the filters when it was held, so each is warned once more under always: a once filter that already saw it would otherwise drop it here.

Parameters:

Name Type Description Default
held sequence of warnings.WarningMessage

Captured warnings to emit again, in their original order.

required

pyflightstream.run.cli.renumber_repeated_pols

renumber_repeated_pols(
    path: str | Path,
    workspace: CampaignWorkspace,
    *,
    in_place: bool = False,
) -> list[PolChange]

Give every repeated row of ONE matrix the next free POL (PFS-2031.21).

A row keeps its POL unless another matrix of the workspace already states it, or an earlier row of this matrix does. Each row that must move takes the next free number, counted up from the highest POL claimed ANYWHERE in the workspace: every row of every matrix, every sim_id in the manifest and every sims/sim_<id> folder, so a new POL never lands on the evidence of a study whose matrix has since been removed. Only this matrix is rewritten, and only its POL cells.

Parameters:

Name Type Description Default
path str or Path

The matrix to renumber.

required
workspace CampaignWorkspace

The workspace whose matrices, manifest and simulation folders claim POLs.

required
in_place bool

Rewrite the file. Keyword-only and False by default, which computes the changes and writes nothing, as every rewriter in this package does.

False

Returns:

Type Description
list of PolChange

One entry per moved row, in row order; empty when nothing repeats, in which case the file is not touched.

Raises:

Type Description
MatrixError

A row that must move already has records of THIS matrix in the manifest. Moving it would orphan them from the row that produced them, so it is refused by name and nothing is written.

pyflightstream.run.cli.resolve_matrix_arguments

resolve_matrix_arguments(args: object) -> int | None

Resolve, in place, every matrix argument of one parsed pyfs-matrix command.

Each (subcommand, destination) of :data:MATRIX_ARGUMENTS holding a value is replaced by :func:matrix_path of it over the homes of the command's --workspace (the working directory where it has none), as text, so every later use of the argument (the plan receipt, the post, the rebuild) reads the one file.

Parameters:

Name Type Description Default
args object

Parsed arguments exposing the subcommand, workspace and matrix destinations; resolved paths are written back to this object.

required

Returns:

Type Description
int or None

2, after printing the refusal to standard error, when a matrix is in both homes of the workspace with different bytes; None otherwise. A same-named file in the working directory only warns (FR-411).

pyflightstream.run.cli.resolve_workflow

resolve_workflow(name: str) -> Workflow

Look one workflow up in the table.

Parameters:

Name Type Description Default
name str

The workflow type, as a WORKFLOW cell writes it.

required

Returns:

Type Description
Workflow

The registered workflow.

Raises:

Type Description
CampaignConfigError

If no workflow of that name is registered. The refusal lists what IS registered, because a workflow cannot be supplied from outside: an unknown name is always a typo or a version gap, and never a module the caller forgot to install.

pyflightstream.run.cli.resume_hint

resume_hint(argv: Sequence[str]) -> str

Return the sentence naming the command that continues a refused second run (FR-327).

The command is the one invoked, every argument kept, with --resume added, quoted for the shell it was typed in: the Windows command-line rule on Windows and the POSIX rule elsewhere. Nothing is asked of the user; a run may be detached or scripted.

Parameters:

Name Type Description Default
argv sequence of str

Original arguments without the program name.

required

Returns:

Type Description
str

A continuation instruction containing the shell-quoted command.

pyflightstream.run.cli.run_query

run_query(args: Namespace) -> int

Run one query verb of pyfs-matrix; returns the process exit code.

Parameters:

Name Type Description Default
args Namespace

The parsed command line of a verb of :data:QUERY_COMMANDS.

required

Returns:

Type Description
int

0 when it printed; 1 when --sims named only simulations that hold no record and no planned point; 2 for a refused argument or a manifest that is not JSON.

pyflightstream.run.cli.runner_for

runner_for(
    args: Namespace, default: Callable[..., Any]
) -> Callable[..., Any]

Return the function run calls to run the matrix.

Parameters:

Name Type Description Default
args Namespace

The parsed run options (polar_sweep and batch).

required
default callable

The per-point function, returned unchanged when no grouped mode is asked.

required

Returns:

Type Description
callable

default, or run_grouped_matrix bound to the asked mode.

pyflightstream.run.cli.say_data

say_data(text: str) -> None

Print requested data on stdout at every console level, including quiet.

Parameters:

Name Type Description Default
text str

Requested output, printed with a terminating newline.

required

pyflightstream.run.cli.say_summary

say_summary(text: str) -> None

Print a command's final summary line on standard output, stated for a quiet console.

The same line :func:print writes, at every level; a quiet console says it once the command has ended (FR-997, :func:quiet_keeps).

Parameters:

Name Type Description Default
text str

The summary line.

required

pyflightstream.run.cli.selected_sims

selected_sims(
    records: Iterable[RunRecord],
    sims: Iterable[str],
    *,
    scope: str,
) -> frozenset[str]

Return the simulations sims names, each refused by name unless records hold it.

FR-307: the one refusal of post --sims and collect --sims, raised before either touches anything. records are the records the command may select from (one matrix's for the post), and scope says which in the refusal, for example "of matrix 'matriz'".

pyflightstream.run.cli.split_typed_ids

split_typed_ids(
    items: Sequence[str],
    root: str | Path,
    *,
    manifest: str = "runs.json",
    whole_only: bool = False,
) -> tuple[list[str], dict[str, list[str]]]

Split typed simulation ids from run id aliases, for a verb that destroys (FR-794).

Parameters:

Name Type Description Default
items sequence of str

What was typed after --sims: simulation ids and aliases.

required
root str or Path

The workspace root, whose records and plan.json files read the aliases.

required
manifest str

The manifest the verb reads, by name in the root.

'runs.json'
whole_only bool

The verb acts on whole simulations (delete-sims, rebuild), so an alias resolves to the simulation that holds it and acts only when the selection names EVERY point of that simulation; a selection that names part of it is refused, naming the simulation and its points, so the verb never acts on more than was named (PFS-2124.004).

False

Returns:

Type Description
tuple

The simulation ids and, per simulation, the point names the aliases name (none with whole_only, whose aliases are folded into the simulation ids); every alias read STRICTLY (the records and the plan must agree).

Raises:

Type Description
AliasError

An alias with no point, whose two readings disagree, or, with whole_only, aliases that name only part of a simulation's points.

pyflightstream.run.cli.stage_progress

stage_progress(
    name: str,
    *,
    total_files: int | None = None,
    total_bytes: int | None = None,
) -> Iterator[StageProgress]

Show the progress of one stage of a long command.

Yields a :class:StageProgress whose advance the stage calls as it works, and closes with one line saying what was done, or where the stage stopped when it raised or was interrupted; the stage's own exception passes through unchanged. A stage with nothing to do says nothing, and a Python caller outside a console command sees nothing at all.

Parameters:

Name Type Description Default
name str

Stage label printed by the command console.

required
total_files int or None

Expected file count, when known.

None
total_bytes int or None

Expected byte count, when known.

None

Yields:

Type Description
StageProgress

The stage counter to advance as work completes.

pyflightstream.run.cli.watch_interval_error

watch_interval_error(value: float | None) -> str | None

Return the refusal for a watch interval that would spin or raise (X-F-1292).

Parameters:

Name Type Description Default
value float or None

Requested watch interval in seconds.

required

Returns:

Type Description
str or None

Refusal text for a nonpositive or nonfinite interval; None otherwise.

pyflightstream.run.cli.workflow_names

workflow_names() -> tuple[str, ...]

Return the registered workflow names, sorted.

Returns:

Type Description
tuple of str

The names of every registered workflow, in alphabetical order.

pyflightstream.run.cli.workflow_registry

workflow_registry(
    *, conventions: WorkflowConventions | None = None
) -> dict[str, ScriptRecipe]

Return the workflows as a recipe registry the campaign loop can take.

This is the seam that makes a workflow reachable with NO user function: hand it to run_matrix(recipe_registry=...) and a row whose FS_SCRIPT code maps to a workflow NAME builds through the table instead of through an import.

Parameters:

Name Type Description Default
conventions WorkflowConventions

Passed down to every builder; the run layer owns these, since workspace sits above cases.

None

Returns:

Type Description
dict of str to callable

{name: build(case, script) -> None}, satisfying :class:pyflightstream.cases.ScriptRecipe.

Examples:

>>> from pyflightstream.cases.workflows import workflow_registry
>>> registry = workflow_registry()
>>> "steady" in registry
True
>>> registry["steady"].__name__
'workflow_steady'

pyflightstream.run.cli.wrap

wrap(
    text: str,
    *,
    first: str = "",
    rest: str | None = None,
    width: int = WIDTH,
) -> list[str]

Return text wrapped at width columns, one entry per printed line.

first starts the first line and rest every other, which defaults to as many spaces as first is long, so a continuation reads under the text. A line break already in text is kept, and each of its lines is wrapped on its own; words are never split or reordered.

Parameters:

Name Type Description Default
text str

Text to wrap, retaining existing line breaks.

required
first str

Prefix of the first output line.

''
rest str or None

Prefix of later lines; spaces matching first when omitted.

None
width int

Target line width, including the prefix.

WIDTH

Returns:

Type Description
list of str

The wrapped lines, without newline terminators.