nodify.context.temporal_context
- nodify.context.temporal_context(context: dict | ChainMap | None = None, **context_keys: Any)[source]
Sets a context temporarily (until the context manager is exited).
- Parameters:
context (dict or ChainMap, optional) –
The context that should be updated temporarily. This could for example be the main context or the context of a specific node class.
If None, the keys and values are forced on all nodes.
**context_keys (Any) – The keys and values that should be used for the nodes context.
Examples
Forcing a certain context on all nodes:
>>> from nodes import temporal_context >>> with temporal_context(lazy=False): >>> # If a node class is called here, the computation will be performed >>> # immediately and the result returned.
Switching off lazy behavior for workflows:
>>> from nodes import Workflow, temporal_context >>> with temporal_context(context=Workflow.context, lazy=False): >>> # If a workflow is called here, the computation will be performed >>> # immediately and the result returned, unless that specific workflow >>> # class overwrites the lazy behavior.