Skip to content

is_mocked

laktory.dlt.is_mocked ยค

is_mocked()

DLT module mock flag. If True, native Databricks DLT functions are mocked to allow debugging by running a pipeline notebook against an arbitrary cluster even when the native DLT module is not available.

DLT is mocked in the following situations:

  • notebook ran outside a DLT pipeline and DBR < 13
  • notebook ran outside a DLT pipeline and DBR >= 13 with shared access mode cluster
RETURNS DESCRIPTION
bool

Mocked flag

Source code in laktory/dlt/__init__.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def is_mocked() -> bool:
    """
    DLT module mock flag. If `True`, native Databricks DLT functions are mocked
    to allow debugging by running a pipeline notebook against an arbitrary
    cluster even when the native DLT module is not available.

    DLT is mocked in the following situations:

    * notebook ran outside a DLT pipeline and DBR < 13
    * notebook ran outside a DLT pipeline and DBR >= 13 with shared access
    mode cluster

    Returns
    -------
    :
        Mocked flag
    """
    try:
        import dlt

        return False
    except Exception:
        return True