pyflightstream.run.records (provisional)¶
Generated from the docstrings at build time: every one of the 4 names in the public definitions (the module declares no __all__) of pyflightstream.run.records has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The run records of a workspace: which manifest, its restore and its rebuild.
Pipeline role: the run row, beside the manifest the run stage writes. It is
the home of three operations on the records of a campaign workspace
(work package B1; the packages that call it, B2 with the sync and B3 with the
post and collect reading --runs, code against the same signatures):
- :func:
resolve_manifestnames the manifest file a command reads: the defaultruns.json, or another file directly in the workspace root (pyfs-matrix post --runs NAMEand its siblings). it is defined in :mod:pyflightstream.workspace.namingand re-exported here (AD-09), so the storage layer below this one reads it without reaching up. - :func:
restorebrings a file of the records family back from the workspace's archive, EXACTLY: the manifest, the storage record, a matrix's products record, the plan receipt or the additional-post record (the kinds of :data:RESTORE_KINDS). It previews unless asked to apply, and archives the current file before it replaces it, so a restore can itself be undone. - :func:
rebuildmakes run records AGAIN from the simulation folders undersims/when no archive holds them. It is not a restore and every record it makes says so in itswarnings.
The two operations carry two names on purpose (GEO-066, R2): a reader must never trust a rebuilt record as the one written when the point ran.
How a record is rebuilt, and what proves it. The matrix row is run again
through this package's own campaign loop in a throwaway SHADOW workspace (a
copy of inputs/ and of the matrix in a temporary folder), with a
submitting executor that submits nothing, which mints the SUBMITTED record
the cluster path writes. The proof of identity is the executed script: the
script on disk under sims/sim_<id>/scripts/ must be the script THIS
package version renders for that row, once the workspace root and the
interpreter path are set aside on both sides; otherwise the simulation is
refused, naming the version and, line by line, which input the difference
comes from. The record is then completed by the package's own collect stage
run READ-ONLY over the files already on disk (:func:collect_without_writing):
a collection that would move, copy, translate or expand a file is not done,
and the record stays SUBMITTED for pyfs-matrix collect. The whole
workspace tree is compared before and after, and nothing is written when it
changed.
Deliberately NOT rebuilt: a simulation stored compressed, one whose record a
known run of another package version wrote, one whose row no matrix holds (it
waits for the revision that ran, matrix), one whose executed script
differs, and one with no declared output. A SUBMITTED record is pointed to
pyfs-matrix collect unless every simulation is rebuilt (all_sims),
which judges each from its outputs instead.
The post and the collect of other records (work package B3):
:func:manifest_workspace is the workspace post --runs NAME
and collect --runs NAME read, :func:assemble_records assembles the
records of post --from-sims in memory from the simulation folders, and
:func:from_sims_workspace is the workspace that post reads. Both kinds are
a :class:ManifestWorkspace, whose products go to post/<matrix>@<label>/
beside the default ones and never over them.
FIVE MODULES (AD-11). This one holds :func:restore and
:func:mark_failed and keeps every public name of the records family at its public path. The
record files, their archives, the lease and
:class:RecordsError are :mod:pyflightstream.run._record_files; what a
rebuild reads and compares is :mod:pyflightstream.run._rebuild_evidence;
the rebuild itself is :mod:pyflightstream.run._rebuild; the assembly of
other records for the post is :mod:pyflightstream.run._assemble. Each
imports only ones before it and none imports this module, so there is no
import cycle among them. The machinery the rebuild drives and the collect's
assessor are imported inside the functions that call them. The collect stage
is made read-only by replacing its three writes with refusals for the length
of one call, under a lock (:func:collect_without_writing); nothing else of
the stage is changed.
Advanced¶
pyflightstream.run.records.mark_converged
¶
mark_converged(
root: str | Path,
sims: Sequence[str],
*,
reason: str,
points: Sequence[str] | None = None,
apply: bool = False,
) -> dict[str, Any]
Record a person's verdict of CONVERGED on the named points (FR-414).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str or Path
|
The workspace root. |
required |
sims
|
sequence of str
|
Simulation ids; each may hold several, comma separated. |
required |
reason
|
str
|
Why the person judges them converged, recorded as given; required. |
required |
points
|
sequence of str
|
Point names; only the records of these points of the named simulations are marked. Without it every point of them is. |
None
|
apply
|
bool
|
Write. Without it nothing changes and the result says what would. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
RunsManifestError
|
No reason, no simulation named, no |
AliasError
|
An alias the records and the plan read differently, or that names no
point, as |
pyflightstream.run.records.mark_failed
¶
mark_failed(
root: str | Path,
sims: Sequence[str],
*,
reason: str | None = None,
apply: bool = False,
points: Mapping[str, Sequence[str]] | None = None,
) -> dict[str, Any]
Mark every record of the named simulations FAILED_MARKED (FR-309).
A run can end CONVERGED and still be wrong, which the person finds
only later, reading its products. The record is not deleted: its
status becomes FAILED_MARKED, and marked keeps the status it
had, when it was marked and the reason given, so the post, the cost
estimate and delete-sims treat it as any failure and the history stays.
A steady job is marked per point: each points_ran entry marked takes
the status and its own marked, and the job takes its worst point's
status; a job marked whole keeps marked at its top as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str or Path
|
The workspace root. |
required |
sims
|
sequence of str
|
Simulation ids. An id with no record in |
required |
reason
|
str
|
Why the runs are marked, recorded as it is given. |
None
|
apply
|
bool
|
Write. Without it nothing changes and the result says what would. |
False
|
points
|
mapping of str to sequence of str
|
Per simulation, the point names whose records alone are marked (a run id
alias, FR-395); a simulation also in |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
RunsManifestError
|
No |
pyflightstream.run.records.rebuild
¶
rebuild(
root: str | Path,
*,
out: str | None = None,
all_sims: bool = False,
sims: Sequence[str] | None = None,
build_alias: Mapping[str, str] | None = None,
matrix: str | Path | None = None,
apply: bool = False,
inputs_from: str | Path | None = None,
) -> dict[str, Any]
Rebuild run records from the simulation folders under sims/.
Each record is minted again by this package from the matrix row, proved
by the executed script being the one this version renders for that row,
and completed by the collect stage over the files on disk, read-only (the
module docstring says how). A record the rebuild makes carries a warning
starting with REBUILT that says what was reconstructed and with which
version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str or Path
|
The workspace root. |
required |
out
|
str
|
The manifest file the rebuilt records go to, a name
:func: |
None
|
all_sims
|
bool
|
Rebuild EVERY simulation folder on disk, recorded or not, so the result
can be compared with |
False
|
sims
|
sequence of str
|
The simulation ids to rebuild, recorded or not. |
None
|
build_alias
|
mapping of str to str
|
The scheduler name a solver build had when it ran, keyed by the build, for a build the submission profile no longer maps; the default is the build itself. It enters only the job descriptor of the shadow run, never the solver script, and the record says which alias was assumed. |
None
|
matrix
|
str or Path
|
The matrix revision the simulations ran from, for a POL no current
matrix holds (a row deleted or renumbered after it ran). Name the file
as the matrix was named when it ran. Without it every matrix at the
root and in |
None
|
apply
|
bool
|
Write the manifest; without it the call previews and writes nothing. |
False
|
inputs_from
|
str or Path
|
Another origin's |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
RunsManifestError
|
|
RecordsError
|
|
pyflightstream.run.records.restore
¶
restore(
root: str | Path,
kind: str,
*,
stamp: str | None = None,
apply: bool = False,
matrix: str | None = None,
) -> dict[str, Any]
Restore one file of the records family from the workspace's archive.
Exact and cheap: the archived bytes become the file again, unchanged. The
archive forms read are archive/runs-<stamp>.json, where sync,
--force-rerun, delete-sims, rename, mark-failed and
mark-converged copy the manifest before rewriting it; in the same form
archive/storage_management-<stamp>.json and archive/additional-<stamp>.json;
and, beside a matrix's products,
post/<matrix>/archive/<stamp>/products.json and .../plan.json.
Every restore that applies archives the file it replaces in these forms.
The writers of the storage record, the products record, the plan receipt
and the additional-post record archive their file before rewriting it
(workspace.naming.archive_previous, the one home of these names), so every
kind has copies to bring back; products.json is archived rather than
removed when a post rebuilds. A copy numbered within one stamp
(runs-<stamp>.2.json) or labelled after it
(runs-<stamp>-before-doctor.json) is found too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str or Path
|
The workspace root. |
required |
kind
|
str
|
One of :data: |
required |
stamp
|
str
|
The archive stamp to restore from, |
None
|
apply
|
bool
|
Change files; without it the call previews and changes nothing. With it the current file, when there is one, is archived first under the same form, so the restore can be undone by restoring that copy. |
False
|
matrix
|
str
|
For |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
RecordsError
|
An unknown kind; no archived copy (naming where it was looked for); a
stamp no copy carries (naming the stamps that exist); archives for
several matrices and none named; a |