Skip to content

require_jupyter_kernel_gateway_installed

autogen.coding.jupyter.import_utils.require_jupyter_kernel_gateway_installed #

require_jupyter_kernel_gateway_installed()

Decorator that checks if jupyter-kernel-gateway is installed before function execution.

RETURNS DESCRIPTION
Callable[[T], T]

Callable[[T], T]: A decorator function that either: - Returns the original function unchanged if jupyter-kernel-gateway is installed - Returns a patched version of the function that will raise a helpful error indicating the missing dependency when called

Source code in autogen/coding/jupyter/import_utils.py
def require_jupyter_kernel_gateway_installed() -> Callable[[T], T]:
    """Decorator that checks if jupyter-kernel-gateway is installed before function execution.

    Returns:
        Callable[[T], T]: A decorator function that either:
            - Returns the original function unchanged if jupyter-kernel-gateway is installed
            - Returns a patched version of the function that will raise a helpful error indicating the missing dependency when called
    """
    if is_jupyter_kernel_gateway_installed():

        def decorator(o: T) -> T:
            return o

    else:

        def decorator(o: T) -> T:
            return patch_object(o, missing_modules={}, dep_target="jupyter-executor")

    return decorator