Pipeline API
scinr.newton.pipeline.run_pipeline
async
run_pipeline(
input_raw: str | None = None,
converter_output_dir: str | None = None,
extraction_input_dir: str | None = None,
extraction_output_dir: str | None = None,
ingestion_input_dir: str | None = None,
stages: list[str] | None = None,
document_names: list[str] | None = None,
document_names_dir: str | None = None,
manual: bool = False,
model_class: str | None = None,
only_unannotated: bool = False,
only_unextracted: bool = False,
context_instructions: str | None = None,
update_mode: bool = False,
replaces: str | None = None,
parallel_docs: int = 5,
on_partial_failure: Literal[
"abort", "continue", "warn"
] = "warn",
tabular_extensions: set[str] | None = None,
tabular_delimiter: str | None = None,
) -> PipelineResult
Orchestrate the scinr-ingest pipeline end-to-end.
Chains Stages 0-4 in sequence, passing data between stages in memory when intermediate directory parameters are omitted. Tabular files (.csv, .xlsx, .xls) found in input_raw are automatically routed to the tabular pipeline.
Concurrency for LLM calls (llm_concurrency) and Neo4j writes
(neo4j_concurrency) must be configured via
:func:~scinr.newton.config.configure before calling this function.
Use parallel_docs to control how many documents are processed
concurrently across all stages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_raw
|
str | None
|
Folder containing raw source files (PDF, DOCX, CSV, XLSX, …) for
Stage 0. Required when |
None
|
converter_output_dir
|
str | None
|
Folder where Stage 0 writes intermediate JSON files to disk.
When |
None
|
extraction_input_dir
|
str | None
|
Folder where Stage 1 reads JSON input from disk, skipping Stage 0.
Precedence: if provided, this takes absolute priority over |
None
|
extraction_output_dir
|
str | None
|
Folder where Stage 1 writes |
None
|
ingestion_input_dir
|
str | None
|
Folder where Stage 2 reads |
None
|
stages
|
list[str] | None
|
Ordered list of stage names to execute ( |
None
|
document_names
|
list[str] | None
|
Explicit list of Neo4j |
None
|
document_names_dir
|
str | None
|
Directory of |
None
|
manual
|
bool
|
If |
False
|
model_class
|
str | None
|
CamelCase Pydantic model class name for manual annotation. |
None
|
only_unannotated
|
bool
|
Skip nodes that already have an annotation decision. |
False
|
only_unextracted
|
bool
|
Skip nodes that already have extracted entities. |
False
|
context_instructions
|
str | None
|
Custom instructions injected into converter and annotation prompts. |
None
|
update_mode
|
bool
|
If |
False
|
replaces
|
str | None
|
|
None
|
parallel_docs
|
int
|
Maximum number of documents processed concurrently (default: |
5
|
on_partial_failure
|
Literal['abort', 'continue', 'warn']
|
Control behavior when a stage fails
( The pipeline never stops processing OTHER documents because of
this flag: every document in the batch is always dispatched to
the per-document-unit engine and runs independently of its
siblings, regardless of Within a single document's own remaining stages, the effect of
Both warnings coexist in |
'warn'
|
tabular_extensions
|
set[str] | None
|
File extensions to process via tabular pipeline (default: |
None
|
tabular_delimiter
|
str | None
|
Delimiter character for CSV tabular files. |
None
|
Returns:
| Type | Description |
|---|---|
PipelineResult
|
PipelineResult containing stage metrics, execution flags, and duration. |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If Neo4j or LLM configuration is missing. |
PreconditionError
|
If invalid parameters or mutually exclusive options are supplied. |
ExtractionError
|
If entity extraction fails. |
IngestionError
|
If Neo4j graph write fails. |
ValueError
|
If any parameter combination is invalid (see validation section). |
FileNotFoundError
|
If a required directory does not exist. |