Beta. Taps are a new feature and the API and UI may evolve based on user feedback. Core functionality is stable and production-ready, but we may add fields, rename properties, or adjust workflow steps in upcoming releases.
Tap Types
Every tap is one of three types. Choose the type when you create the tap; it can’t be changed later because the target pipeline shape differs.- Structured/Semi-Structured — the script returns records that flow into a structured pipeline destination.
- Document Ingestion — the script returns
{uri, filename, content}dicts for each file; the pipeline handles text extraction, chunking, and embedding. - I Have My Own Code — skip the AI and paste your own Python
fetch()script directly. The script still runs through the same test / auto-fix / post-run review / auto-optimize flow and can use any of the pre-installed packages or bring its own.
I Have My Own Code produces either Structured or Document output depending on what the pasted
fetch() returns — the shape rules in Data Types are what determine downstream routing, not the radio button. In practice pick this when you already have Python code you trust; if you change your mind and want AI help later, create a new tap.
Creating a Tap
The Tap creation wizard walks you through 4 steps — or 5, if you link the tap to a pipeline (the optional 5th step lets you run the tap immediately and push data through the pipeline before leaving the wizard).Step 1: Describe
Step 1 is where everything except testing happens — you name the tap, describe what you want, attach credentials, and generate or paste the script. Tap Name — A short identifier for the tap (e.g.,weather-data or contracts-sharepoint). If the name matches an existing tap (and you’re not in edit mode), an amber warning appears under the field letting you know that continuing will overwrite the existing tap’s configuration and script. The warning is non-blocking — overwriting is allowed if that’s what you intend.
Tap Type — Three radio options:
- Structured/Semi-Structured (default) — AI generates a script that returns records flowing into a structured pipeline destination.
- Document Ingestion — AI generates a script that returns
{uri, filename, content}dicts for each file; the pipeline handles text extraction, chunking, and embedding. - I Have My Own Code — skip the AI and paste your own Python
fetch()script. The AI brainstorm, Instruction textarea, and Generate Script button are all hidden; you see a full-width code textarea and a Use My Code button that uploads the pasted script to MinIO. Once uploaded, Next is enabled and the rest of the wizard (Edit & Test, Schedule, Review & Save) behaves identically to an AI-authored tap. Editing the textarea after upload invalidates the upload — you’ll see the button flip to Re-upload My Code and Next will be disabled until you re-click it.
- Ask one focused clarifying question at a time
- Suggest specific data sources (e.g., yfinance for stocks, Open-Meteo for weather, Alpha Vantage for fundamentals)
- Recognize when you reference a Datris table (it knows the platform’s metadata and query endpoints)
- Auto-update the Instruction box below on every turn as the conversation progresses
- Suggest the environment variable names you’ll need (e.g.,
ALPHA_VANTAGE_API_KEY) when an external API requires authentication
os.environ.get('KEY_NAME'). Never hardcode credentials in scripts.
Generate Script — Click to have the AI produce a Python script with a fetch() function. The result appears below in a scrollable preview, along with any extra pip packages it needs.
The generated script can use these pre-installed packages:
requests,beautifulsoup4,pandas,lxml,feedparserboto3(AWS S3),google-cloud-storage(GCS),azure-storage-blob(Azure Blob)openpyxl(Excel),pyyaml(YAML),python-dateutil,pytz- Additional packages can be specified and are installed at runtime via pip. Datris caches installed packages in Docker volumes so subsequent runs reuse them instantly.
- “Fetch current weather data for New York from the Open-Meteo API”
- “Retrieve daily stock prices for all S&P 500 companies from yfinance”
- “Get the latest news headlines from the BBC RSS feed”
- “Query the consumer_discretionary_earnings table on Datris to get tickers, then fetch historical earnings from Alpha Vantage”
Step 2: Edit & Test
Review and edit the generated script. You can:- Modify the Python code directly
- Add or remove pip packages
- Edit the instruction and click Regenerate to produce a new script
- Copy the script to your clipboard with the Copy button next to the editor
- Click Test Script to execute and preview results. Preview renders as JSON (up to 100 records) in a scrollable pane
- If the script fails, an AI Diagnosis explains what went wrong and is auto-applied — the platform fixes the script and retests, up to 3 attempts. If all retries fail, the diagnosis stays visible for you to review and apply manually
- Click Stop Test to cancel an in-flight test (also halts the auto-fix chain)
20, minimum 1): when enabled, the runner injects DATRIS_TAP_TEST_LIMIT=<n> into the script process. Well-written tap scripts honor this env var to cap both their /api/v1/query/* reads and per-item iteration loops, making tests fast and low-cost. Cron and manual runs (via Run Tap) never set this env var, so production runs always read every row from every source.
Post-run script review
When a test passes, the platform first sends the working script and its captured stderr/stdout to the LLM for a functional review — not a performance pass. The reviewer looks for signals in the script’s own output that the script should behave differently:- Rate-limit / throttle / burst warnings — add
time.sleep, lowermax_workers, add adaptive backoff on HTTP 429 - Deprecation / migration hints — switch to the recommended replacement endpoint, method, or field
- Pagination / partial-response hints (“truncated”, “page 1 of 5”, “next_cursor=…”) — add pagination so the tap keeps fetching until the source says no more
- Schema-drift / auth warnings — update parsing for renamed fields; for auth errors, add a clear stderr note naming the suspect env var
Auto-optimize after a successful test
If the post-run review left the script unchanged, the platform sends the working script back to the LLM with the measured duration and record count, asks it to restructure for performance, and re-tests the rewrite:- One pass per successful test. The optimizer is instructed to preserve
fetch(),DATRIS_TAP_TEST_LIMIThandling, error handling, and Vault env-var reads — it only changes how the script fetches, not what - If the optimized re-test runs ≥20% slower than the original, or fails, the platform auto-reverts to the original script with no user action
- On success, an amber banner shows
"Auto-optimized: 12.4s → 1.1s (11.3×)"with a list of the changes the AI made (e.g. Parallelized ticker fetches with ThreadPoolExecutor(10), Removed per-item sleep) and a Revert to original link - If you revert or edit the script, the auto-optimize pass won’t rerun until you click Generate again
Step 3: Schedule (Optional)
Set up automatic runs with a CRON expression:- Presets: Every Hour, Daily (Midnight), Weekdays (Midnight), Weekly (Monday)
- Custom: Describe your schedule in plain English (e.g., “Every weekday at 4pm ET”) and click Generate to create the CRON expression
Step 4: Review & Save
Review all settings (including a human-readable description of the CRON schedule, e.g.0 0 16 ? * MON-FRI — at 4:00 PM, on MON-FRI).
From step 4 you can also link the tap to a pipeline so its output flows through validation, transformation, and into your destination automatically. Two options — both branches change shape based on the tap’s type:
Structured taps
- Attach to Pipeline — pick an existing pipeline whose source columns match the tap’s test output exactly. If columns don’t match, you’ll see exactly which columns are missing or extra so you can fix the mismatch before attaching.
- Generate Pipeline — create a new pipeline pre-wired to the tap’s output. The new pipeline’s destination is Postgres (
public.<tap_name>) for tabular data, or MongoDB for nested/document data. All columns are created asstringfor safe ingestion — tap output shape can vary across runs, and string columns ingest reliably regardless of what the script returns. You can promote individual columns to richer types in the pipeline editor once you’re confident about the data shape.
- Attach to Pipeline — the picker is filtered to only compatible pipelines: those whose source is
unstructuredAttributesand whose destination is a vector store (Qdrant, pgvector, Weaviate, Milvus, Chroma). Column matching doesn’t apply — every document has the same{uri, filename, content}shape. The selection card shows the destination (e.g.pgvector → public.contracts). - Generate Pipeline — creates an unstructured → vector-store pipeline. You pick:
- Vector store — only stores whose secret is configured and the service is reachable are listed (server probes each on modal open via
/api/v1/vector-stores/available). If exactly one is available it’s preselected; if none are, the modal blocks with a link to Configuration. - Destination name — collection name (Qdrant / Milvus / Chroma), class name (Weaviate), or table + schema (pgvector).
- Chunking strategy — recursive (default), fixed, sentence, paragraph, or none. Plus chunk size (default 500 chars) and overlap (default 50). These live on the pipeline, not the tap.
- Embedding is inherited from the environment’s default embedding secret — no picker this pass.
- Vector store — only stores whose secret is configured and the service is reachable are listed (server probes each on modal open via
Step 5: Run the Tap (Optional)
Step 5 only appears when the tap is linked to a pipeline. It’s a one-time launch screen with two buttons:- Run the Tap Now — runs the tap script immediately and pushes the records it returns into the linked pipeline. The pipeline applies any data quality and transformation rules and writes to its destination. After the run completes you’re returned to the Taps list.
- Done — skip the run and return to the Taps list. You can run the tap later from the Taps page or via the MCP
run_taptool.
Querying Datris Data
Tap scripts can query data already stored in the Datris platform. The following environment variables are always automatically injected at runtime — your script does not need to fall back to defaults:
In single-tenant deployments the postgres and mongo database names may differ (postgres defaults to
datris, mongo defaults to oss); in multi-tenant mode both resolve to the same tenant name. Always use the variable that matches the backend you are querying.
Scripts can call the Datris API directly using these:
Discover tables (PostgreSQL):
/api/v1/metadata/postgres/columns reflect the live table schema, which always satisfies the platform’s [A-Za-z0-9_]+ rule (see Column Naming Rules). You can use them directly in SELECT clauses without quoting.
Query PostgreSQL data:
/api/v1/metadata/postgres/columns or /api/v1/metadata/mongodb/collections.
Credentials / Secrets
Tap secrets are stored in HashiCorp Vault and injected as environment variables when the script runs. They are managed directly in the tap wizard (Step 1).- Select existing: Choose from previously created tap secrets
- Create new: Define key-value pairs inline (e.g.,
API_KEY=your-key) - Edit existing: Modify an existing secret’s fields
- Use suggested keys: When the brainstorm AI suggests environment variables, click + Create tap secret with these keys to jump straight into the create form with the keys pre-filled
_type=tap and only appear in the tap dropdown — not mixed with system secrets like database credentials.
Never hardcode credentials in scripts. Always use os.environ.get('KEY_NAME').
Running Taps
Tap code runs in-process by default, and can optionally run in an isolated runner container
that’s separated from the platform’s credentials and internal services. See
Tap Execution & Isolation.
Test Run (from UI)
Click the play button on the taps list to open the Run page:- Shows the tap instruction
- Send to pipeline checkbox (only if a target pipeline is configured)
- Displays script output, results table, and errors
- Run Again button for re-execution
CRON Schedule
Taps with acronExpression run automatically. The scheduler checks every 30 seconds for taps that are due. A tap won’t fire if it’s already running. For a tap that has never run before, the scheduler anchors the “next valid cron time” to updatedAt or createdAt, so the first scheduled slot after the tap was saved fires on its own — no manual bootstrap run needed.
Sending Data to Pipelines
When “Send to pipeline” is checked:- The tap executes the script
- Records are converted to the pipeline’s expected format (CSV or JSON)
- Data is fed through the pipeline’s processing chain (data quality, transformation, destinations)
Watching a Run
run_tap returns as soon as records are handed off — the pipeline load runs async after that. The response carries:
persisted: true/falsewithpersistedReasonwhen false (no_target_pipeline,test_mode,no_records,run_error,debounced) so callers know whether the data actually landed.debouncedmeans another run for this same tap was triggered within the last 5 seconds — that earlier run is still executing; do not retry, just track it viaget_tap_logs/get_pipeline_status.publisherToken— a single ID covering every ingestion job this run submitted. Document taps fan out to many jobs per run; onepublisherTokencovers them all.pipelineTokens— the per-job IDs (length 1 for structured, N for document).recordCount— how many records the script produced.
run_tap does not return the records themselves. Use test_tap (or the Test Script button in the UI) when you need to preview what a script produces before pushing it — test_tap returns a sample of up to 20 rows with a recordsTruncated flag when trimmed.
Poll GET /api/v1/pipeline/status?publishertoken=...&withrollup=true (or the MCP get_pipeline_status tool, which sets withrollup=true automatically) until rollup.allDone is true, then read rollup.status for the outcome and rollup.jobs[].lastError for any failure detail.
Per-run Parameters
run_tap accepts an optional params object — a map of caller-supplied values that get injected into the script as environment variables for that one run only. Use this for values that vary per call (date windows, ticker lists, page cursors, batch sizes, geographic regions). Each key/value becomes an env var the script reads:
- Key constraints: must match
[A-Za-z_][A-Za-z0-9_]*so the keys map cleanly onto env var names. Anything else is rejected with an actionable error. - Value handling: strings pass through; numbers/booleans are stringified; nested objects/arrays are JSON-encoded so the script can
json.loads()them back. - Scheduled runs supply no params — cron-triggered runs have an empty params bag. Scripts MUST apply sensible defaults when the env var is absent.
params for things that change between runs; use secret_name for credentials that don’t. Rewriting a tap secret on every run to smuggle per-call values through is an anti-pattern — it clobbers concurrent runs, pollutes audit history, and wastes Vault writes.
Run Status Outcomes
Each tap run produces one of three states on itslastRunStatus field and matching run log entry:
Cron-scheduled runs that legitimately produce zero records (incremental tap that’s caught up, polling tap with no new entries) record
no_records rather than failure and the Ops Activity dashboard surfaces them as healthy.
Output Size Guard
The platform caps tap-script output attapMaxOutputMB (default 100 MB, settable via the TAP_MAX_OUTPUT_MB env var on the datris service). Runs that exceed the cap fail fast with an actionable error before the JSON is parsed — preventing the whole batch from buffering in JVM heap and OOM-killing the server.
If a backfill blows the cap, reduce the source range using run_tap params (shorter date window, smaller page, per-symbol chunks) and call again. Multiple smaller runs all land in the same destination pipeline; with keyFields configured on a Postgres or MongoDB pipeline, overlapping ranges upsert safely.
Data Types
The system automatically detects the data type from whatfetch() returns:
The
uri + content detection takes priority — if your script returns records with those keys, the runner routes every element through the document pipeline path even if the tap’s type is structured. In practice the type radio and the return shape should always agree; this rule just makes misconfigurations fail loudly rather than silently corrupt a structured destination.
Pipelines and Taps
The Pipelines page shows a Tap column for each pipeline, indicating which tap (if any) feeds it. Click the tap name to jump straight to that tap’s edit page. On the Pipeline creation wizard, select From Tap to auto-populate the pipeline’s source type and schema from a tap’s test results. The tap’s data type and columns are used to configure the pipeline automatically.Run History
Click the history icon on the taps list to view a tap’s run history. Each entry shows:- Status (success/failure)
- Timestamp and duration (formatted using the configured
dateFormatanddateTimezone— see Configuration Reference) - Record count
- Whether data was sent to a pipeline
- Expandable script output logs and error messages
MCP Tools
AI agents can manage taps via MCP:
End-to-end agent flow when a tap needs credentials:
CLI Commands
Configuration
Document Taps
Document taps feed files (PDFs, DOCX, HTML, Markdown, etc.) into a vector-store pipeline. The pipeline owns text extraction, chunking, and embedding — the tap’s only job is discovery and retrieval.Return shape
Each element of the listfetch() returns is a dict describing one document:
Rules the generator and users must follow:
- Return one entry per source file. Never chunk, split, or segment. Never decode the bytes.
- Don’t generate embeddings, pick embedding models, choose a vector store, or create tables — those are pipeline concerns.
- Don’t invent metadata fields that describe pipeline behavior (
chunk_size,embedding_model,target_table); those belong on the pipeline.
The Document Ledger
Every document the tap successfully stages is recorded in a ledger — a MongoDB collection keyed by{tapName}|{uri}. On each run, the tap:
- Loads
uri → contentHashfor every existing ledger entry owned by this tap. - For each document returned by
fetch(), computes (or reads) its content hash. - Skips the document if the ledger already has an entry with the same hash (just refreshes
lastSeenAtfor operator visibility). - Otherwise, stages the bytes to MinIO, writes a ledger entry (
status: staged), submits to the pipeline, and marks the entryprocessed(orfailedon error).
uri, tapName, stagedPath (MinIO key), filename, contentHash, firstSeenAt, lastSeenAt, status (staged/processed/failed), metadata.
Managing the ledger:
- UI — the document-ledger button (page icon) next to a document tap in the Taps list opens a modal listing every entry. Actions: Clear All (force full re-scan on next run), or delete a single entry (force that one file to re-process).
- REST —
GET /api/v1/tap/ledger?name={tap},DELETE /api/v1/tap/ledger?name={tap}&uri={uri}for a single entry,DELETE /api/v1/tap/ledger?name={tap}to clear all. - MCP —
get_tap_ledgerwith optionalclear_uri/clear_all.
- Deleting a tap clears its ledger entries and deletes all staged MinIO objects.
- Deleting a pipeline’s data (from the Pipelines page → Delete Data Only, or
DELETE /api/v1/pipeline?pipeline=X&deleteData=true) clears the ledger for every document tap pointed at that pipeline — so the next run re-ingests every file into the now-empty destination. Without this, taps would skip docs they already “processed” and the pipeline would stay empty.
Pipeline compatibility
The server validates at two points:- On save (
POST /tap) — iftapType == "document"andtargetPipelineis set, it checks the pipeline’s shape. Rejects with HTTP 400 if the source isn’tunstructuredAttributesor the destination isn’t a vector store. - On feed (
TapRunner.feedDocumentPipeline) — re-checks before submitting bytes, so a pipeline that was reshaped after the tap was saved fails the run with a clear error instead of silently corrupting a destination.
Concurrency
Document taps feed many documents throughStreamNotifier.process in rapid succession. Each becomes its own JobRunner, and all five vector-store loaders are now race-safe when multiple runners hit ensureCollection / ensureTable at the same time on a fresh pipeline:
- pgvector — transactional advisory lock plus
CREATE TABLE IF NOT EXISTS; serializes concurrent sessions at the schema-qualified table name. - Qdrant / Milvus / Weaviate — try-create; on error, re-check existence and swallow if a concurrent runner won the race.
- Chroma — sends
get_or_create: trueplus a re-GET fallback for older servers.
Script Requirements
Thefetch() function must:
- Take no arguments
- Return a list of dictionaries (records) or a string (JSON/XML/text)
- Handle errors gracefully with try/except
- Include timeouts on network requests (30 seconds recommended)
- Return an empty list on failure rather than raising exceptions
- Use
os.environ.get()for any credentials - Read
DATRIS_POSTGRES_DATABASE,DATRIS_MONGODB_DATABASE,DATRIS_PLATFORM_HOST, andDATRIS_PLATFORM_PORTdirectly without fallback defaults — they are always injected by the platform - Column names are auto-normalized for tabular results (list of dicts). The platform converts each key to lowercase snake_case using only
[a-z0-9_]so that downstream pipeline registration succeeds and SQL queries don’t need quoting. Examples:EPS Estimate→eps_estimate,Surprise(%)→surprise_percent. You can return raw source column names — the platform will clean them — but for clarity in the test preview, prefer to emit clean keys directly. JSON/XML results destined for MongoDB are not normalized (they go through as raw blobs in the_jsonfield). See Schema Definition → Column Naming Rules for the underlying validator rule.
