Skip to content

pyflightstream.post.input_template (provisional)

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

The input template, input_template.md: one section per kind of input file.

Written at the ROOT of a workspace's inputs folder: one section per kind of input file a user writes, the files of profiles/ among them, each with a complete example to copy. Every example is a file the package reads as it stands, which its test holds by writing each one where its title says and reading it with the reader the run uses; the matrix's header is the layout's registry, the values a comment lists are read from the registries that check them, and every key of the glossary's tables is either stated by an example or named on the page as left out, with the reason.

The sections are one data table, :data:_TEMPLATE_SECTIONS, in the page's order; the page is rendered from it by :func:input_template_markdown.

Size exemption: one data table of complete example files, each a literal the suite reads back. Its length is the examples' own text; a cut would part an example from its section.

Every public name is re-exported by :mod:pyflightstream.post.guides.

Advanced

pyflightstream.post.input_template.INPUT_TEMPLATE_NAME module-attribute

INPUT_TEMPLATE_NAME = 'input_template.md'

pyflightstream.post.input_template.TemplateExample dataclass

TemplateExample(
    path: str, language: str, text: str, note: str = ""
)

One example file of the input template.

Attributes:

Name Type Description
path str

Where the file goes, relative to the workspace root; the example block's title, so a reader copies it there and the suite writes it there before reading it back.

language str

The language of the block's fence: toml, text or csv.

text str

The file, ending in a newline.

note str

What to know about this file before copying it, above the block.

pyflightstream.post.input_template.TemplateSection dataclass

TemplateSection(
    heading: str,
    intro: str,
    examples: tuple[TemplateExample, ...],
    after: str = "",
    left_out: Mapping[
        str, Mapping[str, tuple[str, ...]]
    ] = MappingProxyType({}),
    pages: tuple[tuple[str, str], ...] = (),
)

One kind of input file on the input template.

Attributes:

Name Type Description
heading str

The section's heading; for the five artifacts the glossary covers, the glossary's own heading of that artifact.

intro str

What the file is for and where it lives.

examples tuple of TemplateExample

The files the section shows, each complete and valid as it stands.

after str

What the examples do not say by themselves, below them.

left_out mapping

By the glossary's heading of a table, each reason to the keys of that table the examples leave out; an empty tuple of keys stands for every key of the table. It is written on the page, and the template's test holds that every key of every table is shown or named here.

pages tuple of (str, str)

The documentation pages the section links, as (name, title): docs/<name>.md.

pyflightstream.post.input_template.input_template_markdown

input_template_markdown() -> str

Return the input template, input_template.md, as Markdown.

One section per kind of input file a user writes, each with what the file is for, where it lives and a complete example: the run matrix, the setup, the pproc, the reference, the named points, the geometry sidecar and the trailing-edge points file beside it, the provenance record, the actuator profile and the probe survey of profiles/, the custom free stream, the HPC profile and the build registry with its overlay. Each example is a file the package reads as it stands, and the keys an example leaves out are named with the reason. Generated on every call.

Returns:

Type Description
str

The Markdown page, ending with a newline.

Examples:

>>> text = input_template_markdown()
>>> text.splitlines()[0]
'# Input templates'
>>> 'title="inputs/setups/s001.toml"' in text
True

pyflightstream.post.input_template.write_input_template

write_input_template(
    folder: str | Path,
    *,
    changed: list[Path] | None = None,
    overwrite: bool = True,
) -> Path

Write the input template, input_template.md, into folder; return its path.

Rewritten only when its content would change, so the call is idempotent and leaves a versioned workspace clean.

Parameters:

Name Type Description Default
folder str or Path

Where to write it: the inputs folder of a workspace. Created if it is not there.

required
changed list

Receives the page when this call actually wrote it.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path

The page, written or not.

Examples:

>>> import tempfile
>>> folder = tempfile.mkdtemp()
>>> first: list = []
>>> write_input_template(folder, changed=first).name
'input_template.md'
>>> again: list = []
>>> _ = write_input_template(folder, changed=again)
>>> len(first), len(again)
(1, 0)

pyflightstream.post.input_template.write_workspace_input_template

write_workspace_input_template(
    inputs_dir: str | Path, *, overwrite: bool = True
) -> list[Path]

Write input_template.md at the root of inputs_dir; return it if it CHANGED.

The input-guide writer this package registers with :func:pyflightstream.workspace.register_input_guide beside the glossary, which is how pyfs-workspace init, pyfs-matrix plan and pyfs-matrix post reach it.

Parameters:

Name Type Description Default
inputs_dir str or Path

The workspace's inputs root; created if absent.

required
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
list of pathlib.Path

The page when this call wrote it, otherwise an empty list.