conda_subprocess.decorator.CondaSpawner#

class conda_subprocess.decorator.CondaSpawner(cwd: str | None = None, cores: int = 1, openmpi_oversubscribe: bool = False, threads_per_core: int = 1, prefix_name: str | None = None, prefix_path: str | None = None)[source]#

Bases: SubprocessSpawner

executorlib SubprocessSpawner which starts the worker process with conda_subprocess.Popen() instead of the regular subprocess.Popen(), so the worker runs inside the conda environment selected by prefix_name/prefix_path.

Parameters:
  • cwd (str) – Working directory to start the worker process in.

  • cores (int) – Number of cores to use for the worker process.

  • openmpi_oversubscribe (bool) – Whether to oversubscribe the worker process.

  • threads_per_core (int) – Number of threads per core.

  • prefix_name (str) – Name of the conda environment the worker process should be executed in.

  • prefix_path (str) – Absolute path of the conda environment the worker process should be executed in.

__init__(cwd: str | None = None, cores: int = 1, openmpi_oversubscribe: bool = False, threads_per_core: int = 1, prefix_name: str | None = None, prefix_path: str | None = None)[source]#

Subprocess interface implementation.

Parameters:
  • cwd (str, optional) – The current working directory. Defaults to None.

  • cores (int, optional) – The number of cores to use. Defaults to 1.

  • threads_per_core (int, optional) – The number of threads per core. Defaults to 1.

  • worker_id (int) – The worker ID. Defaults to 0.

  • openmpi_oversubscribe (bool, optional) – Whether to oversubscribe the cores. Defaults to False.

Methods

__init__([cwd, cores, ...])

Subprocess interface implementation.

bootup(command_lst[, stop_function])

Method to start the subprocess interface.

generate_command(command_lst)

Method to generate the command list.

poll()

Method to check if the subprocess interface is running.

shutdown([wait])

Method to shutdown the subprocess interface.

bootup(command_lst: list[str], stop_function: Callable | None = None) → bool[source]#

Method to start the subprocess interface.

Parameters:
  • command_lst (list[str]) – The command list to execute.

  • stop_function (Callable) – Function to stop the interface.

Returns:

Whether the interface was successfully started.

Return type:

bool

generate_command(command_lst: list[str]) → list[str]#

Method to generate the command list.

Parameters:

command_lst (list[str]) – The command list.

Returns:

The generated command list.

Return type:

list[str]

poll() → bool#

Method to check if the subprocess interface is running.

Returns:

True if the interface is running, False otherwise.

Return type:

bool

shutdown(wait: bool = True)#

Method to shutdown the subprocess interface.

Parameters:

wait (bool, optional) – Whether to wait for the interface to shutdown. Defaults to True.