semantica.pipeline lets you chain Semantica components into reproducible, fault-tolerant workflows:
  • Per-step failure strategies: skip, retry, abort, or fallback
  • Parallel workers via ParallelismManager: thread or process pool
  • PipelineValidator catches cycles, missing handlers, and config errors before running
  • Pre-built templates: "document_processing", "rag_pipeline", "kg_construction", "ontology_generation"
  • Pipelines are serializable to YAML: save and reload in any environment

Exported Classes

Why Use a Pipeline?

You could wire Semantica modules together with plain Python code. Pipelines add:
  • Retry and failure handling — A single bad document doesn’t crash a 10,000-document run.
  • Parallelism — Run extraction across multiple workers with one parameter.
  • Progress tracking — tqdm console bar or WebSocket streaming to Explorer.
  • Reproducibility — Save the exact pipeline configuration to YAML and replay on any machine.
  • Delta mode — On re-runs, only process documents that changed since the last run.
  • Validation — Catch misconfigured steps and dependency cycles before they fail mid-run.
Use plain module calls for quick scripts and notebooks. Use pipelines for anything you run repeatedly, at scale, or in production.
Pipeline step sequence: Ingest → Parse → Normalize → Extract → Build KG → QA → Store → Deliver

Quick Start

1

Build a pipeline

2

Validate before running

Use PipelineValidator before running in production. It catches dependency cycles, missing step names, and misconfigured connections that would only surface as errors mid-run. Validation is instant; catching them after a 30-minute extraction job is not.
3

Execute and inspect results

Inspect result.metrics to find bottlenecks. result.metrics['steps_executed'] and result.metrics['execution_time'] give a quick read on overall pipeline health. For per-step timing, check step.result on each PipelineStep after the run.

Parallel Processing

Set parallelism on the builder and pass max_workers to ExecutionEngine:
Set workers= based on workload type. Thread workers for I/O-bound steps (web fetching, DB queries), process workers for CPU-bound steps (embedding, OCR, large NER batches). Mixing pool types on the wrong step type wastes resources without speed gains.

Retry and Error Handling

Failure Strategies

In production, configure a RetryPolicy with limited retries so a single failing step does not stop the whole run. After execution, inspect result.errors to find and reprocess failed documents.
Configure retry policies to contain failures in production. Use handler.set_retry_policy("step_type", RetryPolicy(max_retries=3)) so transient errors are retried without stopping the pipeline. After the run, inspect result.errors to find and reprocess any documents that exhausted retries.

Progress Tracking

Displays a live progress bar in the terminal via Semantica’s built-in progress tracker. Best for scripts and CLI tools.

Pipeline DSL

PipelineBuilder uses add_step(name, type, **config) and connect_steps(from, to) to define a DAG:

Serialize and Restore Pipelines

PipelineSerializer converts a pipeline to JSON or dict for storage and reloads it later:
Serialized pipelines capture step names, types, and config: but not handler functions (callables can’t be serialized). Re-register handlers on the restored steps before executing.

Pre-Built Templates

PipelineTemplateManager wires common workflows with the correct step order: no manual wiring required:
The create_pipeline_from_template(name) method returns a configured PipelineBuilder. Call .build(pipeline_name) on it to produce a runnable Pipeline.
  • document_processingIngest → Parse → Normalize → Extract → Embed → Build KG — Complete document processing from ingestion to knowledge graph.
  • rag_pipelineIngest → Chunk → Embed → Store Vectors — RAG pipeline for question answering: builds a vector-indexed store.
  • kg_constructionIngest → Extract Entities → Extract Relations → Dedup → Resolve → Build Graph — Knowledge graph construction from multiple sources.
  • ontology_generationExtract Concepts → Infer Classes → Infer Properties → Generate OWL → Validate — Ontology generation from extracted data.
Use templates from PipelineTemplateManager for common patterns. create_pipeline_from_template("kg_construction") wires normalization, deduplication, conflict detection, and graph construction in the correct order: saving you from common mistakes like deduplicating before normalizing.

ExecutionEngine

Fine-grained control over pipeline execution: pause, resume, cancel, and inspect live progress:

PipelineValidator

Catches problems before they surface as mid-run failures:
Checks performed:
  • Dependency cycle detection: A depends on B, B depends on A
  • Step type validation: each step type must be registered
  • Connection integrity: referenced step names must exist
  • Configuration completeness: required parameters must be present

ParallelismManager

Use thread pools for I/O-bound steps: web fetching, database queries, API calls.

ResourceScheduler

Prevents memory oversubscription on large runs:

Delta Mode

Re-process only data that has changed since the last run:
Delta detection uses SHA-256 checksums on source content. Only sources whose checksum differs from base_version_id are passed to downstream steps. For pipelines that run hourly or daily against a growing corpus, delta mode eliminates redundant re-embedding and re-extraction.

SPARQL CONSTRUCT Template Steps

Use the "construct_template" step type to render and execute a SPARQL CONSTRUCT template as part of a pipeline. store_backend and construct_template_registry are execution-time resources, not step config — pass them to execute_pipeline(), the same way delta_mode steps receive version_manager and triplet_store:
construct_template steps raise ProcessingError if store_backend or construct_template_registry is missing from execute_pipeline()’s options, and ValidationError if template_name isn’t registered.

Schemas