pyflightstream.workspace.manifest (provisional)¶
Generated from the docstrings at build time: every one of the 23 names in the __all__ of pyflightstream.workspace.manifest has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Run and extraction records, manifest writers and the owned manifest lease.
The workspace facade keeps the historical imports and delegates writes here. Existing record shapes and serialized fields are preserved.
Used in the guides¶
pyflightstream.workspace.manifest.RunRecord
¶
Bases: BaseModel
One manifest record: a single executed campaign point.
The record plus the staged inputs reproduce the run (NFR-07).
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Unique identity of the executed point, for example
|
sim_id |
str
|
Simulation identity; ties the record to |
point |
dict of str to float
|
Sweep point coordinates, for example alpha and beta in deg. |
fs_version_requested |
str
|
Canonical FlightStream version the script was built for. |
fs_version_reported |
(str, optional)
|
Version printed in the solver outputs; filled by the parsers and cross-checked against the requested one (FR-18). |
fs_build |
(str, optional)
|
Build string reported by the solver, when available. |
fs_version_source |
str or None
|
Where the build this point ran on came from: None means the row PREDATES the field and is not a claim that the
build was inherited, exactly as |
velocity_requested_m_s |
float or None
|
Free-stream velocity in m/s the case ASKED for, as
:attr: None means the run did not request a velocity, which includes every row written before the field existed, and is NOT zero: a binding treats an unrequested axis as unasked rather than as agreed, and zero would be a request the export could contradict. |
package_version |
str
|
pyflightstream version that produced the run. Read from the
installed distribution's metadata, which is a static string, so
every commit between two tags reports the tag: use
|
package_commit |
(str, optional)
|
Git commit the package's code came from, when it came from a tracked work tree; None for a wheel install, where there is no repository to ask (PYFS-017). |
package_dirty |
(bool, optional)
|
Whether that work tree had uncommitted changes. None travels
with a None |
script_sha256 |
str
|
Hash of the executed script text. |
inputs_sha256 |
dict of str to str
|
Hash per staged input file name, recorded at staging time. |
raw_flag |
bool
|
True when the script used the |
manifest_schema |
str or None
|
Identifier of the record layout this row was written under. A reader that does not know the value should refuse rather than guess which fields exist (PYFS-015). None means the row PREDATES the field and is not a claim that it was written under the current schema. Reading an older row does not stamp it with the current schema (REV010-014). "The field is absent because the row is old" and "the row asserts the current schema" are different facts about the evidence. |
conditions |
list of dict, optional
|
The operating-point binding recorded by the assessor, one
entry per requested axis the export printed back: |
fs_exe |
(str, optional)
|
Solver executable the run invoked, as resolved. |
fs_exe_sha256 |
(str, optional)
|
Hash of that executable, so a later reader can tell whether the same binary is still installed. None when it could not be read. |
argv |
list of str
|
The exact command line, argument by argument. Reproducing a run from the record needs the flags, not a guess at how the executor builds them. |
cwd |
(str, optional)
|
Working directory the solver process ran in. |
timeout_s |
(float, optional)
|
Wall-clock limit actually applied to the process. |
recipe |
(str, optional)
|
Recipe identifier as the case declared it. |
recipe_sha256 |
(str, optional)
|
Hash of the recipe function's source at run time. A recipe is user code that can be edited between runs, so the name alone does not identify what built the script; None when the source is not introspectable. |
script_path |
(str, optional)
|
Generated script, relative to the simulation folder. |
outputs_sha256 |
dict of str to str
|
Hash per collected output, keyed by the same relative name that
appears in |
waived_commands |
list of BrokenCommandRecord
|
Serialized
:class: The key was
|
executor |
ExecutorRecord or None
|
Which executor ran the point and the argv it ran, read off the
run rather than asserted (PFS-2012.04); None on a point where
no solver ran, and on every row written in legacy releases. Adding
it did not move :data: |
export_window |
ExportThresholdRecord or None
|
The export threshold the row states for its unsteady exports
(PFS-2031.18), as resolved for this run: |
solver_setup |
(dict, optional)
|
Serialized solver-setup snapshot
(:class: |
status |
RunStatus
|
Terminal status of the point. |
iterations |
(int, optional)
|
Solver iterations reached, when parsed. |
residual |
(float, optional)
|
Final residual, when parsed. |
wall_time_s |
(float, optional)
|
Wall-clock duration of the solver process in seconds. |
started_at |
(str, optional)
|
When the solver process was started, ISO 8601 in UTC to the
second, as the executor read its clock (PFS-2012.08.01); the
provenance document the products stage writes states it as the
run activity's start. None where no solver ran, where the
executor reports no clock, and on every row written in legacy releases. Adding it did
not move :data: |
finished_at |
(str, optional)
|
When the process ended, or was killed on timeout, the same way. |
outputs |
list of str
|
Collected output files, relative to the simulation folder
(for example |
error |
(str, optional)
|
Error text for failed points. |
flight_condition_defaults |
dict of str to float
|
The fluid pins the row's SETUP artifact supplied, with the values
used, for the keys the row did not state (PFS-2030.08). Empty
means the row stated everything its resolution used, which is
every record written in legacy releases; it is NOT a claim that the
setup carried no table. HOW TO READ THE PAIR: a pin in
|
flight_condition_defaults_from |
str
|
Which setup supplied those pins, id and path, for example
|
angles_not_stated |
list of str
|
The flow angles ( |
matrix_stem |
(str, optional)
|
The stem of the run matrix the point came from, when the campaign
was converted from one (PFS-2031.04). A workspace may hold several
matrices sharing this one manifest, and the sweep table and the
products of each are rebuilt from the records that name it. None
means the record predates the field or the campaign was authored
in Python; such a record belongs to no matrix and is left out of a
per-matrix table rather than counted in every one. Adding it did
not move :data: |
reductions |
dict or None
|
The windows of every reduction the products stage writes beside
the point's plots table (PFS-2015.04), resolved off the row by
:func: a row that names its rotors by alias also carries
|
flight_condition |
dict of str to float
|
The flight condition AS WRITTEN in the row, canonical key to
value, in the units the key names ( |
density_kg_m3 |
(float, optional)
|
Resolved density in kg/m3. |
temperature_k |
(float, optional)
|
Resolved static temperature in K, including any ISA deviation. |
viscosity_pa_s |
(float, optional)
|
Resolved dynamic viscosity in Pa s, from Sutherland's law at
|
density_source |
({'atmosphere', 'solved-from-reynolds'}, optional)
|
WHICH BRANCH produced |
reference_length_m |
(float, optional)
|
The reference length in m that the resolution used, which is
|
action_program |
(str, optional)
|
The counter program the run layer wrote for a row stating
|
action_script |
(str, optional)
|
The file the SCRIPT action points at and the program rewrites,
relative to the simulation folder; |
action_count |
(int, optional)
|
The invocation count the program reached, read from its count file after the solver exited: the number of time steps the solver completed, since the count is the step count exactly (RPT-041). None when the file was never written: a row with no threshold, or a solver that never reached a time step. |
Examples:
A synthetic record illustrates serialization without running a solver:
>>> from pyflightstream.workspace import RunRecord, RunStatus
>>> record = RunRecord(
... run_id="demo/sim_1/AL+000", sim_id="1",
... fs_version_requested="25.0", package_version="0.36.0",
... script_sha256="0" * 64, raw_flag=False, status=RunStatus.SUBMITTED,
... )
>>> record.model_dump(mode="json")["status"]
'SUBMITTED'
>>> record.as_points()[0] is record
True
as_points
¶
as_points() -> list[RunRecord]
Return this record as one record per POINT.
THE MANIFEST STORES JOBS and a steady matrix row is one job over several points, so a consumer that reasons per point (the physics reduction, a per-point table, an assessor comparing angles) would see one point where three ran. Rather than have each of them learn the job shape, they ask here.
A record that is one point returns itself, unchanged and not copied, so every caller can use this unconditionally and the common path costs nothing.
pyflightstream.workspace.manifest.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'
Advanced¶
pyflightstream.workspace.manifest.ADDITIONAL_MANIFEST
module-attribute
¶
ADDITIONAL_MANIFEST = 'additional.json'
pyflightstream.workspace.manifest.ADDITIONAL_MANIFEST_SCHEMA
module-attribute
¶
ADDITIONAL_MANIFEST_SCHEMA = 'pyfs-additional/1'
pyflightstream.workspace.manifest.AdditionalRecord
¶
Bases: BaseModel
One extraction of the additional post: a saved simulation reopened, with no solve.
Written to :data:ADDITIONAL_MANIFEST and never to runs.json, so the
point's own record stays exactly as its run wrote it. Every path is
relative to the point's simulation folder, as a run record's are.
Attributes:
| Name | Type | Description |
|---|---|---|
manifest_schema |
str
|
:data: |
extraction_id |
str
|
|
run_id |
str
|
The point's run id, as :meth: |
job_id |
str or None
|
The run id of the job record the point belongs to, for a steady row run as one job; None for a point recorded on its own. |
sim_id, point_name, matrix_stem |
str or None
|
Copied from the point's record. |
pproc |
str
|
The ADDITIONAL pproc id, which the products are marked with. |
pproc_sha256 |
str or None
|
sha256 of |
fsm |
str
|
The point's saved simulation, as its record names it. |
fsm_sha256 |
str
|
Its sha256 in the point's record, which the file on disk matched and the copy the solver opened matched too. |
fsm_sha256_after |
str or None
|
The ORIGINAL file hashed again after the launch; it equals
|
unsteady |
bool
|
Whether the point marched in time; its extraction is then one instant, the last. |
note |
str or None
|
What a reader of the extraction must know: the one-instant sentence on an unsteady point. |
fs_version_requested, fs_exe, fs_exe_sha256 |
str or None
|
The build the extraction was emitted under and run on. |
package_version, package_commit, package_dirty |
As on a run record. |
|
script_path, script_sha256 |
str
|
The extraction script, under |
working_dir |
str
|
Where the solver ran and wrote: |
argv, cwd, timeout_s, executor, started_at, finished_at, wall_time_s |
How the solver was called, as on a run record. |
|
status |
ExtractionStatus
|
The terminal status. |
error |
str or None
|
Why a failed extraction failed. |
outputs |
list of str
|
The files written, relative to the simulation folder. |
outputs_sha256 |
dict of str to str
|
sha256 of each, keyed by the same name. |
sections_layout |
list of dict
|
Which rows of the sections exports are which distribution: the run's own layout first, then the additional pproc's blocks, numbered on after the run's and marked with the pproc (RPT-062: a reopened export carries the run's distributions first and the new ones after them). |
leading_sections |
int
|
How many rows at the head of those exports are the run's own. |
frames |
dict
|
The frames the extraction cited, by name, as the run created them. |
inventory |
list of str or None
|
The boundary names the saved simulation holds, in the solver's order. |
surface_translations |
list of dict or None
|
The Tecplot surfaces the package wrote from the extraction's VTK (G45), as a run record states them. |
pyflightstream.workspace.manifest.BrokenCommandRecord
¶
Bases: TypedDict
One serialized :class:~pyflightstream.script.BrokenCommandUse.
The JSON shape of a waived_commands entry of the manifest,
declared here rather than imported so the workspace layer keeps its
manifest schema and the script layer keeps the model. The model is
the single home of what each field MEANS: read
:class:~pyflightstream.script.BrokenCommandUse for that, including
why two of these are versions and are not interchangeable.
Every key is optional (total=False) and no member type is
narrower than the model's, which is the compatibility half: a
manifest row written before a key existed still reads back, exactly
as :attr:RunRecord.manifest_schema may be None. Unknown keys are
KEPT rather than dropped, so reading a manifest a later version
wrote never quietly edits the evidence.
pyflightstream.workspace.manifest.COST_EXCLUDED_STATUSES
module-attribute
¶
COST_EXCLUDED_STATUSES = frozenset(
status
for status in RunStatus
if status.name.startswith("FAILED")
or status
in {
RunStatus.WALLTIME_REACHED,
RunStatus.SUBMITTED,
RunStatus.RAN_MISSING_LOG,
RunStatus.GEOMETRY_FAILED,
}
)
Statuses whose wall clock is not a completed-run cost sample.
pyflightstream.workspace.manifest.ExecutorRecord
¶
Bases: TypedDict
How the solver was called, as the run layer read it off the run.
The JSON shape of the executor entry of a manifest row
(PFS-2012.04). class_name is the executor's class as it ran
(LocalExecutor today; an HPC executor the day FR-15 lands) and
argv the command line it returned, which is the same list as the
row's own argv and travels here as well so the entry is one
self-contained fact a report can be built from. Both keys are
required: the entry is written whole or, on a point where no solver
ran, not at all, and the row says None. forced_local is
present, and true, only on a point the run's local switch kept on a
machine that would otherwise have submitted; a record
written before it, or by a run that did not ask, has no key, and a legacy reader refuses a
manifest that carries one.
pyflightstream.workspace.manifest.ExtractionStatus
¶
Bases: StrEnum
Status of one extraction of the additional post (G12).
There is no convergence verdict among them: an extraction solves nothing, so it is judged by its process and by the files it declared.
pyflightstream.workspace.manifest.KNOWN_MANIFEST_SCHEMAS
module-attribute
¶
KNOWN_MANIFEST_SCHEMAS = (
"pyfs-manifest/1",
"pyfs-manifest/2",
"pyfs-manifest/3",
)
pyflightstream.workspace.manifest.MANIFEST_LOCK_POLL_S
module-attribute
¶
MANIFEST_LOCK_POLL_S = 0.02
pyflightstream.workspace.manifest.MANIFEST_LOCK_RENEW_S
module-attribute
¶
MANIFEST_LOCK_RENEW_S = 5.0
pyflightstream.workspace.manifest.MANIFEST_LOCK_STALE_S
module-attribute
¶
MANIFEST_LOCK_STALE_S = 300.0
pyflightstream.workspace.manifest.MANIFEST_LOCK_TIMEOUT_S
module-attribute
¶
MANIFEST_LOCK_TIMEOUT_S = 60.0
pyflightstream.workspace.manifest.MANIFEST_SCHEMA
module-attribute
¶
MANIFEST_SCHEMA = 'pyfs-manifest/3'
pyflightstream.workspace.manifest.SOURCE_VERSION_REQUIRED_SINCE
module-attribute
¶
SOURCE_VERSION_REQUIRED_SINCE = 'pyfs-manifest/2'
pyflightstream.workspace.manifest.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.workspace.manifest.append_record
¶
append_record(
workspace: _ManifestWorkspace, 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 defaults 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace
|
CampaignWorkspace
|
The owner of the manifest and its read and write operations. |
required |
record
|
RunRecord
|
The new run to append, with a unique |
required |
Raises:
| Type | Description |
|---|---|
WorkspaceError
|
If the |
Examples:
Append a synthetic record to a temporary workspace without a solver:
>>> from tempfile import TemporaryDirectory
>>> from pyflightstream.workspace import CampaignWorkspace, RunRecord, RunStatus
>>> from pyflightstream.workspace.manifest import append_record
>>> record = RunRecord(
... run_id="demo/sim_1/AL+000", sim_id="1",
... fs_version_requested="25.0", package_version="0.36.0",
... script_sha256="0" * 64, raw_flag=False, status=RunStatus.SUBMITTED,
... )
>>> with TemporaryDirectory() as directory:
... workspace = CampaignWorkspace(directory)
... append_record(workspace, record)
... workspace.read_manifest()[0].run_id == record.run_id
True
pyflightstream.workspace.manifest.complete_submitted_record
¶
complete_submitted_record(
workspace: _ManifestWorkspace, 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace
|
CampaignWorkspace
|
The owner of the manifest and its read and write operations. |
required |
record
|
RunRecord
|
The completed record replacing the row with the same |
required |
Raises:
| Type | Description |
|---|---|
WorkspaceError
|
When the manifest holds no row with that |
pyflightstream.workspace.manifest.manifest_lock
¶
manifest_lock(
manifest: Path,
*,
root: Path,
timeout_s: float,
renew_s: float,
stale_s: float,
poll_s: float,
) -> Iterator[None]
Hold the manifest's read-modify-replace under an owned, renewable lease.
manifest is the file the lease guards, runs.json unless named:
the extraction manifest of the additional post (G12) takes a lease of
its own under the same rules, additional.json.lock, so an extraction
never holds or waits on the lease of the runs.
runs.json.lock records the PID, host and a unique token. A background
heartbeat updates its modification timestamp every five seconds. A waiter
recovers it only for a confirmed dead local PID or after 300 seconds with
no renewal; elapsed time since acquisition alone never expires a lease.
Legacy PID-only files have no verifiable host and use the same stale bound.
A persistent .runs.json.lock.guard serialises ownership changes and
the entire read-modify-replace interval using an OS byte/file lock. It is never
deleted: replacing its inode would split the arbitration between waiters.
The OS releases this guard if its process dies. The filesystem must honour
these locks across clients (SMB/NFS deployments must support locking), and
hosts must synchronise clocks for the stale-heartbeat fallback. A live
writer retains the guard even if its heartbeat stalls, so a successor cannot
take over while the former writer can still publish its snapshot.
A release removes only its own token, including on a refused write.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
Path
|
The manifest file whose lease is acquired. |
required |
root
|
Path
|
The workspace directory, created before acquiring the lease. |
required |
timeout_s
|
float
|
Finite, nonnegative maximum wait in seconds for another writer or the arbitration guard. |
required |
renew_s
|
float
|
Seconds between heartbeat renewals while the lease is held. |
required |
stale_s
|
float
|
Seconds without renewal after which a lease may be recovered. |
required |
poll_s
|
float
|
Seconds between acquisition attempts. |
required |
Yields:
| Type | Description |
|---|---|
None
|
Control to the writer while it owns the lease. |
Raises:
| Type | Description |
|---|---|
WorkspaceError
|
If the timeout is invalid or another writer holds the manifest for the configured wait bound. |
pyflightstream.workspace.manifest.planned_points_without_record
¶
planned_points_without_record(
planned: Iterable[str],
rows: Iterable[Mapping[str, object]],
) -> list[str]
Return the planned run ids no record carries, in the order planned.
A planned point (<campaign>/sim_<id>/<point>, as plan.json lists it)
is recorded by a record of its own id; by a record of the same campaign and
simulation whose id ends with its point, which is a continuation of it; by
a JOB record of its row (<campaign>/sim_<id>/sweep) whose points_ran
names it; or by a job record that ran no point, which stands for every
point of its row (a job refused before it ran records them all at once).
Rows without a run_id, such as a delete-sims note, carry nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planned
|
iterable of str
|
The planned run ids. |
required |
rows
|
iterable of mapping
|
The manifest's rows as written ( |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
The planned run ids with no record, the points a run never attempted. |
Examples:
>>> planned_points_without_record(
... ["c/sim_1/J1", "c/sim_1/J2", "c/sim_2/AL+000"],
... [{"run_id": "c/sim_1/J1", "sim_id": "1"},
... {"run_id": "c/sim_2/sweep", "sim_id": "2", "points_ran": []}],
... )
['c/sim_1/J2']
pyflightstream.workspace.manifest.supersede_records
¶
supersede_records(
workspace: _ManifestWorkspace,
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 |
|---|---|---|---|
workspace
|
CampaignWorkspace
|
The owner of the manifest and its read and write operations. |
required |
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. |