Commit 9a3158f
refactor: replace multiprocessing.Pool with ThreadPoolExecutor in process_single_position (#396)
* refactor: replace multiprocessing.Pool with ThreadPoolExecutor in process_single_position
The transform functions passed to process_single_position (numpy, scipy,
PyTorch, ANTsPy) all release the GIL, making threads sufficient for
parallelism. ThreadPoolExecutor avoids the overhead of spawn-based
multiprocessing (re-importing libraries, serializing arguments) and
plays better with Nextflow's per-task resource accounting.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: handle os.cpu_count() returning None and add threaded path test
Guard against os.cpu_count() returning None in containerized environments
by falling back to 1. Add test_process_single_position_threaded to
exercise the ThreadPoolExecutor code path with num_processes=2.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: deduplicate test_process_single_position and threaded variant
Extract shared logic into _run_process_single_position helper so the
threaded test delegates instead of duplicating the entire test body.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: inline helper and parameterize num_processes via hypothesis
Remove _run_process_single_position helper and merge the two test
functions into a single test_process_single_position that samples
num_processes from [1, 2].
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: rename num_processes to num_threads with deprecation shim
Add num_threads parameter to process_single_position and deprecate
num_processes. When num_processes is passed, a DeprecationWarning is
emitted and the value is forwarded to num_threads if num_threads is
smaller. Update tests to use num_threads.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9beb2a4 commit 9a3158f
2 files changed
Lines changed: 30 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
283 | 285 | | |
284 | 286 | | |
285 | 287 | | |
286 | | - | |
| 288 | + | |
| 289 | + | |
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
| |||
324 | 327 | | |
325 | 328 | | |
326 | 329 | | |
327 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
328 | 335 | | |
329 | 336 | | |
330 | 337 | | |
331 | 338 | | |
332 | 339 | | |
333 | 340 | | |
334 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
335 | 350 | | |
336 | 351 | | |
337 | 352 | | |
| |||
395 | 410 | | |
396 | 411 | | |
397 | 412 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
402 | 417 | | |
403 | 418 | | |
404 | 419 | | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
410 | 423 | | |
411 | | - | |
412 | | - | |
| 424 | + | |
| 425 | + | |
413 | 426 | | |
414 | 427 | | |
415 | 428 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| 726 | + | |
726 | 727 | | |
727 | 728 | | |
728 | | - | |
| 729 | + | |
729 | 730 | | |
730 | 731 | | |
731 | 732 | | |
| |||
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
742 | | - | |
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
753 | | - | |
754 | 753 | | |
755 | 754 | | |
756 | | - | |
757 | 755 | | |
758 | 756 | | |
759 | 757 | | |
760 | 758 | | |
761 | 759 | | |
762 | | - | |
763 | 760 | | |
764 | 761 | | |
765 | 762 | | |
| |||
768 | 765 | | |
769 | 766 | | |
770 | 767 | | |
| 768 | + | |
771 | 769 | | |
772 | 770 | | |
773 | 771 | | |
774 | | - | |
775 | 772 | | |
776 | 773 | | |
777 | 774 | | |
778 | 775 | | |
779 | 776 | | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | 777 | | |
784 | 778 | | |
785 | 779 | | |
| |||
0 commit comments