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

{
  "runMode": "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.

On-demand

{
  "runMode": "ON_DEMAND"
}

The model runs only when explicitly triggered by a user via the pdView “Run model” button or the API trigger endpoint. Only one run can be in progress at a time. This is a good fit for experimental models or models with expensive compute requirements.

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 a new file lands in an input source bucket, 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 run datetime that reflects the temporal context of the input data (for example, the trading interval the forecast covers), you can define a custom runDatetimeQuery.

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

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

SELECT MAX(forecast_datetime) AS run_datetime
FROM input_data

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

Data fetcher scheduling

For inputs with AEMO MMS fetchers, a platform scheduler polls the external database at the configured checkInterval (minimum 60 seconds).

The scheduling cycle works like this:

  1. The check query runs against the external database on each interval.
  2. If the results differ from the last check, the fetch query runs.
  3. The fetched data is written to storage as a new input file.
  4. This new file landing in storage 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.