mlmc.sampling_pool.ProcessPool

class mlmc.sampling_pool.ProcessPool(n_processes, work_dir=None, debug=False)[source]

Sampling pool using multiprocessing for parallel sample execution. Suitable for simulations without external program calls.

__init__(n_processes, work_dir=None, debug=False)[source]

Initialize process-based parallel sampling pool.

Parameters

n_processesint

Number of worker processes to use.

work_dirstr, optional

Working directory for samples.

debugbool, default=False

If True, disables moving/removing sample outputs.

Methods

__init__(n_processes[, work_dir, debug])

Initialize process-based parallel sampling pool.

calculate_sample(sample_id, level_sim[, ...])

Execute a single simulation sample.

change_to_sample_directory(work_dir, path)

Create and switch to the sample-specific directory.

compute_seed(sample_id)

Compute a deterministic seed for a given sample ID.

copy_sim_files(files, sample_dir)

Copy shared simulation files to the sample directory.

get_finished()

Retrieve all completed (successful and failed) samples.

handle_sim_files(work_dir, sample_id, level_sim)

Prepare the sample workspace (create directory, copy common files, set cwd).

have_permanent_samples(sample_ids)

Return False, indicating that no samples are stored permanently.

move_dir(sample_id, sample_workspace, ...)

Move a sample directory to another location (e.g., failed or successful).

move_failed_rm(sample_id, level_sim, ...)

Move failed sample directories and remove originals.

move_successful_rm(sample_id, level_sim, ...)

Move successful sample directories and remove originals.

remove_sample_dir(sample_id, ...)

Remove the directory for a completed or failed sample.

res_callback(result, level_sim)

Callback for handling results from asynchronous execution.

schedule_sample(sample_id, level_sim)

Schedule a sample for parallel execution in a separate process.

Attributes

FAILED_DIR

N_SUCCESSFUL

SEVERAL_SUCCESSFUL_DIR