Public Python API¶
Generated from the reviewed core sources using scripts/update_reference.py. Builds consume this checked-in reference and do not import or discover plugins. Version and tag provenance are recorded in the version matrix.
This reference describes core 0.25.0 in the bundle 0.26.0 component set.
Use plugin contracts to obtain tool configurations and workflows. Call submit_workflow for backend-aware execution; direct workflow calls are intended for tests and custom inline execution. See the first workflow.
Dataset.from_file() currently raises NotImplementedError. A frozen dataclass prevents field reassignment; it does not make nested molecule objects or lists immutable.
caddforge.config.base¶
BaseConfig¶
Declared fields and enum values (inherited fields are documented on the base class):
run_directory: Path | None = None
registry_path: Path | None = None
backend: str = 'local'
distribution: DistributionConfig = Field(default_factory=DistributionConfig)
slurm_partition: str | None = None
slurm_python_executable: str | None = None
slurm_time: str | None = None
slurm_account: str | None = None
sbatch_options: list[str] = Field(default_factory=list)
slurm_setup_commands: list[str] = Field(default_factory=list)
job_name: str | None = None
export_results: bool = False
progress_update_interval_seconds: float = Field(5, gt=0, description='Minimum interval between measured stage reports.')
heartbeat_interval_seconds: float = Field(30, gt=0, description='Quiet-worker activity heartbeat interval.')
log_sync_interval_seconds: float = Field(30, gt=0, description='Scratch log and progress copy-back interval.')
slurm_nodes: int = 1
slurm_ntasks: int = 1
slurm_cpus_per_task: int = 1
slurm_env_pack_path: Path | None = None
slurm_env_cache_enabled: bool = True
slurm_env_cache_dir: Path | None = None
slurm_wheelhouse_path: Path | None = None
slurm_requirements_path: Path | None = None
from_yaml¶
Load configuration from a YAML file.
Args:
path: Path to the YAML config file.
Returns:
BaseConfig: Parsed and validated configuration.
from_json¶
Load configuration from a JSON file.
Args:
path: Path to the JSON config file.
Returns:
BaseConfig: Parsed and validated configuration.
example_dict¶
Return a dict with defaults or placeholders for required fields.
Returns:
dict[str, Any]: Example config mapping.
caddforge.config.distribution¶
DistributionConfig¶
Declared fields and enum values (inherited fields are documented on the base class):
enabled: bool = False
by: str | None = None
chunks: int | None = Field(default=None, ge=1)
chunk_size: int | None = Field(default=None, ge=1)
submission: Literal['auto', 'individual', 'array'] = 'auto'
max_concurrent: int | None = Field(default=None, ge=1, description='Maximum running array tasks. Local chunks execute serially.')
array_task_limit: int = Field(default=1000, ge=1)
validate_partition¶
caddforge.core.dataset¶
Dataset¶
Immutable dataset consisting of entries and optional labels.
Args:
entries: Sequence of entries (typically molecule-like objects).
labels: Optional sequence of labels aligned with entries.
source: Optional provenance string (e.g., file path or database tag).
Declared fields and enum values (inherited fields are documented on the base class):
from_file¶
Create a dataset from a file path.
Args:
path: Path to the dataset file.
Returns:
Dataset: Parsed dataset instance.
Raises:
NotImplementedError: Always, until a concrete loader is implemented.
from_molecules¶
Build a dataset from an iterable of molecule-like objects.
Args:
molecules: Iterable of molecule-like objects.
source: Optional provenance string.
Returns:
Dataset: New dataset with entries populated and labels empty.
MoleculeSet¶
Immutable collection of molecules.
Args:
molecules: Sequence of molecule-like objects.
source: Optional provenance string (e.g., file path or database tag).
Declared fields and enum values (inherited fields are documented on the base class):
caddforge.core.model¶
Model¶
fit¶
predict¶
Generate predictions for a dataset or molecule set.
Args:
data: Dataset or MoleculeSet to predict on.
Returns:
Any: Tool-specific prediction output.
caddforge.core.job¶
JobStatus¶
Declared fields and enum values (inherited fields are documented on the base class):
PENDING = 'PENDING'
RUNNING = 'RUNNING'
COMPLETED = 'COMPLETED'
FAILED = 'FAILED'
CANCELLED = 'CANCELLED'
Job¶
Canonical representation of a workflow execution.
Args:
id: Unique job identifier.
tool_name: Registered tool name (without section).
backend: Backend name used to execute the job.
status: Current job status.
created_at: Timestamp when the job was created.
started_at: Timestamp when execution began.
finished_at: Timestamp when execution completed.
run_directory: Path to the job run directory.
metadata: Tool/backend-specific metadata.
Declared fields and enum values (inherited fields are documented on the base class):
id: str
tool_name: str
backend: str = 'unsubmitted'
status: JobStatus = JobStatus.PENDING
created_at: datetime = field(default_factory=lambda: datetime.now().astimezone())
started_at: Optional[datetime] = None
finished_at: Optional[datetime] = None
run_directory: Optional[Path] = None
metadata: dict[str, Any] = field(default_factory=dict)
to_metadata_dict¶
Serialize job metadata to a JSON-friendly dict.
Returns:
dict[str, Any]: Serialized metadata suitable for JSON encoding.
from_metadata_dict¶
Deserialize job metadata produced by `to_metadata_dict`.
Args:
data: Serialized job metadata.
Returns:
Job: Deserialized Job instance.
save_metadata¶
caddforge.core.result¶
Result¶
Standardized result object produced by workflows.
Args:
job_id: Job identifier.
tool_name: Tool name that produced the result.
status: Completion status for the job.
metrics: Tool-defined metrics (simple scalar values).
paths: Paths to key output artifacts.
extra: Tool-defined extra metadata payload.
Declared fields and enum values (inherited fields are documented on the base class):
job_id: str
tool_name: str
status: JobStatus
metrics: dict[str, float | int | str] = field(default_factory=dict)
paths: dict[str, Path] = field(default_factory=dict)
extra: dict[str, Any] = field(default_factory=dict)
to_dict¶
Serialize to a JSON-friendly dictionary.
Returns:
dict[str, Any]: Serialized representation of the result.
from_dict¶
Construct a Result from a dictionary representation.
Args:
data: Serialized result dictionary.
Returns:
Result: Deserialized Result instance.
save¶
caddforge.core.workflow¶
Workflow¶
Declared fields and enum values (inherited fields are documented on the base class):
prepare_job¶
Build a job object with metadata and paths.
Returns:
Job: Prepared job instance ready for submission.
run¶
Execute the workflow logic and return a result.
Args:
job: Job metadata for the execution.
context: Backend-neutral runtime details supplied by the executor.
Returns:
Result: Standardized workflow result.
caddforge.core.execution¶
BackendOptions¶
Declared fields and enum values (inherited fields are documented on the base class):
slurm_partition: str | None = None
slurm_time: str | None = None
slurm_account: str | None = None
slurm_nodes: int | None = None
slurm_ntasks: int | None = None
slurm_cpus_per_task: int | None = None
slurm_setup: list[str] = field(default_factory=list)
slurm_env_pack: Path | None = None
slurm_wheelhouse: Path | None = None
slurm_requirements: Path | None = None
extra_sbatch_options: list[str] = field(default_factory=list)
submit_workflow¶
def submit_workflow(workflow, cfg: BaseConfig, *, backend_name: str, runs_root: Path | str=Path('runs'), registry_path: Path | None=None, job_name: str | None=None, submission_cwd: Path | None=None, local_async: bool=False, backend_options: BackendOptions | None=None, emit: EmitFn | None=None, prepared_job_callback: Callable[[Job], None] | None=None, input_ports: tuple[InputPort, ...]=(), defer_submission: bool=False) -> Job
load_result_for_job¶
caddforge.core.lifecycle¶
execute_job¶
def execute_job(job: Job, run: Callable[..., Result], context: RuntimeContext, *, registry_path: Path | None=None) -> Result
persist_result¶
JobExecutionError¶
__init__¶
caddforge.core.execution_state¶
ExecutionUncertainError¶
reconcile_submission¶
def reconcile_submission(job: Job, *, handle: dict[str, Any] | None=None, confirmed_absent: bool=False) -> None
Record an operator-verified handle or confirmed absence after lost acknowledgement.
Absence must be established outside this helper. A failed/unavailable
scheduler query is never evidence of absence. This operation preserves
scientific files and allows the normal graph resume policy to run again.
caddforge.core.runtime_context¶
RuntimeContext¶
Declared fields and enum values (inherited fields are documented on the base class):
run_dir: Path
results_dir: Path
stdout_path: Path
stderr_path: Path
scratch_dir: Path
cpus_per_task: int = 1
allocated_runtime: bool = False
submission_cwd: Path | None = None
environment: dict[str, str] = field(default_factory=dict)
managed_execution: bool = False
scratch_subdir¶
retain_scratch¶
request_scratch_cleanup¶
finish_persistence¶
caddforge.core.filesystem¶
atomic_write_json¶
copy_verified¶
caddforge.core.artifact_sync¶
ArtifactCopy¶
Declared fields and enum values (inherited fields are documented on the base class):
source: Path
destination: Path
group_id: str | None = None
error: str | None = None
depends_on: tuple[Path, ...] = ()
generation: str = field(default_factory=lambda: uuid4().hex, compare=False)
ArtifactSyncReport¶
Declared fields and enum values (inherited fields are documented on the base class):
complete¶
ArtifactSyncQueue¶
Copy completed files asynchronously and retry transient failures.
Files are copied to a temporary file in the destination directory and then
atomically published with :func:`os.replace`. Copy failures remain queued
and are retried without interrupting the producer. ``finalize`` stops the
worker, performs one final pass over unresolved files, and returns a report.
``on_published`` runs in that worker after each verified atomic copy, before
its immutable source snapshot is removed. Use idempotent callbacks for
policy-specific cleanup; callback failures are logged without undoing the
successful publication or stopping other copies.
__init__¶
def __init__(self, *, interval_seconds: float=5.0, on_published: Callable[[ArtifactCopy], None] | None=None, on_maintenance: Callable[[], bool] | None=None) -> None
start¶
enqueue_files¶
def enqueue_files(self, files: Iterable[tuple[Path, Path]], *, group_id: str | None=None, depends_on: Iterable[Path]=(), replace_pending: bool=False, preserve_pending: bool=False) -> None
Queue immutable sources, optionally after other destination paths.
``replace_pending`` permits newer immutable snapshots to supersede a
destination's previous snapshot. Producers must never mutate queued
sources. Dependencies must be registered before their dependants.
``preserve_pending`` pins that snapshot until publication and coalesces
newer updates into one successor, preventing publication starvation.
enqueue_snapshot¶
def enqueue_snapshot(self, source: Path, destination: Path, *, snapshot_directory: Path, depends_on: Iterable[Path]=(), preserve_pending: bool=False) -> None
Own an immutable local snapshot until copied or safely superseded.
Only local snapshot I/O occurs in the producer. The worker removes
acknowledged/superseded snapshots after any in-flight copy completes.
Pending snapshots remain available for recovery after finalization.
``preserve_pending`` keeps one pinned generation and its latest successor.
finalize¶
report¶
caddforge.core.task_graph¶
Task¶
Declared fields and enum values (inherited fields are documented on the base class):
job: Job
config: BaseConfig
run: Callable[..., Result]
dependencies: tuple[Job, ...] = ()
require_success: bool = True
input_ports: tuple[InputPort, ...] = ()
submit_task_graph¶
def submit_task_graph(parent: Job, tasks: list[Task], finalizer: Task, *, backend_options: BackendOptions | None=None, local_async: bool=False, emit: Callable[[str], None] | None=None, bulk_options: dict[str, Any] | None=None) -> Job
cancel_task_graph¶
caddforge.core.job_logs¶
LogCursor¶
Declared fields and enum values (inherited fields are documented on the base class):
offset: int = 0
tail: bytes = b''
pending: bytes = b''
seen_events: set[tuple[str, str, int]] = field(default_factory=set)
max_seen_events: int = 20000
max_pending_bytes: int = 65536
read¶
job_log_sources¶
worker_logging¶
def worker_logging(logger_name: str, stream: TextIO, *, heartbeat_seconds: float=30, job_id: str='unknown', attempt_id: str | None=None, session_id: str | None=None, on_heartbeat: Callable[[], None] | None=None, event_filter: Callable[[logging.LogRecord], bool] | None=None, stage_name: Callable[[], str] | None=None) -> Iterator[logging.Handler]
caddforge.core.progress¶
StageProgress¶
__init__¶
def __init__(self, stage: str, total: float | None, *, logger: logging.Logger, initial: float=0, interval_seconds: float | None=None, unit: str='steps', on_update: Callable[[dict[str, Any]], None] | None=None, summary: str='', **details: Any) -> None
snapshot¶
update¶
def update(self, current: float, *, force: bool=False, measured_elapsed_seconds: float | None=None, measurement_timeout_seconds: float | None=None, measurement_age_seconds: float=0, **details: Any) -> None
caddforge.core.backend¶
Backend¶
Declared fields and enum values (inherited fields are documented on the base class):
submit¶
Submit a job for execution using the provided callable.
Args:
job: Job metadata to register and execute.
run_callable: Callable that performs the work and returns a Result.
Returns:
JobHandle: Backend-specific handle for tracking execution.
submit_shell_commands¶
Submit a shell-command job if the backend supports it.
Args:
job: Job metadata to register and execute.
commands: Shell commands to execute in order.
Returns:
JobHandle: Backend-specific handle for tracking execution.
Raises:
NotImplementedError: If the backend does not implement shell jobs.
submit_dependent¶
def submit_dependent(self, job: Job, run_callable: Callable[[Job], Result], dependencies: tuple[JobHandle, ...]=(), *, require_success: bool=True) -> JobHandle
submit_bulk¶
def submit_bulk(self, entries: list[tuple[Job, Callable[[Job], Result]]], *, max_concurrent: int | None=None, task_limit: int=1000) -> dict[str, JobHandle]
restore_handle¶
observe_status¶
cancel_job¶
query_status¶
Return current status of a submitted job.
Args:
handle: Backend-specific job handle.
Returns:
JobStatus: Current status for the job.
cancel¶
caddforge.core.artifacts¶
ArtifactKind¶
Declared fields and enum values (inherited fields are documented on the base class):
FILE = 'file'
DIRECTORY = 'directory'
MOLECULE_COLLECTION = 'molecule_collection'
POSE_COLLECTION = 'pose_collection'
POSE_MANIFEST = 'pose_manifest'
TABULAR_SCORES = 'tabular_scores'
PROTEIN_STRUCTURE = 'protein_structure'
COMPLEX_STRUCTURE = 'complex_structure'
ArtifactRef¶
Reference to a workflow artifact stored on disk.
Large data stays on disk; the pipeline engine passes these lightweight
references between stages and resolves them into concrete config paths.
Declared fields and enum values (inherited fields are documented on the base class):
id: str
kind: ArtifactKind | str
producer_stage_id: str
path: Path | None = None
paths: list[Path] = field(default_factory=list)
producer_job_id: str | None = None
metadata: dict[str, Any] = field(default_factory=dict)
primary_path¶
to_dict¶
from_dict¶
InputPort¶
Declarative input accepted by a tool plugin.
``config_field`` is the stable top-level pipeline binding target.
``runtime_selector`` may identify nested path values for execution-time
staging without changing that pipeline contract.
Declared fields and enum values (inherited fields are documented on the base class):
name: str
kind: ArtifactKind | str
config_field: str
required: bool = True
description: str | None = None
compression: InputCompressionPolicy | str = InputCompressionPolicy.TRANSPARENT_GZIP
runtime_selector: str | None = None
OutputPort¶
Declarative output produced by a tool plugin.
``config_field`` identifies the optional Path-typed config field that asks
the workflow where to write this result. Declaring it enables transparent
gzip output handling at the pipeline boundary.
Declared fields and enum values (inherited fields are documented on the base class):
name: str
kind: ArtifactKind | str
result_path_key: str
description: str | None = None
required: bool = True
path_collection_column: str | None = None
config_field: str | None = None
SplitContract¶
Declared fields and enum values (inherited fields are documented on the base class):
input_field: str
kind: ArtifactKind | str = ArtifactKind.MOLECULE_COLLECTION
strategy: Literal['sdf', 'csv', 'tsv', 'lines', 'auto'] = 'auto'
merge_outputs: dict[str, Literal['csv', 'tsv', 'sdf', 'jsonl', 'manifest', 'auto']] = field(default_factory=dict)
item_path_field: str | None = None
prepare: Callable[[Any, Path, Any], Iterable[Any]] | None = None
collect: Callable[[Any, Any, list[Any]], Any] | None = None
verify: Callable[[Any, Any, Any], None] | None = None
retains_inputs: bool = False
legacy_scatter: bool = True
caddforge.core.tool¶
ToolPlugin¶
Protocol that tool plugins should satisfy.
Attributes:
section: Section/group name for CLI organization.
name: Tool name within its section.
config_cls: Pydantic config model used by the tool.
workflow_cls: Workflow class executed by the tool.
Declared fields and enum values (inherited fields are documented on the base class):
section: str
name: str
config_cls: Type[BaseConfig]
workflow_cls: Type[Workflow]
input_ports: tuple[InputPort, ...] = ()
output_ports: tuple[OutputPort, ...] = ()
split_contracts: tuple[SplitContract, ...] = ()
resume_spec: ToolResumeSpec | None = None
input_fingerprint: Callable[[BaseConfig], dict[str, str]] | None = None
ToolSpec¶
Concrete description of a discovered tool plugin.
Args:
section: Section/group name for CLI organization.
name: Tool name within its section.
config_cls: Pydantic config model used by the tool.
workflow_cls: Workflow class executed by the tool.
plugin: Loaded plugin instance.
Declared fields and enum values (inherited fields are documented on the base class):
caddforge.plugins¶
get_tool¶
Return the tool spec for a given section/tool name.
Args:
section: Section/group name.
name: Tool name within the section.
Returns:
ToolSpec: Discovered tool specification.
Raises:
KeyError: If the section or tool name is not registered.
caddforge.pipeline.spec¶
PipelineSpec¶
Declared fields and enum values (inherited fields are documented on the base class):
version: int = 1
name: str = 'pipeline'
orchestration: OrchestrationConfig = Field(default_factory=OrchestrationConfig)
defaults: PipelineDefaults = Field(default_factory=PipelineDefaults)
stages: list[PipelineStageSpec]
PipelineStageSpec¶
Declared fields and enum values (inherited fields are documented on the base class):
id: str
tool: str | None = None
type: str | None = None
config: str | Path | dict[str, Any] | None = None
inputs: dict[str, str] = Field(default_factory=dict)
outputs: dict[str, str | dict[str, Any]] = Field(default_factory=dict)
scatter: ScatterSpec | None = None
depends_on: list[str] = Field(default_factory=list)
PipelineDefaults¶
Declared fields and enum values (inherited fields are documented on the base class):
backend: str = 'local'
run_directory: Path | None = None
registry_path: Path | None = None
job_name: str | None = None
export_results: bool = False
ScatterSpec¶
Declared fields and enum values (inherited fields are documented on the base class):
by: str
chunks: int | None = Field(default=None, ge=1)
chunk_size: int | None = Field(default=None, ge=1)
strategy: Literal['auto', 'sdf', 'csv', 'tsv', 'lines'] = 'auto'
submission: Literal['auto', 'individual', 'array'] | None = None
max_concurrent: int | None = Field(default=None, ge=1)
array_task_limit: int = Field(default=1000, ge=1)
OrchestrationConfig¶
Declared fields and enum values (inherited fields are documented on the base class):
backend: Literal['auto', 'local', 'slurm'] = 'auto'
compute: CoordinatorCompute = Field(default_factory=CoordinatorCompute)
load_pipeline_spec¶
caddforge.pipeline.executor¶
PipelineExecutionResult¶
Declared fields and enum values (inherited fields are documented on the base class):
pipeline_job: Job
stage_jobs: dict[str, list[Job]] = field(default_factory=dict)
artifacts: dict[str, ArtifactRef] = field(default_factory=dict)