Run Modes & Scheduling

After you publish a model, the platform needs to know when to run it. pd4castr supports two run modes that control how and when model runs are triggered: automatic runs based on incoming data, and on-demand runs triggered manually.

Run Modes

Set the runMode field in .pd4castrrc.json to one of these values:

Automatic

The model runs automatically when new input data arrives. The platform monitors your input sources and triggers a run when all required inputs have fresh data. This is the default mode for production models that need to update on a regular cadence.

{
  "runMode": "AUTOMATIC"
}

On-Demand

The model runs only when explicitly triggered by a user via the pd4castr UI’s “Run model” button or the API trigger endpoint. Only one run can be in progress at a time. This is a good fit for models you want fine-tuned control over.

{
  "runMode": "ON_DEMAND"
}

How Automatic Triggering Works

For models with AUTOMATIC run mode, the platform tracks a trigger progress state that determines when a new run starts.

The trigger logic works as follows:

  1. When new data arrives in an input source (both manually uploaded static input data and automatically fetched data from a dynamic input), the input’s latest file reference is updated.
  2. The platform checks the model’s trigger progress.
  3. All inputs with WAIT_FOR_LATEST_FILE trigger type must have received new data since the last run.
  4. Inputs with USE_MOST_RECENT_FILE trigger type use whatever file was last available — they don’t block a run from starting.
  5. When all conditions are met, a run is triggered.
  6. One base run plus one run per enabled sensitivity are created.

Custom Run Datetime

By default, the run datetime is set to the moment the run is created. If your model needs a specific run datetime to align with the context of the input data (for example, the trading interval the forecast covers), you can define a custom runDatetimeQuery in .pd4castrrc.json.

{
  "runDatetimeQuery": "queries/run-datetime.sql"
}

This SQL file is executed against the input data and must return a single row with a run_datetime column. For example:

SELECT MAX(forecast_datetime) AS run_datetime
FROM input_data

Where the data in the table named input_data in this case would correspond to an input with the key of input_data.

Set runDatetimeQuery to null or omit it to use the default behaviour.

Data Fetcher Scheduling

For inputs with configured data fetchers, the platform polls the data source at the configured checkInterval (minimum 60 seconds).

The scheduling cycle works like this:

  1. The check query runs against the external data source on each interval.
  2. If the results differ from the last check, the fetch query runs.
  3. The fetched data is written to the configured input source as a new input file.
  4. This new file landing in the input source can trigger automatic model runs (if the model uses AUTOMATIC run mode and all trigger conditions are met).

This creates a fully automated pipeline: external data is polled, new data is fetched and stored, and model runs are triggered without any manual intervention.

Next Steps

  • See Model inputs for details on trigger types and fetcher configuration.
  • Review Publishing to learn how run mode is set during the publish process.