Skip to content

dbx_patch.patches.autoreload_hook_patch

source module dbx_patch.patches.autoreload_hook_patch

AutoreloadDiscoverabilityHook Patch for Editable Installs.

This module patches the Databricks autoreload discoverability hook to allow imports from editable install paths. The autoreload hook wraps builtins.import and only allows imports from specific paths (like /Workspace). We need to add editable install paths to this allowlist.

Environment Variables

DBX_PATCH_DEBUG_IMPORTS: Set to '1', 'true', or 'yes' to enable extremely verbose import tracing by patching builtins.import. This logs every single import that happens in the Python process and should only be used for debugging import-related issues with editable installs.

Example

import os os.environ['DBX_PATCH_DEBUG_IMPORTS'] = '1' from dbx_patch import patch_dbx patch_dbx()

Classes

source class AutoreloadHookPatch(verbose: bool = True)

Bases : BasePatch

Patch for Databricks autoreload discoverability hook.

Registers editable install paths in the autoreload allowlist and optionally patches builtins.import for debug logging.

Initialize the patch.

Parameters

  • verbose : bool Enable verbose logging

Methods

  • patch Apply the autoreload hook patch.

  • remove Remove the patch and restore original autoreload hook behavior.

  • is_applied Check if the autoreload hook patch is currently applied.

source method AutoreloadHookPatch.patch()PatchResult

Apply the autoreload hook patch.

Returns

source method AutoreloadHookPatch.remove()bool

Remove the patch and restore original autoreload hook behavior.

Returns

  • bool True if unpatch was successful, False otherwise

source method AutoreloadHookPatch.is_applied()bool

Check if the autoreload hook patch is currently applied.

Returns

  • bool True if patched, False otherwise