Skip to content

pyflightstream.workspace.naming (stable)

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

Output-only naming templates for human-readable run file names.

Pipeline role: renders the human-readable names of generated scripts, per-point exports, and simulation archives from a user-configurable template. Names are a reading convenience for people and external tools, nothing more: run identity lives in the campaign manifest (runs.json), never in a file or folder name, and no API in this package parses a generated name back into its parts (SAD Section 6). Structural simulation and datapoint folders have explicit inverses below; these do not parse configurable generated file names.

Available placeholders:

  • {campaign}: the campaign name.
  • {sim}: the sim_id of the case.
  • {point}: the point name of :func:pyflightstream.cases.point_name, every variable the row's flight condition declares, in its order, for example M144RE438AL+000BE+000J+080.
  • {alpha}, {beta}: sweep angles in deg, compact (2, -3.5).
  • {advance_ratio}: rotor advance ratio J, dimensionless, compact.
  • {mach}: free-stream Mach number of the case, compact.
  • {polar}: the file stem of the point, P<sim>-<point name>, so P2001-M144RE438AL+000BE+000J+080 (in legacy releases it was POLAR-<sim>_M<mach*100>AL..BE..J..).
  • {name}, in OUTPUT names only: the rendered point stem, so every export hangs off the point's name whatever template produced it.

The default templates are {point} for per-point files and sim_{sim} for archives; the matrix command line names points by :data:MATRIX_POINT_NAME, P<sim>-<point name>. A workspace written in legacy releases carries older names; see docs/upgrading.md for supported workspace formats and explicit migration.

Advanced

pyflightstream.workspace.naming.ADDITIONAL_DIR module-attribute

ADDITIONAL_DIR = 'additional'

pyflightstream.workspace.naming.ARCHIVE_DIR module-attribute

ARCHIVE_DIR = 'archive'

pyflightstream.workspace.naming.ARCHIVE_STAMP module-attribute

ARCHIVE_STAMP = '%Y%m%d-%H%M%S'

pyflightstream.workspace.naming.ARCHIVE_STAMP_PATTERN module-attribute

ARCHIVE_STAMP_PATTERN = '\\d{8}-\\d{6}'

pyflightstream.workspace.naming.DATAPOINT_PREFIX module-attribute

DATAPOINT_PREFIX = 'DP-'

pyflightstream.workspace.naming.DEFAULT_MANIFEST module-attribute

DEFAULT_MANIFEST = 'runs.json'

pyflightstream.workspace.naming.MACH_POINT_KEY module-attribute

MACH_POINT_KEY = 'MACH'

pyflightstream.workspace.naming.MATRIX_POINT_NAME module-attribute

MATRIX_POINT_NAME = '{polar}'

pyflightstream.workspace.naming.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.workspace.naming.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.workspace.naming.POINT_FILE_PREFIX module-attribute

POINT_FILE_PREFIX = 'P'

pyflightstream.workspace.naming.PointName

Bases: str

A point's name, as :func:pyflightstream.cases.point_name wrote it.

A str that has been CHECKED: not empty, a portable file name, and not already carrying the DP- folder prefix. The datapoint folder is rendered from it and never from a bare string, because a string that already held the prefix, or a tag of the earlier scheme, put files in a folder the assessor never looks in.

THE CALLER OF THE LEGACY NAMING SCHEME: :func:datapoint_name_of builds one of these from a folder that ALREADY EXISTS under a legacy tag, for a collector that read that folder off the record rather than recomputing it. The harm above is a name INVENTED in the old scheme, which files outputs where nothing looks; reading back a folder that is already there is its opposite. That function answers None rather than raising for anything it cannot check, which is what keeps this class's refusal out of a caller that could not handle it.

Examples:

>>> PointName("M144AL+020")
'M144AL+020'
>>> try:
...     PointName("a b")
... except ValueError as error:
...     print(type(error).__name__)
NamingTemplateError

pyflightstream.workspace.naming.RunsManifestError

Bases: PyflightstreamError, ValueError

A manifest name that does not name a file directly in the workspace root.

ValueError because the refused thing is the NAME a caller passed, before any file is read.

pyflightstream.workspace.naming.SIM_DATAPOINTS_DIR module-attribute

SIM_DATAPOINTS_DIR = 'datapoints'

pyflightstream.workspace.naming.SUPER_FILE_PREFIX module-attribute

SUPER_FILE_PREFIX = 'SUPER-'

pyflightstream.workspace.naming.archive_previous

archive_previous(
    base: Path, path: Path, *, matrix: str | None = None
) -> Path | None

Copy the file a writer is about to rewrite into the archive restore reads.

matrix names the folder under post/ for the kinds kept per matrix (products.json, plan.json); a root kind (storage_management.json, additional.json) leaves it None. Nothing is done when there is no previous file. A copy that fails is warned and never raised: the writer goes on, and the archive is a courtesy the write does not depend on. Returns the copy, or None.

Parameters:

Name Type Description Default
base Path

The workspace root.

required
path Path

The file about to be rewritten.

required
matrix str

The matrix stem of a kind kept per matrix; None for a root kind.

None

Returns:

Type Description
Path or None

The archived copy, or None when there was nothing to copy or the copy failed.

pyflightstream.workspace.naming.datapoint_dir_name

datapoint_dir_name(name: PointName) -> str

Return the folder name one datapoint collects its outputs into (FR-92).

:data:DATAPOINT_PREFIX and the point name that already ends the run_id and is the stem of every file of the point, so the folder, the files and the run record carry ONE identity (DP-M144RE438AL+000BE+000J+080).

Parameters:

Name Type Description Default
name PointName

The point's name, checked.

required

Returns:

Type Description
str

Folder name, relative to :data:SIM_DATAPOINTS_DIR.

Raises:

Type Description
NamingTemplateError

If name is a bare string rather than a :class:PointName.

pyflightstream.workspace.naming.datapoint_name_of

datapoint_name_of(folder: str) -> PointName | None

Return the point a datapoint FOLDER belongs to, or None if it names none.

The inverse of :func:datapoint_dir_name, and it lives beside it because a rule and its inverse drifting apart is the defect this module already records for :data:ARCHIVE_STAMP.

Parameters:

Name Type Description Default
folder str

A folder name read off disk.

required

Returns:

Type Description
PointName or None

The checked name, or None when folder does not carry :data:DATAPOINT_PREFIX or what follows it is not a point name.

The collector reads arbitrary folder names from disk. Returning ``None`` for a name that is
not a point folder lets it continue examining other folders and report the refusal in its
own vocabulary.

pyflightstream.workspace.naming.free_matrix_archive

free_matrix_archive(
    base: Path, stem: str, name: str, stamp: str
) -> Path

Return the free archive path of a matrix file: post/<stem>/archive/<stamp>/<name>.

Parameters:

Name Type Description Default
base Path

The workspace root.

required
stem str

The matrix stem.

required
name str

The file's name.

required
stamp str

The archive stamp, :data:ARCHIVE_STAMP applied to the moment of the copy.

required

Returns:

Type Description
Path

A path no file holds yet; a second copy within one stamp goes under <stamp>.2, <stamp>.3.

pyflightstream.workspace.naming.free_root_archive

free_root_archive(
    base: Path, name: str, stamp: str
) -> Path

Return the free archive path of a root file: archive/<stem>-<stamp>.json.

A second copy within one stamp is numbered .2, .3. This is the ONE home of the spelling: run.records.restore reads what it names and every writer of a restorable file archives through it.

Parameters:

Name Type Description Default
base Path

The workspace root.

required
name str

The file's name; its stem names the copy.

required
stamp str

The archive stamp, :data:ARCHIVE_STAMP applied to the moment of the copy.

required

Returns:

Type Description
Path

A path no file holds yet.

pyflightstream.workspace.naming.group_token

group_token(group: str | int) -> str

Return what a product file carries for one group: its NAME, or gNN.

The one place the two eras are told apart, so the rename that moves existing products and the stage that writes new ones cannot drift into two conventions -- which is the drift a technical-writing lens flagged, since the migration page's whole promise is that the renamed file IS the file the next post writes.

Parameters:

Name Type Description Default
group str or int

The polar group: its name, or its number in a product written before names.

required

Returns:

Type Description
str

The name, or gNN for a number.

Raises:

Type Description
ProductError

If the group has no name, or its name has the shape of the numbered tokens it would be confused with.

pyflightstream.workspace.naming.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.workspace.naming.machine_description

machine_description() -> str | None

Describe the machine this process runs on, without naming it (NL-RECS-6).

The system, its release, the processor architecture and the count of logical processors: what a reader comparing the cost of two runs needs, and nothing that identifies the host. None where the platform states no system, the explicit unknown a record keeps.

Returns:

Type Description
str or None

For example "Windows 11 AMD64, 16 logical processors".

pyflightstream.workspace.naming.point_file_stem

point_file_stem(sim: str, name: PointName) -> str

Return the stem of every file of one point: P<sim>-<point name>.

Parameters:

Name Type Description Default
sim str

The simulation id.

required
name PointName

The point's name.

required

Returns:

Type Description
str

P<sim>-<name>.

pyflightstream.workspace.naming.resolve_manifest

resolve_manifest(
    root: str | Path, runs: str | None = None
) -> Path

Return the manifest file a command reads in the workspace root.

This rule (AD-09) lives in the workspace layer, because it names a file of the workspace root; :mod:pyflightstream.run.records re-exports it under its public name and :mod:pyflightstream.workspace.storage calls it without reaching into the run layer above it.

Parameters:

Name Type Description Default
root str or Path

The workspace root, the folder that holds runs.json.

required
runs str

The manifest's file name. None means runs.json. A name is a file directly in root: it must end in .json and carry no path separator, no drive and nothing that leaves the root.

None

Returns:

Type Description
Path

root / runs. Whether the file exists is not asked: a command that writes a new manifest resolves its name here too.

Raises:

Type Description
RunsManifestError

When runs is empty, carries a separator or a drive, does not end in .json, has no name before .json, or resolves outside root.

pyflightstream.workspace.naming.sim_dir_name

sim_dir_name(sim_id: str) -> str

Render the managed simulation folder.

Parameters:

Name Type Description Default
sim_id str

Letters, digits, underscore or hyphen, starting with a letter or digit.

required

Returns:

Type Description
str

The portable sim_<id> folder name.

Raises:

Type Description
NamingTemplateError

If sim_id is empty or contains characters outside the portable alphabet.

pyflightstream.workspace.naming.sim_id_of_folder

sim_id_of_folder(folder: str) -> str | None

Read a structural simulation folder, returning None for other names.

Parameters:

Name Type Description Default
folder str

One folder name, without parent paths.

required

Returns:

Type Description
str or None

The simulation identifier if the renderer reproduces this folder.

pyflightstream.workspace.naming.submitted_by

submitted_by() -> str | None

Return the operator running this process, or None if the host names nobody.

identify the user who ran, transparently for Linux and Windows. One call, not a pair of sys.platform branches, which would be two paths that drift.

IT LIVES HERE AND NOT BESIDE THE PRODUCTS because run captures it and post writes it, and post imports workspace rather than the reverse. Putting it beside the products would have inverted the dependency direction, which is a design error rather than a lint finding.

IT RETURNS None AND NOT NA. The product layer spells the absence, because the token belongs to the CSV and provenance surface and this function is below it. A host that cannot say who is running is a real path rather than a defensive one: a batch submission with a scrubbed environment and no password entry reaches it, and inventing a name there would put a false claim into the one artifact whose purpose is to be believed.

Returns:

Type Description
str or None

The operator's name, or None when the host names nobody.

pyflightstream.workspace.naming.sweep_file_stem

sweep_file_stem(
    sim: str, sweep: str, *, prefix: str = POINT_FILE_PREFIX
) -> str

Return the stem of a file about a whole sweep: P<sim>-<sweep> or SUPER-<sim>-....

Parameters:

Name Type Description Default
sim str

The simulation id.

required
sweep str

The sweep's name.

required
prefix str

P for a sweep file, SUPER- for a super file.

POINT_FILE_PREFIX

Returns:

Type Description
str

<prefix><sim>-<sweep>.