---
question: What does a pipeline return to the caller?
kind: overview
---

# Pipelines

A pipeline turns external data into RDF and inserts it into the triple store. It is a Python class under the module's `pipelines/` folder: its `async def run(parameters)` fetches data (usually through an integration), maps it to ontology classes, inserts the graph and returns it. `abi new pipeline` scaffolds the class and a test beside it.

<!-- matrix -->

Nexus has no screen that writes a pipeline. Each pipeline class is also the durable workflow `pipeline.<slug>`: the System app's Jobs tab starts it, shows its runs and cancels them.

## Key concepts

- **`run(parameters)`.** Takes a Pydantic parameters model and returns an `rdflib.Graph`. The usual class also awaits `triple_store.insert(graph, graph_name)` before returning, so a run both stores and returns the triples.
- **The class.** `naas_abi_sdk.pipeline.Pipeline`, with the extras `naas-abi-sdk[workflows,rdf]`.
- **Discovery.** After `on_initialized` the module builds each `Pipeline` subclass defined under its `pipelines/` folder (not the tests), with `New(module)` or an empty `<Name>PipelineConfiguration()`. Nothing else registers it: delete the file and it is gone at the next start.
- **Durable workflow.** The module publishes each class as `pipeline.<slug>` (the class name in snake case: `ItemsPipeline` is `pipeline.items_pipeline`). Its one step is `run`, with one attempt and one run at a time unless the class sets `job`. A started run is recorded in System › Jobs. Its output is `{"format": "text/turtle", "triples": n, "data": "<turtle>"}`, with `data` replaced by a `note` above 60 KiB.
- **No route of its own.** The kernel REST API does not mount a module's pipelines. Scripts start `pipeline.<slug>` through Nexus' `/api/workflows`.
- **Agent tools.** `as_tools()` comes with the base class: one tool for the module's agents, after `await self.build_processes()` in `on_initialized`.
- **Schedules.** The class sets its triggers with `job = JobSettings(...)`. Each run is recorded with its status, input, step and result.

```text
Integration (raw API data)  →  Pipeline.run  →  Triple store
                                   ↑
  pipeline.<slug> (System › Jobs, /api/workflows, other modules, schedules)
  ·  agent tool
```

Pipelines and workflows share their runtime: see [Workflows](/capabilities/build/workflows/overview) for durable runs, and [Monitor and cancel a run](/capabilities/build/workflows/monitor-and-cancel-a-run) for their steps.
