dbx_patch.patches.wsfs_import_hook_patch
source module dbx_patch.patches.wsfs_import_hook_patch
WsfsImportHook Patch for Editable Installs.
This module monkey-patches workspace import machinery to allow imports from editable install paths. Supports both legacy and modern Databricks runtimes:
- DBR < 18.0: Patches dbruntime.wsfs_import_hook.WsfsImportHook
- DBR >= 18.0: Patches dbruntime.workspace_import_machinery._WorkspacePathEntryFinder
The import hooks normally block imports that don't originate from
- site-packages
- /Workspace paths
- Whitelisted paths
This patch extends the whitelist to include editable install paths detected from .pth files and .egg-link files.
Classes
-
WsfsImportHookPatch — Patch for workspace import machinery.
source class WsfsImportHookPatch(verbose: bool = True)
Bases : BasePatch
Patch for workspace import machinery.
Patches the appropriate import hook based on runtime version to allow imports from editable install paths.
Initialize the patch (called only once due to singleton).
Parameters
-
verbose : bool — Enable verbose logging
Methods
-
patch — Apply the workspace import hook patch.
-
remove — Remove the patch and restore original workspace import hook behavior.
-
is_applied — Check if the workspace import hook patch is currently applied.
source method WsfsImportHookPatch.patch() → PatchResult
Apply the workspace import hook patch.
Automatically detects runtime version and applies appropriate patch.
Returns
-
PatchResult — PatchResult with operation details
source method WsfsImportHookPatch.remove() → bool
Remove the patch and restore original workspace import hook behavior.
Automatically detects which runtime version was patched and restores accordingly.
Returns
-
bool — True if unpatch was successful, False otherwise
source method WsfsImportHookPatch.is_applied() → bool
Check if the workspace import hook patch is currently applied.
Returns
-
bool — True if patched, False otherwise