Model Inputs
Inputs are the data files your model reads on every run. This page covers how
your model receives them, the two kinds of input, and how each input’s trigger
decides when an AUTOMATIC model runs.
An input’s data comes from its input source. A static input’s input source is a file the CLI uploads when you publish. A fetched input’s input source is a data fetcher that pulls data on a schedule. An input can also have several input sources, each a file or a data fetcher.
How Inputs Work
When a model run starts, pd4castr makes each input file available at its own URL and passes that URL to your container in an environment variable. Your model reads the variable, downloads the file with a standard HTTP GET request, and parses it.
An input with "key": "demand" arrives in INPUT_DEMAND_URL, and an input with
"key": "spot-price" arrives in INPUT_SPOT_PRICE_URL. The variable is always
INPUT_<KEY>_URL, where <KEY> is the input’s key in uppercase with hyphens
replaced by underscores.
JSON Input Format
Write every JSON input file as an array of objects that share one set of fields, with one object per row:
[
{ "timestamp": "2026-01-01T00:00:00Z", "price": 42.5 },
{ "timestamp": "2026-01-01T00:05:00Z", "price": 43.1 }
]pd4castr reads a JSON input as rows when it converts the file to another format, when a sensitivity changes it, and when one of your SQL queries reads it, such as an input aggregation or a model run view query. A file in any other shape fails at those steps.
Input Configuration Fields
Each entry in the inputs array in .pd4castrrc.json supports the following
fields.
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Identifier for this input. See How inputs work. |
trigger | string | Yes | WAIT_FOR_LATEST_FILE or USE_MOST_RECENT_FILE. See Trigger types. |
file | string | Static inputs only | Path to the local file the CLI uploads, relative to the project root. |
fetcher | object | Fetched inputs only | Data fetcher configuration. See Fetched inputs. |
uploadFileFormat | string | No | Format of the input’s files as they arrive: json, csv, or parquet. Defaults to json. |
targetFileFormat | string | No | Format your container receives: json, csv, or parquet. Defaults to json. |
storageLocation | string | No | ID of your own storage location. |
axes | object | No | Connects the input to a model axis. See Model axes. |
sources | object | No | Several input sources, in place of file or fetcher. See Input sources. |
Give an input the same uploadFileFormat and targetFileFormat. A publish
fails when they differ, because pd4castr converts formats only for an input
source other than the default on an
input with several input sources.
Storage Locations
A storage location is a storage bucket and folder that pd4castr watches for
input files. Every input uses pd4castr’s shared storage location unless you
declare your own. With your own storage location, you can upload files between
publishes, and each new file can start runs without a publish.
Contact us
to set one up: we create it, tell you how to upload to it, and give you the ID
to declare in storageLocation.
Static Inputs
A static input is a file in your project that the CLI uploads each time you run
pd4castr publish. Use static inputs for reference data, lookup tables, and
other data that changes only when you publish. Declare the file’s path, relative
to the project root, in the file field:
{
"key": "reference_prices",
"file": "test_input/reference_prices.csv",
"trigger": "USE_MOST_RECENT_FILE",
"uploadFileFormat": "csv",
"targetFileFormat": "csv"
}When your model declares axes, you can partition a
static input whose uploadFileFormat and targetFileFormat are both parquet.
pd4castr then gives each run only the rows for that run’s axis value, as
Partitioning inputs and datasets by an axis
describes.
Fetched Inputs
A data fetcher polls a data provider on a schedule and writes each new batch of data as a new file for a fetched input. Each new file can start a run. AEMO MMS (the Australian Energy Market Operator’s Market Management System) is the only data fetcher pd4castr ships.
Data from another data provider can arrive as files you upload: as a static input at each publish, or between publishes through your own storage location. Contact us to connect another data provider directly.
A data fetcher runs two SQL queries that you write: a check query and a fetch
query. Every checkInterval seconds, pd4castr runs the check query and compares
its result with the result of the previous check. When any row or value differs,
pd4castr runs the fetch query and writes its result as a new input file. If the
fetch fails, pd4castr fetches again at the next check. After 3 failed fetches
for the same check result, it waits for the check result to change. Write the
check query to return something that changes when new data lands, such as the
latest timestamp in the table:
SELECT MAX(settlementdate) FROM mms.tradingprice. See
SQL queries for the tables these queries read and the
limits they run under.
To configure a fetched input, add a fetcher block to the input entry:
{
"key": "predispatch_price",
"trigger": "WAIT_FOR_LATEST_FILE",
"uploadFileFormat": "json",
"targetFileFormat": "json",
"fetcher": {
"type": "AEMO_MMS",
"checkInterval": 300,
"config": {
"checkQuery": "queries/data-fetchers/predispatch-price-check.sql",
"fetchQuery": "queries/data-fetchers/predispatch-price-fetch.sql"
}
}
}An AEMO MMS fetcher writes its data as JSON, so the CLI and publish reject an
input source that is a data fetcher and whose uploadFileFormat isn’t json.
The fetcher fields are:
| Field | Type | Description |
|---|---|---|
type | string | The data fetcher type. AEMO_MMS is the only type. |
checkInterval | number | Seconds between runs of the check query. Minimum 5. pd4castr starts a check within a second of the interval ending; a 5-second interval runs the check query 12 times a minute against the provider’s database. |
config.checkQuery | string | Path to the check query’s SQL file, relative to the project root. |
config.fetchQuery | string | Path to the fetch query’s SQL file, relative to the project root. |
config.fetchQueries | object | In place of config.fetchQuery, a map of query key to SQL file path. See Several Fetch Queries. |
statementTimeoutSeconds | number | Optional. Seconds the check query and each fetch query may run. Defaults to 10, and publish rejects a value above 900. pd4castr fetch and publish stop a query after 20 seconds. |
When a publish changes a check or fetch query, pd4castr publish warns you that
the data fetcher will fetch again. Within about a minute, pd4castr runs the new
fetch query and writes its result as a new file, whether or not new data is
available. That file can start a run straight away with the newest files of your
other inputs, so publish when those files still suit the data the new query
returns.
Several Fetch Queries
Declare fetchQueries in place of fetchQuery when your model needs several
tables from the same AEMO publication. A data fetcher declares exactly one of
the two. Each key of fetchQueries is a query key of lowercase letters, digits,
_ and -, starting with a letter or digit:
{
"key": "p5min",
"trigger": "WAIT_FOR_LATEST_FILE",
"uploadFileFormat": "json",
"targetFileFormat": "json",
"fetcher": {
"type": "AEMO_MMS",
"checkInterval": 60,
"statementTimeoutSeconds": 120,
"config": {
"checkQuery": "queries/check/p5min-loaded.sql",
"fetchQueries": {
"unit_solution": "queries/fetch/unit-solution.sql",
"region_solution": "queries/fetch/region-solution.sql"
}
}
}
}A fetch query can read a column of the check query’s result by its name, written
as :<column>. With a check query that returns run_datetime, the fetch query
SELECT * FROM mms.p5min_unitsolution WHERE run_datetime = :run_datetime reads
the AEMO publication the check found. A check query that a fetch query reads
from must return one row.
Every fetch query of one fetch reads the same database snapshot, so the files of
one fetch all come from the same AEMO publication. The fetch writes one file per
query, and a run starts only from a fetch whose every file was written. Your
model reads each file from INPUT_<KEY>_<QUERY_KEY>_URL, with both keys
uppercased and - replaced by _: the input above gives
INPUT_P5MIN_UNIT_SOLUTION_URL and INPUT_P5MIN_REGION_SOLUTION_URL.
In SQL, each file is the table <input_key>_<query_key>, or
input_<input_key>_<query_key> in a view
(Table names). The CLI rejects a config
where that name equals another input’s key or another query’s table name. An
input with fetchQueries can’t connect to a partition axis. When an input has
several input sources, every data fetcher
among them declares the same query keys in the same order.
Inputs with Several Input Sources
Every input has at least one input source, the file or data fetcher its data
comes from. An input that declares file or fetcher has one input source.
When the same input comes from more than one data provider, such as demand data
from an AEMO data fetcher and from a file a New Zealand provider sends you, you
can give it several input sources. Each input source then starts its own runs,
and each of those runs reads only that input source’s file. See
Input sources.
Trigger Types and Run Modes
A model in the AUTOMATIC run mode runs
when new input files arrive. Each input’s trigger decides whether a run waits
for that input:
WAIT_FOR_LATEST_FILE: a run waits until this input has a new file since the model’s last run.USE_MOST_RECENT_FILE: a run uses this input’s newest file, whenever that file arrived. Once the input has its first file, runs never wait for it.
An AUTOMATIC model runs as soon as every input has a file and every
WAIT_FOR_LATEST_FILE input has a new file since the model’s last run. Runs
started by hand count as the model’s last run too, and so does the run
pd4castr publish starts. When no input uses WAIT_FOR_LATEST_FILE, each new
file for any input starts a run. When an input has several input sources, each
input source follows these rules on its own, as
Input sources
describes.
Example Configuration
Here’s a complete inputs array with a fetched input and a static input:
{
"inputs": [
{
"key": "dispatch_price",
"trigger": "WAIT_FOR_LATEST_FILE",
"uploadFileFormat": "json",
"targetFileFormat": "json",
"fetcher": {
"type": "AEMO_MMS",
"checkInterval": 300,
"config": {
"checkQuery": "queries/data-fetchers/dispatch-price-check.sql",
"fetchQuery": "queries/data-fetchers/dispatch-price-fetch.sql"
}
}
},
{
"key": "regional_historical_prices",
"file": "test_input/regional_historical_prices.csv",
"trigger": "USE_MOST_RECENT_FILE",
"uploadFileFormat": "csv",
"targetFileFormat": "csv"
}
]
}pd4castr checks AEMO for new dispatch price data every 5 minutes and fetches it
when the check result changes. Each new dispatch price file starts a run,
because dispatch_price uses WAIT_FOR_LATEST_FILE. Every run also receives
the newest regional_historical_prices file, which the CLI uploaded at the last
publish.
Next Steps
- Use
pd4castr fetchto pull live data from your data fetchers into your localtest_input/directory. - See Input sources to give an input several input sources.
- See the Configuration File reference for the full schema.