Skip to content

pyflightstream.workspace.cli (stable)

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

The pyfs-workspace command line.

Every subcommand accepts --workspace PATH (PFS-2089.004), defaulting to the current directory. For example, pyfs-workspace init --workspace campaign creates the campaign tree there. init and migrate take the positional root, and naming two different folders is refused. archive SIM_ID --workspace ROOT names the campaign by --workspace alone; archive ROOT SIM_ID is refused.

Pipeline role: drives the managed campaign workspace from a terminal. pyfs-workspace init <root> creates the full campaign tree (the input-artifact library skeleton under inputs/, sims/, post/, and archive/) idempotently, so a campaign starts from the managed layout instead of hand-built folders; identity stays in the manifest, never in names (SAD Section 6).

pyfs-workspace archive <sim_id> --workspace <root> zips one manifest-recorded simulation under archive/ and removes its folder, through :meth:CampaignWorkspace.archive_sim. It exists because two refusals already told the user to run it (OPS-2009.01.10): the collection refusal of a name already in a point's own datapoints/ folder and the pre-run refusal of a declared output already in the simulation folder both say to archive the simulation and re-run, and in legacy releases the command they named was not there. The refusal of a simulation the manifest does not record is archive_sim's own, printed to stderr with exit 2.

pyfs-workspace migrate <root> previews migration from the record format; --apply backs up each rewritten file. See docs/upgrading.md.

pyfs-workspace field mirror|move|subtract|time-mean builds a custom free-stream file of inputs/freestreams/ out of other fields, through :mod:pyflightstream.workspace.fields: a field mirrored through a coordinate plane, moved so a source point lands on a target point, one field subtracted from another on the same grid (with a stated reference free stream), or the time mean of an unsteady run's per-step fields. Each previews by default and writes only with --apply into the workspace named by --workspace (the current directory by default), the file and its <stem>.provenance.json, and never overwrites without --overwrite; a refusal is printed to stderr with exit 2.

field fill-interior fills the interior probes (those inside the body radius --r-body, 0.38 m by default, take the value of the nearest probe outside it on the same azimuth ray) and, on field time-mean, --fluctuation (the per-probe population standard deviation of the averaged steps, written beside the mean as <stem>.fluctuation.csv and named in its provenance) and --fluctuation-only --last K (that report alone, no field).

pyfs-workspace excel create|preview|apply|cancel|check creates the macro-free matrix workbook and synchronises a saved one through :mod:pyflightstream.workspace.excel, whose module form python -m pyflightstream.workspace.excel is the same command.

pyfs-workspace profile sections|uni|bp prepares (FR-347) the radial thrust profile of an actuator disc a row's PROFILE names, written into inputs/profiles/<stem>.csv with its provenance record through :mod:pyflightstream.workspace.actuator_profiles: from a POL's written sections, or as the uniform or the Betz-Prandtl shape, scaled to a thrust or a CT. It previews and applies as the field operations do, and refuses an option of another shape rather than leave it unread.

The CLI reads the workspace settings files pyfs.toml and pyfs.local.toml through :mod:pyflightstream.workspace._settings_file, which owns their schema, the precedence and the provenance: this program takes their [log] console level only (FR-1000). The command-line side of the same files lives here too, because the parsing of a command line stays in the command families (FR-1002): :func:withhold_defaults and :func:take_settings adapt an argparse parser so that an option the command line does not state takes its default from the files, and pyfs-matrix parses through them.

Used in the guides

pyflightstream.workspace.cli.main

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

Run pyfs-workspace; returns the process exit code.

Parameters:

Name Type Description Default
argv list of str

The command-line arguments, sys.argv[1:] by default.

None

Returns:

Type Description
int

The process exit code of the subcommand that ran.

Advanced

pyflightstream.workspace.cli.WITHHELD module-attribute

WITHHELD = _Withheld()

pyflightstream.workspace.cli.add_console_arguments

add_console_arguments(
    parser: ArgumentParser, verbose_help: str
) -> None

Add --verbose and --log-level (FR-997), one choice of the console level.

Shared by pyfs-matrix and pyfs-workspace: a level typed on the command line wins over the [log] console of pyfs.local.toml and pyfs.toml.

Parameters:

Name Type Description Default
parser ArgumentParser

The parser of one command.

required
verbose_help str

The help of --verbose for that command.

required

pyflightstream.workspace.cli.fill_from_settings

fill_from_settings(
    parser: ArgumentParser,
    args: Namespace,
    held: _Held,
    settings: WorkspaceSettings,
) -> TakenDefaults

Give every option the command line did not state the value the files decide.

What was typed and what was left open is read off the parse; which file answers is decided by :func:~pyflightstream.workspace._settings_file.take_defaults; an option no file answers for gets its package default back, required where it was required.

Parameters:

Name Type Description Default
parser ArgumentParser

The program's parser, as :func:withhold_defaults left it.

required
args Namespace

The parsed command line, changed in place.

required
held _Held

What :func:withhold_defaults yielded.

required
settings WorkspaceSettings

The workspace's settings files, read.

required

Returns:

Type Description
TakenDefaults

What the command took from the files.

pyflightstream.workspace.cli.register_command_group

register_command_group(
    name: str,
    add: Callable[[Any], None],
    handler: Callable[[Namespace], int],
) -> None

Register a command group of pyfs-workspace that a higher layer defines.

Parameters:

Name Type Description Default
name str

The subcommand, such as fsi.

required
add callable

Adds the group's parser to the subparsers it is given.

required
handler callable

Runs the parsed command and returns its exit code.

required

pyflightstream.workspace.cli.take_settings

take_settings(
    parser: ArgumentParser, args: Namespace, held: _Held
) -> None

Take what a parsed command line did not state from its workspace's files (FR-436).

An option typed wins over pyfs.local.toml, which wins over pyfs.toml, which wins over the package default, and a workspace holding neither file parses exactly as before. A file the reader refuses stops the command here, exit 2, before its console opens and before anything is written. What was taken holds for the rest of the invocation.

Parameters:

Name Type Description Default
parser ArgumentParser

The program's parser, as :func:withhold_defaults left it.

required
args Namespace

The command line parsed inside :func:withhold_defaults, changed in place.

required
held _Held

What :func:withhold_defaults yielded.

required

pyflightstream.workspace.cli.typed_value

typed_value(args: Namespace, flag: str) -> object

Return the value of flag where the command line typed it, else None (FR-993).

A value a workspace settings file supplied is not the command line's: a command that judges what was asked of it judges the typed value alone, and leaves unused a file's value it does not use.

Parameters:

Name Type Description Default
args Namespace

The parsed command line, as :func:take_settings left it.

required
flag str

The long option, --fs-exe for instance.

required

Returns:

Type Description
object

The option's value, or None where a settings file supplied it.

pyflightstream.workspace.cli.withhold_defaults

withhold_defaults(
    parser: ArgumentParser, argv: Sequence[str] | None
) -> Iterator[_Held]

Hold the defaults of every settable option back for the length of one parse.

Inside, each settable option of each subcommand defaults to :data:WITHHELD, so an option still holding it after the parse was not typed; a REQUIRED option a settings file of the workspace argv names supplies stops being required at the parse, and is required again by :func:fill_from_settings if no file answers for it after all. The parser's own defaults are put back on the way out, whatever happened inside, so the parser a reader inspects (--help, the generated command-line reference) shows the package's defaults.

Abbreviated options are refused for the length of the parse: the settings are read from the folder an exact --workspace names, so an abbreviation argparse would expand (--works PATH) would parse to one workspace while the settings came from another.

Parameters:

Name Type Description Default
parser ArgumentParser

The program's parser, whose subcommands are walked.

required
argv sequence of str or None

The command line about to be parsed; None reads sys.argv.

required

Yields:

Type Description
_Held

What :func:fill_from_settings needs to restore a default nobody stated.