Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Wait for data to be ready with signals

Make a scheduled Vulcan model wait for late-arriving source data instead of running on a fixed clock and computing an incomplete result.

Vulcan normally decides whether to run a model using two checks: has the cron schedule elapsed, and have upstream dependencies finished. Neither check confirms the data itself has actually arrived. If a daily model is scheduled for 12:15 and the source system's batch job runs late, the model still fires at 12:15 and processes an incomplete window.

A signal adds a third check: a Python function that asks the source system directly, "is today's data here yet?" before the model runs. Use this recipe when a model depends on an external system whose delivery time isn't guaranteed by the clock alone (for example, a daily sales rollup that must wait for that day's orders to land before it aggregates them).

A signal only adds a readiness check. It does not replace cron or upstream dependencies; all three must pass before Vulcan evaluates an interval. If a model defines more than one signal, every signal must agree the interval is ready; Vulcan treats them as an AND, not an OR.

Steps

1. Write the signal function

Create (or add to) signals/__init__.py at the project root. Define a function that checks whether the source data exists for the interval Vulcan wants to process.

from vulcan import signal, DatetimeRanges, ExecutionContext


@signal()
def data_available_for_today(batch: DatetimeRanges, context: ExecutionContext) -> bool:
    overall_start = min(s for s, _ in batch)
    overall_end = max(e for _, e in batch)

    query = f"""
        SELECT COUNT(*) AS cnt
        FROM vulcan_demo.orders
        WHERE order_date::timestamp BETWEEN '{overall_start}' AND '{overall_end}'
    """
    df = context.engine_adapter.fetchdf(query)
    count = int(df.iloc[0]['cnt'])
    return count > 0

Vulcan can pass several intervals at once as batch (the model's batch_size controls how many). This function collapses them into one overall window and asks the source table: "does at least one row exist in this window?" context.engine_adapter.fetchdf runs the query against the live source, the same mechanism a Python model uses to pull data.

The function must return a single True/False for the whole batch, or a filtered list of the ready intervals, never a per-row result.

2. Wire the signal into the model

Add a signals (...) block to the model's MODEL(...) definition, calling the function by name.

Vulcan now checks data_available_for_today() in addition to cron and upstream dependencies. On a normal day, the signal returns True right away and the model runs on schedule. On a day with delayed source data, the model waits and runs once the signal returns True on a later scheduler pass.

Run vulcan plan to confirm the signal name and arguments resolve correctly.

3. Confirm the signal is actually gating runs

Compare vulcan check_intervals output with and without the signal against a deployed environment.

check_intervals only evaluates a deployed environment, so run vulcan plan first. Local-only signal changes aren't reflected until they're deployed. With signals on, an interval whose source data hasn't landed yet is excluded from the list. With --no-signals, that same interval shows up as ready, confirming the signal (not something else) is the reason it's being held back.

4. Handle partial readiness (optional)

If a batch can contain some ready intervals and some that aren't, return a filtered list instead of one boolean.

If a model's batch_size groups several days together, this lets Vulcan process the days that already have data while it keeps waiting on the rest, instead of holding the whole batch back for one late day. Only return a subset of the exact (start, end) tuples you were given; never modify their bounds.

Best practices

  • Keep the readiness check close to the real question ("does the source have data for this window?") rather than a proxy like a fixed delay.

  • Query the actual source table with context.engine_adapter.fetchdf (or context.fetchdf in a Python model), not a cached or derived copy.

  • Return a filtered list of intervals instead of a single boolean once a model's batch_size spans more than a day, so one late day doesn't block everything else.

  • Use vulcan check_intervals --no-signals whenever you need to confirm a signal, not something else, is the reason a model isn't running.

Troubleshooting

Symptom
Likely cause
Fix

Model never runs, even though data has landed

The signal's query checks the wrong table/column, or targets a different environment than the one with the data

Run the signal's query manually against the same environment the model targets

Signal changes don't seem to take effect

The signal was only changed locally, not deployed

Run vulcan plan <env> before vulcan check_intervals <env>

Model runs but processes incomplete data anyway

The signals block was commented out or removed from the MODEL definition

Confirm the signals (...) block is present and active

Type or assertion errors inside the signal function

The signal declares an argument that doesn't match what the model passes

Match the signal function's parameters to the arguments in the signals(...) call

One slow day blocks an entire multi-day batch

The signal returns a single True/False for the whole batch

Return a filtered list of ready intervals instead (step 4)

References

  • Signals - full signal reference: the @signal decorator, batch/context arguments, and testing with check_intervals. Vulcan ships no built-in signals; every signal is a custom function you write.

  • Run and scheduling - how cron, dependencies, and signals combine to decide when a model runs.

Last updated

Was this helpful?