Skip to content

_get_fabric_runtime_context

Internal helper
This page documents an internal implementation helper, not a primary public API.

Return the Fabric notebook runtime context when available.

Fabric notebooks expose runtime metadata through notebookutils.runtime. This helper keeps that dependency optional so the module can still be imported in local tests or non-Fabric environments.

Returns:

Type Description
dict

Fabric runtime context when running inside Fabric. Returns an empty dictionary when the context is unavailable.

Source code in src/fabricops_kit/fabric_io.py
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
def _get_fabric_runtime_context():
    """Return the Fabric notebook runtime context when available.

    Fabric notebooks expose runtime metadata through `notebookutils.runtime`.
    This helper keeps that dependency optional so the module can still be
    imported in local tests or non-Fabric environments.

    Returns
    -------
    dict
        Fabric runtime context when running inside Fabric. Returns an empty
        dictionary when the context is unavailable.
    """
    try:
        from notebookutils import runtime

        return runtime.context
    except Exception:
        return {}