pyiron_base.jobs.job.runfunction.execute_subprocess#
- pyiron_base.jobs.job.runfunction.execute_subprocess(executable: str, shell: bool, working_directory: str, cores: int = 1, threads: int = 1, gpus: int = 1, conda_environment_name: str | None = None, conda_environment_path: str | None = None) str[source]#
Execute a subprocess with the given parameters.
- Parameters:
executable (str) – The executable command to run.
shell (bool) – If True, the command will be executed through the shell.
working_directory (str) – The working directory for the subprocess.
cores (int, optional) – The number of CPU cores to allocate. Defaults to 1.
threads (int, optional) – The number of threads to allocate. Defaults to 1.
gpus (int, optional) – The number of GPUs to allocate. Defaults to 1.
conda_environment_name (str, optional) – The name of the conda environment to activate. Defaults to None.
conda_environment_path (str, optional) – The path to the conda environment to activate. Defaults to None.
- Returns:
The output of the subprocess.
- Return type:
str
- Raises:
subprocess.CalledProcessError – If the subprocess returns a non-zero exit status.
Note
If both conda_environment_name and conda_environment_path are None, the subprocess will be executed using subprocess.run.
If conda_environment_name is not None, the subprocess will be executed using conda_subprocess.run with the specified environment name.
If conda_environment_path is not None, the subprocess will be executed using conda_subprocess.run with the specified environment path.