macroforecast.meta#
Purpose#
macroforecast.meta stores package-wide execution settings. These settings are
used when a run does not pass a more specific value through a direct function
argument. They do not choose data, preprocessing, features, models, evaluation
metrics, or output files.
The module is intentionally small. It owns defaults and temporary overrides; direct function arguments and runner policies always take precedence over global settings.
Public Functions#
Function |
Purpose |
|---|---|
|
Update one or more global execution settings. |
|
Return the full active configuration. |
|
Return one active configuration value. |
|
Resolve the configured worker count ( |
|
Restore package defaults. |
|
Temporarily override settings inside a |
Public Values#
Symbol |
Meaning |
|---|---|
|
Package default seed value, currently |
|
Dictionary-like output schema for active meta settings. |
|
Accepted worker-count type: positive integer or |
|
Stored failure-mode type: |
|
Runner stage-scope type: |
|
Runner metadata detail type: |
MetaConfig#
MetaConfig is the output schema returned by configure, get_config,
reset_config, and yielded by use_config.
Output Schema#
Key |
Type |
Default |
Meaning |
|---|---|---|---|
|
|
|
Seed used by stochastic functions when no run-specific seed is supplied. |
|
|
|
Default worker count. |
|
failure mode |
stop on error |
Default cell failure behavior. See Failure Mode Values. |
|
|
|
Default verbosity level for future logging surfaces. |
|
|
|
Default |
|
|
|
Default |
|
|
|
Default |
|
|
|
Runner metadata detail. |
The default seed is owned by macroforecast.meta.config.DEFAULT_RANDOM_SEED and
is exported as macroforecast.meta.DEFAULT_RANDOM_SEED.
Failure Mode Values#
User-facing mode |
Stored value |
Meaning |
|---|---|---|
Stop on error |
|
Stop immediately when a supported execution cell fails. |
Continue where supported |
|
Record the failure and continue for call sites that support non-fatal errors. |
Stage Scope Aliases#
Stage-scope inputs are normalized before storage. Docs and metadata use the canonical stored values.
Accepted input |
Stored value |
Meaning |
|---|---|---|
|
|
Fit the stage on the full panel. |
|
|
Fit the stage on observations available at each forecast origin. |
|
|
Fit the stage on the model fit window. |
Example output:
{
"random_seed": 42,
"n_jobs": 1,
"on_error": "raise",
"verbose": 0,
"default_preprocessing_scope": "origin_available",
"default_feature_scope": "fit_window",
"default_selection_scope": "fit_window",
"metadata_level": "standard",
}
configure#
Update package-wide execution settings and return the active configuration.
Signature#
macroforecast.meta.configure(
*,
random_seed: int | None = ...,
n_jobs: int | "auto" = ...,
on_error: str = ...,
verbose: int = ...,
default_preprocessing_scope: "full_panel" | "origin_available" | "fit_window" = ...,
default_feature_scope: "full_panel" | "origin_available" | "fit_window" = ...,
default_selection_scope: "full_panel" | "origin_available" | "fit_window" = ...,
metadata_level: "minimal" | "standard" | "full" = ...,
) -> MetaConfig
All inputs are keyword-only. Omitted inputs keep their current values.
Input#
Name |
Type |
Default if omitted |
Allowed Values |
Meaning |
|---|---|---|---|---|
|
|
keep current value |
non-negative integer or |
Sets the default seed for stochastic components. |
|
|
keep current value |
positive integer or |
Sets the default worker count. |
|
failure mode |
keep current value |
Stop on error ( |
Sets default failure behavior. |
|
|
keep current value |
non-negative integer |
Sets default verbosity. |
|
str |
keep current value |
|
Sets the default preprocessing stage scope for |
|
str |
keep current value |
|
Sets the default feature-engineering stage scope. |
|
str |
keep current value |
|
Sets the default model-selection stage scope. |
|
str |
keep current value |
|
Sets the default runner metadata detail. |
Stage-scope inputs also accept the aliases listed in
Stage Scope Aliases. The returned MetaConfig always
stores the canonical value.
Output#
Returns MetaConfig, a copy of the full active configuration after the update.
Output |
Type |
Meaning |
|---|---|---|
|
|
The active package-wide execution settings. |
Side Effects#
configure changes global package state. Later calls that consult
macroforecast.meta will see the updated values.
Validation#
Condition |
Error |
|---|---|
|
|
|
|
|
|
|
|
|
|
stage default scope is not one of the allowed scopes |
|
|
|
Example#
import macroforecast as mf
config = mf.meta.configure(
random_seed=7,
n_jobs="auto",
on_error="continue",
default_feature_scope="origin_available",
metadata_level="standard",
verbose=1,
)
assert config["random_seed"] == 7
get_config#
Return the active package-wide execution settings.
Signature#
macroforecast.meta.get_config() -> MetaConfig
Input#
No input.
Output#
Returns MetaConfig.
Output |
Type |
Meaning |
|---|---|---|
|
|
Copy of the active package-wide execution settings. |
The returned object is a copy. Mutating it does not change global package state.
Example#
import macroforecast as mf
config = mf.meta.get_config()
print(config["n_jobs"])
get_option#
Return one active configuration value.
Signature#
macroforecast.meta.get_option(name: str) -> object
Input#
Name |
Type |
Allowed Values |
Meaning |
|---|---|---|---|
|
|
any |
Configuration key to read. |
Output#
Returns the value for name.
|
Output Type |
|---|---|
|
|
|
|
|
failure mode string |
|
|
|
|
|
|
|
|
|
|
Errors#
Condition |
Error |
|---|---|
|
|
Example#
import macroforecast as mf
seed = mf.meta.get_option("random_seed")
reset_config#
Restore package-wide execution settings to their defaults.
Signature#
macroforecast.meta.reset_config() -> MetaConfig
Input#
No input.
Output#
Returns MetaConfig after reset.
Key |
Reset Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Side Effects#
reset_config changes global package state.
Example#
import macroforecast as mf
mf.meta.configure(random_seed=123, n_jobs=4)
config = mf.meta.reset_config()
assert config["random_seed"] == 42
assert config["n_jobs"] == 1
use_config#
Temporarily override package-wide execution settings inside a context manager.
Signature#
macroforecast.meta.use_config(
*,
random_seed: int | None = ...,
n_jobs: int | "auto" = ...,
on_error: str = ...,
verbose: int = ...,
default_preprocessing_scope: "full_panel" | "origin_available" | "fit_window" = ...,
default_feature_scope: "full_panel" | "origin_available" | "fit_window" = ...,
default_selection_scope: "full_panel" | "origin_available" | "fit_window" = ...,
metadata_level: "minimal" | "standard" | "full" = ...,
) -> Iterator[MetaConfig]
Input#
The inputs match configure.
Name |
Type |
Default if omitted |
Allowed Values |
Meaning |
|---|---|---|---|---|
|
|
keep current value inside context |
non-negative integer or |
Temporary default seed. |
|
|
keep current value inside context |
positive integer or |
Temporary worker count. |
|
failure mode |
keep current value inside context |
Stop on error ( |
Temporary failure behavior. |
|
|
keep current value inside context |
non-negative integer |
Temporary verbosity. |
|
str |
keep current value inside context |
|
Temporary preprocessing default scope. |
|
str |
keep current value inside context |
|
Temporary feature default scope. |
|
str |
keep current value inside context |
|
Temporary model-selection default scope. |
|
str |
keep current value inside context |
|
Temporary metadata detail. |
Stage-scope inputs use the same alias normalization as configure.
Output#
Yields MetaConfig, the active configuration inside the context.
Output |
Type |
Meaning |
|---|---|---|
|
|
Active temporary settings inside the |
Side Effects#
use_config changes global package state only for the duration of the with
block. The previous configuration is restored when the block exits, including
when an exception is raised.
Example#
import macroforecast as mf
mf.meta.configure(random_seed=42)
with mf.meta.use_config(random_seed=7, n_jobs=2) as config:
assert config["random_seed"] == 7
# Run code here with the temporary settings.
assert mf.meta.get_option("random_seed") == 42
Usage Behavior#
Direct package functions can read macroforecast.meta when no more specific
value is provided by the caller.
Setting |
Use |
|---|---|
|
Used as the default run seed and propagated to stochastic estimators where supported. |
|
Used as the default worker count for run-level and selected model-level parallel work. |
|
Default failure handling. |
|
Reserved as the package-wide verbosity setting. |
|
Used by |
|
Used by |
|
Used by |
|
Controls how much run-level metadata is recorded. |
Forecast results record the active config under metadata["run"]["config"] so
a completed run can be audited against the settings in force at execution time.