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

get_shared_data()[source]๏ƒ

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_shared_data(data, logid=None)[source]๏ƒ

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