Skip to content

Generalize patching to support vendoring#39

Merged
rapids-bot[bot] merged 16 commits intorapidsai:branch-24.06from
vyasr:feat/generalized_patching
Apr 4, 2024
Merged

Generalize patching to support vendoring#39
rapids-bot[bot] merged 16 commits intorapidsai:branch-24.06from
vyasr:feat/generalized_patching

Conversation

@vyasr
Copy link
Copy Markdown
Contributor

@vyasr vyasr commented Apr 4, 2024

This PR makes a number of significant changes to the patching infrastructure:

  1. This PR reorganizes the patching logic to be based on a more principled approach. Rather than maintaining lists of patch functions that are each responsible for filtering modules to apply themselves to, patches are organized in the patches directory in a tree structure matching dask itself. Patches are found and run by importing the same relative paths within the patches directory corresponding to a particular dask or distributed module.
  2. It adds proper support for patching submodules. Previously the loader was being disabled whenever a real dask module was being imported, but this is problematic because if some dask modules import others they will pre-populate sys.modules with the real modules and therefore the loader will never be used for loading a patched version of the submodule.
  3. Patches are no longer just functions applied to modules, they are arbitrary functions executed when a module is imported. As a result, a wider range of modifications is possible than was previously allowed. In particular:
  4. The more general functions allow the entire module import to be hijacked and redirected to other modules.
  5. The new framework is used to vendor a patched version of the accessor.py module in dask, which resolves the issues observed in Fix dask.dataframe import error for Python 3.11.9 dask/dask#11035.

@vyasr vyasr added feature request New feature or request non-breaking Introduces a non-breaking change labels Apr 4, 2024
@vyasr vyasr self-assigned this Apr 4, 2024
@vyasr vyasr requested a review from a team as a code owner April 4, 2024 19:36
@vyasr
Copy link
Copy Markdown
Contributor Author

vyasr commented Apr 4, 2024

For posterity, this is a redo of #38 because that PR was merged without squashing.

Copy link
Copy Markdown
Member

@rjzamora rjzamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rjzamora
Copy link
Copy Markdown
Member

rjzamora commented Apr 4, 2024

/merge

@rapids-bot rapids-bot bot merged commit a529757 into rapidsai:branch-24.06 Apr 4, 2024
vyasr added a commit to vyasr/rapids-dask-dependency that referenced this pull request Apr 4, 2024
This PR makes a number of significant changes to the patching infrastructure:
1. This PR reorganizes the patching logic to be based on a more principled approach. Rather than maintaining lists of patch functions that are each responsible for filtering modules to apply themselves to, patches are organized in the patches directory in a tree structure matching dask itself. Patches are found and run by importing the same relative paths within the `patches` directory corresponding to a particular dask or distributed module.
2. It adds proper support for patching submodules. Previously the loader was being disabled whenever a real dask module was being imported, but this is problematic because if some dask modules import others they will pre-populate `sys.modules` with the real modules and therefore the loader will never be used for loading a patched version of the submodule.
3. Patches are no longer just functions applied to modules, they are arbitrary functions executed when a module is imported. As a result, a wider range of modifications is possible than was previously allowed. In particular:
4. The more general functions allow the entire module import to be hijacked and redirected to other modules.
5. The new framework is used to vendor a patched version of the accessor.py module in dask, which resolves the issues observed in dask/dask#11035.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Richard (Rick) Zamora (https://github.com/rjzamora)

URL: rapidsai#39
@vyasr vyasr deleted the feat/generalized_patching branch April 4, 2024 20:19
raydouglass pushed a commit that referenced this pull request Apr 5, 2024
This PR backports #27, #37, and #39 to 24.04

---------

Signed-off-by: Vyas Ramasubramani <vyasr@nvidia.com>
Co-authored-by: Richard (Rick) Zamora <rzamora217@gmail.com>
Co-authored-by: Bradley Dice <bdice@bradleydice.com>
rjzamora added a commit to rjzamora/rapids-dask-dependency that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants