task: module CLI patching methods#319
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a user-facing CLI for enabling/disabling mkl_fft’s NumPy FFT patch, aiming to support both persistent patching (python -m mkl_fft patch ...) and one-shot execution (python -m mkl_fft with_patch ...) alongside updated README guidance.
Changes:
- Introduces
python -m mkl_fft patch install|uninstall|statusfor persistent patch management via a.pthfile. - Introduces
python -m mkl_fft with_patch <command> ...intended to run a single command with temporary patching. - Adds README documentation and unit tests for the persistent patch helper functions.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents persistent patching, one-shot execution, and programmatic patch APIs. |
| mkl_fft/main.py | Adds python -m mkl_fft ... dispatcher for patch and with_patch subcommands. |
| mkl_fft/patch.py | Implements persistent patch install/uninstall/status via writing/removing a .pth file. |
| mkl_fft/with_patch.py | Implements “one-shot” patch execution by spawning a subprocess with modified environment. |
| mkl_fft/tests/test_cli.py | Adds tests for install_patch, uninstall_patch, and check_status using a mocked .pth path. |
f73757a to
15c3ebb
Compare
|
@antonwolfy @ndgrigorian ready for review, I'll open this for the other 2 mkl packages once this gets merged. Tried to get thorough CLI testing added to the meta.yaml, but conda seems to do something weird with the PYTHONPATH while running the tests so I had to run a lot of integration tests by hand |
| --- | ||
| # Patching Mechanisms | ||
|
|
||
| `mkl_fft` provides convenient ways to enable MKL-accelerated FFT operations in NumPy with or without modifying your code. It supports both persistent patching (applies to all Python sessions) and one-shot execution (applies only to a single command). It also supports Python functions and context managers that do the same. |
There was a problem hiding this comment.
| `mkl_fft` provides convenient ways to enable MKL-accelerated FFT operations in NumPy with or without modifying your code. It supports both persistent patching (applies to all Python sessions) and one-shot execution (applies only to a single command). It also supports Python functions and context managers that do the same. | |
| `mkl_fft` provides patches to enable MKL-accelerated FFT operations in NumPy with or without modifying your code. It supports both persistent patching (applies to all Python sessions) and one-shot execution (applies only to a single command). It also supports Python functions and context managers that do the same. |
| import tempfile | ||
|
|
||
|
|
||
| def run_with_patch(args): |
There was a problem hiding this comment.
I think we should rename "with_patch" in general to "patch_numpy" in case we for some reason, were to someday want to patch other libraries (e.g., SciPy)
95f2531 to
d4ed6b9
Compare
7c17a7f to
808ae9d
Compare
adds
python -m mkl_fft patch install/uninstall/statusmethods, and alsopython -m mkl_fft with_patchConvenience CLI functions that will make it way easier to let users have automagic mkl_fft optimizations in their workflows, such as if they want to run npbench suites but with mkl_fft optimizations.
Tested locally pretty exhaustively, everything worked pretty well. A lot of documentation is claude code and it was way too verbose. I deleted and edited a lot of it, but please take a look at it all and make sure it's correct.
If this gets merged, I'll do the same for mkl_random and mkl_umath