config_context

function of dascore.config source

config_context(
    new_config: dascore.config.DascoreConfig | None[DascoreConfig, None] = None,
    **kwargs ,
)-> ‘Iterator[DascoreConfig]’

Temporarily override the runtime config for the current thread/task.

Parameters

Parameter Description
new_config A complete DascoreConfig to install.
Mutually exclusive with keyword overrides.
**kwargs Individual field overrides applied on top of the active config.
Note

Overrides use a ContextVar and restore on exit. New OS threads inherit a copy according to sys.flags.thread_inherit_context (normally enabled on free-threaded builds); exiting this block does not restore inherited copies. For deterministic propagation, run workers with contextvars.copy_context() or use Spool.map.

Examples

import dascore as dc
with dc.config_context(debug=True):
    assert dc.get_config().debug
assert not dc.get_config().debug