context๏
This module manages shared runtime context across different parts of an application. It tracks session-specific data, caller identification (e.g., Jupyter, scripts), and allows for runtime library path registration. It supports reproducibility, logging, and analysis by preserving contextual metadata during execution.
- get_caller()[source]๏
Identify the current session or script origin. Returns a string like โjupyter_session:<id>โ or โscript:<filename>โ.
- Return type:
str
Retrieve the shared data dictionary associated with the current context.
- Returns:
A dictionary that holds all shared data for the current context/session.
- Return type:
dict
- register_libs_path(libs_dir)[source]๏
Add a local library directory to Pythonโs sys.path if it exists.
Useful for loading local modules dynamically without installing them system-wide.
- Parameters:
libs_dir (str) โ The path to the directory containing the libraries.
- Raises:
ValueError โ If the given path does not point to a valid directory.
- Return type:
None
Set the shared data dictionary for the current context.
- Parameters:
data (dict) โ The context data to store. If not a dictionary, only โlogidโ is saved.
logid (str) โ A string identifier used for logging or session tracking.
- Returns:
The updated context dictionary.
- Return type:
dict