Skip to content

pyflightstream.options (stable)

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

Runtime options registry: the package's declared, validated knobs.

Pipeline role: cross-cutting support module (imports nothing from the pipeline; any layer may consume it). Machine-dependent and quality-assurance knobs (scratch roots, solver timeouts) live here as registered options instead of scattered literals, following the pandas register_option model: every option is declared once with a default, a docstring, and a validator, and every access goes through :func:get_option / :func:set_option.

Three deliberate differences from pandas:

  • Keys are exact, never pattern-matched: get_option("qa.probe") does not resolve qa.probe_timeout_s. Partial matching makes every new key a potential silent behavior change of existing code.
  • The registry refuses unknown keys with the full known-key list (openmdao message contract: the error names the option, the value, and what would have been accepted).
  • :func:describe_option returns the text instead of printing it; use print(describe_option()) at the REPL.

The options serve programmatic drivers of the package (scripts, notebooks, campaign code calling the qa entry points); a terminal user of the CLIs tunes the same quantities per invocation through the command-line flags whose defaults read from here.

Examples:

>>> from pyflightstream import options
>>> options.get_option("qa.probe_timeout_s")
120.0
>>> options.set_option("qa.probe_timeout_s", 60.0)
>>> with options.option_context("qa.scratch_root", "D:/scratch"):
...     pass  # runs launched here scratch under D:/scratch
>>> options.reset_option("qa.probe_timeout_s")

Options are process-wide state: they configure the machine the process runs on (where scratch goes, how long a solver may take), never the physics of a case. Anything that changes a result belongs in the case definition or the workspace, where it is recorded by the manifest.

Used in the guides

pyflightstream.options.get_option

get_option(key: str) -> Any

Return the current value of one option (exact key).

Parameters:

Name Type Description Default
key str

Exact dotted key of a registered option.

required

Returns:

Type Description
object

The value set by the latest :func:set_option, else the registered default.

Raises:

Type Description
OptionError

If no option is registered under the exact key; the message lists every registered key.

Examples:

>>> from pyflightstream.options import get_option, option_context
>>> with option_context("warning_refusals", True):
...     get_option("warning_refusals")
True

pyflightstream.options.option_context

option_context(*pairs: Any) -> Iterator[None]

Set options inside a with block, restoring them on exit.

Parameters:

Name Type Description Default
*pairs object

Alternating key and value arguments, pandas style: option_context("qa.probe_timeout_s", 10.0, ...).

()

Yields:

Type Description
None

Control returns to the with block with the options set; they are restored on exit.

Raises:

Type Description
OptionError

Unknown key or refused value, before anything is changed.

Examples:

>>> from pyflightstream.options import get_option, option_context
>>> previous = get_option("warning_refusals")
>>> with option_context("warning_refusals", True):
...     assert get_option("warning_refusals") is True
>>> get_option("warning_refusals") == previous
True

Advanced

pyflightstream.options.OptionError

Bases: PyflightstreamError, KeyError

An option key is unknown, or a value fails its validator.

Raised with the didactic message contract of the module: unknown keys list every registered key; rejected values name the option, the received value, and the accepted form.

pyflightstream.options.RegisteredOption dataclass

RegisteredOption(
    key: str,
    default: Any,
    doc: str,
    validator: Callable[[Any], None] | None = None,
)

Declaration of one option: identity, default, doc, validator.

Attributes:

Name Type Description
key str

Exact dotted key, <area>.<name> (example: "qa.scratch_root").

default object

Value returned until :func:set_option overrides it.

doc str

One didactic sentence: what the knob does and its unit.

validator callable or None

Called with a candidate value; raises ValueError naming the accepted form when the value does not fit. None accepts anything.

pyflightstream.options.describe_option

describe_option(key: str | None = None) -> str

Render the declared options as readable text.

Parameters:

Name Type Description Default
key str

Exact key to describe; None describes every registered option, sorted by key.

None

Returns:

Type Description
str

One block per option: key, current value, default, and doc. Returned, not printed: print(describe_option()) at the REPL.

Raises:

Type Description
OptionError

If the given key is not registered; the message lists every registered key.

pyflightstream.options.non_empty_path_text

non_empty_path_text(value: Any) -> None

Accept a non-empty string or path-like filesystem path.

Parameters:

Name Type Description Default
value object

The value an option is being set to.

required

Raises:

Type Description
InputValueError

If the value is not a non-empty string or path; the registry reports it as an :class:OptionError.

pyflightstream.options.positive_seconds

positive_seconds(value: Any) -> None

Accept a strictly positive, finite real number of seconds.

Parameters:

Name Type Description Default
value object

The value an option is being set to.

required

Raises:

Type Description
InputValueError

If the value is not a strictly positive finite real number (NaN and infinity included, since nan <= 0 is False); the registry reports it as an :class:OptionError.

pyflightstream.options.register_option

register_option(
    key: str,
    *,
    default: Any,
    doc: str,
    validator: Callable[[Any], None] | None = None,
) -> None

Declare one option; every option is declared exactly once.

Parameters:

Name Type Description Default
key str

Exact dotted key, lowercase <area>.<name>.

required
default object

Value served until a set_option overrides it. Must itself satisfy the validator. Keyword-only, like doc: for a string-valued option the two would swap silently if passed positionally.

required
doc str

One didactic sentence (what the knob does, unit included); rendered by :func:describe_option.

required
validator callable

Raises ValueError for unacceptable values.

None

Raises:

Type Description
OptionError

If the key is already registered (a second registration would silently rebind existing readers) or the default fails its own validator.

pyflightstream.options.reset_option

reset_option(key: str) -> None

Return one option to its registered default (exact key).

Parameters:

Name Type Description Default
key str

The option's exact registered key.

required

Raises:

Type Description
OptionError

If no option is registered under the exact key; the message lists every registered key.

pyflightstream.options.set_option

set_option(key: str, value: Any) -> None

Set one option after validation (exact key).

Parameters:

Name Type Description Default
key str

Exact dotted key of a registered option.

required
value object

New value; checked by the option's validator first.

required

Raises:

Type Description
OptionError

Unknown key, or a value the validator refuses; the message names the option, the received value, and the accepted form.