ontocast.api.process_helpers¶
Shared helpers for local batch processing and HTTP response assembly.
calculate_recursion_limit(head_chunks, server_config, *, max_visits_per_node=None)
¶
Calculate the recursion limit based on max visits and head chunks.
Source code in ontocast/api/process_helpers.py
dump_facts_ttl(state, file_path, *, line_number=None, output_dir=None)
¶
Write chunk-stripped facts Turtle when facts exist.
Source code in ontocast/api/process_helpers.py
dump_ontology_ttls(state, file_path, *, line_number=None, output_dir=None)
¶
Write provenance-stripped ontology Turtle dumps when artifacts exist.
Source code in ontocast/api/process_helpers.py
dump_run_manifest(state, file_path, *, config, line_number=None, output_dir=None)
¶
Write the run's cost and configuration beside the facts TTL.
BudgetTracker is returned over HTTP and logged at INFO, then discarded,
so a batch run left no record of the model, the settings, or the tokens
behind its own output -- and no way to compare two dumps except by rerunning
them. One small JSON per document closes that.
Source code in ontocast/api/process_helpers.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
dump_validation_report(state, file_path, *, line_number=None, output_dir=None)
¶
Write the conformance summary and residual findings beside the facts TTL.
A batch run otherwise leaves no record of why a graph is non-conformant: the findings live on the state and are logged, and every downstream reader ends up re-running a validator to rebuild what the gate already computed.
Source code in ontocast/api/process_helpers.py
expand_input_to_states(file_path, *, config, head_chunks, ontology_context_mode_value, tenant, project, target_sections=None, exclude_sections=None, summarize_sections=None, summary_max_sentences=5, document_type_hint=None, section_schema_id=None, max_visits=None, document_metadata=None)
¶
Expand a local input file into one AgentState per logical record.
Source code in ontocast/api/process_helpers.py
facts_ttl_output_path(file_path, *, line_number=None, output_dir=None)
¶
Return the .facts.ttl path for a processed input file.
Source code in ontocast/api/process_helpers.py
flush_triple_configured_scope(tools)
async
¶
Match POST /flush without tenant/project: triple store only, current scope.
get_supported_input_extensions(tools)
¶
Return all input file suffixes handled by document conversion.
Source code in ontocast/api/process_helpers.py
ontology_ttl_output_path(file_path, *, line_number=None, output_dir=None, ontology_id=None)
¶
Return the .ontology.ttl path for a processed input file.
Source code in ontocast/api/process_helpers.py
persist_unit_pipeline_outputs(state, onto_result, facts_result, tools)
async
¶
Serialize unit-pipeline outputs using the standard document serializer.
Source code in ontocast/api/process_helpers.py
process_files_input(files, *, config, head_chunks, use_unit_pipeline, tools, workflow, ontology_context_mode_value, tenant, project, target_sections=None, exclude_sections=None, summarize_sections=None, summary_max_sentences=5, document_type_hint=None, section_schema_id=None, max_visits=None, document_metadata=None, output_dir=None, facts_output_dir=None, ontology_output_dir=None)
async
¶
Process each input file, isolating per-file failures.
Returns:
| Type | Description |
|---|---|
list[Path]
|
The files that failed, in input order. Empty on full success. Callers |
list[Path]
|
use this to set a non-zero exit code -- previously every failure was |
list[Path]
|
logged and swallowed, so |
list[Path]
|
file produced any output. |
Source code in ontocast/api/process_helpers.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | |
resolve_batch_output_dirs(output_dir, facts_output_dir, ontology_output_dir)
¶
Resolve facts/ontology dump dirs from shared and override flags.
Returns:
| Type | Description |
|---|---|
tuple[Path | None, Path | None]
|
|
Source code in ontocast/api/process_helpers.py
safe_ontology_filename_id(ontology)
¶
Return a filesystem-safe ontology id fragment, or None if unavailable.
Source code in ontocast/api/process_helpers.py
select_unit_facts_ontology_graph(onto_result, facts_result)
¶
Return ontology graph for facts post-processing in unit pipeline flows.
Source code in ontocast/api/process_helpers.py
turtle_from_graph(graph, *, strip_provenance)
¶
Serialize graph to Turtle, optionally stripping reification/provenance.
Source code in ontocast/api/process_helpers.py
validate_unit_pipeline_facts(state, ontology_graph, tools)
¶
Run the post-aggregation invariant gate for the single-unit path.
The document graph reaches this gate at VALIDATE_FACTS; the unit pipeline
does not run the graph, so both single-unit callers -- the CLI
--use-unit-pipeline batch path and the /process_unit route -- invoke
it here after aggregation. Without it they would ship facts with no
functional-violation, coreference, or SHACL check at all.
merge_repair=False: un-merging re-aggregates retained units against
each other, which has no meaning for a single unit. Everything else is the
document path verbatim, so batch dumps stay comparable across the two entry
paths.