selection
lacuna.batch.selection
¶
Batch strategy selection based on analysis class attribute.
This module provides simple dispatch to the appropriate batch processing strategy based on the analysis.batch_strategy class attribute.
get_available_cores()
¶
Get the number of CPU cores available to this process.
Returns:
| Type | Description |
|---|---|
int
|
Number of available cores |
Source code in src/lacuna/batch/selection.py
select_strategy(analysis, n_subjects, n_jobs=-1, force_strategy=None, backend='loky', lesion_batch_size=None, batch_result_callback=None)
¶
Select batch processing strategy based on analysis.batch_strategy attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analysis
|
BaseAnalysis
|
Analysis instance to be executed |
required |
n_subjects
|
int
|
Number of subjects to process (currently unused, reserved for future) |
required |
n_jobs
|
int
|
Number of parallel jobs requested |
-1
|
force_strategy
|
str or None
|
Override automatic selection. Options: - "parallel": Force parallel processing - "vectorized": Force vectorized processing |
None
|
backend
|
str
|
Joblib backend for parallel processing: - 'loky': Robust multiprocessing (best for standalone scripts) - 'threading': Thread-based (use in Jupyter notebooks) - 'multiprocessing': Standard multiprocessing |
'loky'
|
lesion_batch_size
|
int or None
|
For vectorized strategy: number of lesions to process together. |
None
|
batch_result_callback
|
callable or None
|
Callback function called after each batch is processed. |
None
|
Returns:
| Type | Description |
|---|---|
BatchStrategy
|
Instantiated strategy ready for execution |
Raises:
| Type | Description |
|---|---|
ValueError
|
If force_strategy is invalid |