pype.process¶
- class pype.process.DockerConfig(exec_path, runtime, cache_dir=None)[source]¶
Bases:
object
Configuration for Docker and container runtime environments.
This class manages container runtime configuration and provides properties to identify the runtime type (Docker, Singularity, uDocker).
- Attributes:
exec_path: Path to the container runtime executable runtime: Name of the container runtime (‘docker’, ‘singularity’, ‘udocker’) cache_dir: Optional cache directory, required for Singularity containers
- class pype.process.Volume(path, output=False, bind_prefix='/var/lib/pype')[source]¶
Bases:
object
Volume binding configuration for containerized environments.
Handles the mounting of files and directories between host and container environments, managing read-only and read-write access modes.
- Attributes:
path: Path to the file or directory on the host system output: If True, mount as read-write; if False, mount as read-only bind_prefix: Base path in the container where volumes will be mounted
- class pype.process.Command(cmd, log, profile, name='')[source]¶
Bases:
object
High-level interface for executing commands with container support.
This class provides a unified interface for running commands locally or within containers (Docker, Singularity, uDocker). It handles: - Command execution and piping - Volume mounting and file access - Container runtime configuration - Environment modules integration - Input/output file tracking
- Attributes:
cmd: Command to execute as list of arguments name: Identifier for the command (used in logs) profile: Configuration profile for the environment log: Logger instance for command execution tracking docker: Container runtime configuration inputs: List of input files required by the command outputs: List of output files produced by the command volumes: List of volumes to mount in container environments
- __init__(cmd, log, profile, name='')[source]¶
Initialize command execution environment.
- Args:
cmd: Command string to execute log: Logger instance for command output profile: Environment profile configuration name: Optional identifier for the command
- add_output(out_file)[source]¶
Add output file to track.
- Parameters:
out_file (str)
- Return type:
None
- run(local_script=False)[source]¶
Execute the command.
- Parameters:
local_script (bool)
- Return type:
None
- docker_run(local_script)[source]¶
Execute command within a container environment.
Handles the complexities of running commands in containers including: - Volume mounting and path translation - User permissions - Working directory setup - Container-specific command modifications
- Args:
- local_script: If True, indicates the command is a local script that
needs to be mounted in the container
- Parameters:
local_script (bool)
- Return type:
None
- class pype.process.Namespace(program_dict, log, profile)[source]¶
Bases:
object
Environment and dependency management system.
Manages different execution environments (path-based, environment modules, containers) and their dependencies. Supports: - Path-based program execution - Environment modules loading - Container image specification - Dependency resolution
The namespace format is ‘type@item’ where: - type: One of ‘path’, ‘env_module’, or ‘docker’ - item: The specific program/container/module to use
For example: - ‘docker@ubuntu:latest’ - ‘env_module@gcc/9.3.0’ - ‘path@/usr/local/bin/python’
- __init__(program_dict, log, profile)[source]¶
Initialize namespace configuration.
- Args:
- program_dict: Dictionary containing program configuration:
namespace: String in format ‘type@item’
version: Program version
dependencies: Optional list of dependent programs
log: Logger instance for namespace operations profile: Environment profile containing program configurations
- Raises:
CommandNamespaceError: For invalid namespace format or unsupported types