Model Outputs
Your model produces forecast data by writing an output file to the platform.
During a model run, your model must upload its results to the URL specified by
the OUTPUT_URL environment variable using an HTTP PUT request. The platform
processes this file, stores the forecast data, and makes it available in the
pd4castr UI. A model can also upload
table outputs, each to its own URL. A table output holds rows
that describe the forecast, such as the name of each region the forecast covers.
How Output Works
When your container finishes its forecast, it uploads the output file as the
body of an HTTP PUT request to the URL in OUTPUT_URL. The file’s format is the
one the fileFormat field sets, as
Output Configuration describes.
Required Output
Every row of your forecast output must contain a forecast_datetime value. The
forecast chart in the pd4castr UI plots it on the x-axis.
forecast_datetime must be an ISO 8601 timestamp. Supported shapes:
| Example | Notes |
|---|---|
2024-01-01T00:30:00Z | UTC, no fractional seconds |
2024-01-01T00:30:00.000Z | UTC, with fractional seconds (any precision up to nanoseconds) |
2024-01-01T10:30:00+10:00 | Explicit timezone offset |
2024-01-01T00:30:00 | No timezone — interpreted as UTC |
2024-01-01T00:30:00.123456 | No timezone, with fractional seconds — interpreted as UTC |
Date.prototype.toISOString() (JavaScript) and datetime.isoformat() (Python)
both produce values in the supported set. The platform fails a model run whose
output holds a date-only string, an epoch number, a locale string, or any other
format.
pd4castr test enforces this contract locally, so invalid output fails the
local test command before you publish.
Output Configuration
The outputs object in your model’s
configuration file, .pd4castrrc.json,
describes each output file. One entry, the forecast output, sits under an output
key you choose, such as forecast. Every other entry is a
table output.
The forecast output takes one of two shapes:
wide: one row perforecast_datetime, with one column for each value the model forecasts at that time, such as one region’s price.long: one row perforecast_datetimeand combination of dimension values. A dimension is a column, such as a region, whose values identify which line of the forecast a row belongs to. Long outputs describes the shape.
| Field | Type | Required | Description |
|---|---|---|---|
shape | string | Yes | wide or long for the forecast output. |
fileFormat | string | Yes | json, csv, or parquet. |
dimensions | array | Required in long | One entry per dimension, with the fields in Long outputs. |
columns | array | Yes | One entry per column, with the fields described below. |
List every column of the file in columns except forecast_datetime. In a
long output, leave the dimensions out of columns as well. Each entry has
these fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The column’s name in the pd4castr UI. |
key | string | Yes | The column’s name in the output file. |
type | string | Yes | float, integer, string, date, or boolean. |
seriesKey | boolean | Required in wide | true to plot the column as a line on the forecast chart. |
colour | string | No | The line’s colour, as a hex code such as #84EDDC. |
unit | string | No | The column’s unit, such as MW. At most 32 characters. |
A long output’s columns take neither seriesKey nor colour, and the CLI
rejects a column that sets either.
The forecast chart and table on the model page format each value by its column’s
unit. When no column shown declares a unit, the values show as prices, so a
model that forecasts something other than a price sets unit on its columns:
| Units on the columns shown | Tooltip and table value | Chart axis |
|---|---|---|
| One unit on every column | 1,200.00 MW | MW |
| Different units, or a unit on only some columns | 1,200.00 MW, or 1,200.00 | No unit |
| No unit on any column | $1,200.00 | $/MWh |
A model that forecasts the probability of a price spike sets forecastVariable
to price_spike_probability and writes values between 0 and 1. The forecast
chart then draws its axis from 0 to 1, whatever the highest value in the period,
and the chart and table show each value as a plain number such as 0.31. The
model page has a button that hides the axis.
A column key starts with a lowercase letter or a digit and continues with
lowercase letters, digits, - and _. No two columns of an output share a key.
Older configs declare outputs as a list of columns. The CLI still reads them,
as
Configs with an outputs list
describes.
Keep a column’s key stable
The platform matches a column’s data across republishes by its key. If you
change a column’s key, the UI stops showing that column’s data from earlier
runs. Its name can change freely.
Example: five regional prices
Here’s a complete outputs configuration for a price forecast model that covers
five Australian energy regions:
{
"outputs": {
"forecast": {
"shape": "wide",
"fileFormat": "json",
"columns": [
{
"name": "NSW1",
"key": "nsw1",
"type": "float",
"seriesKey": true,
"colour": "#84EDDC"
},
{
"name": "QLD1",
"key": "qld1",
"type": "float",
"seriesKey": true,
"colour": "#FD4E4E"
},
{
"name": "SA1",
"key": "sa1",
"type": "float",
"seriesKey": true,
"colour": "#FED600"
},
{
"name": "TAS1",
"key": "tas1",
"type": "float",
"seriesKey": true,
"colour": "#40A967"
},
{
"name": "VIC1",
"key": "vic1",
"type": "float",
"seriesKey": true,
"colour": "#1965C6"
}
]
}
}
}Each row of this output holds forecast_datetime and one price per region. The
forecast chart draws five lines, one per region, each in its column’s colour.
Long outputs
A long output holds one row per forecast_datetime and combination of
dimension values. Each combination is one series, and each column holds that
series’ value. A forecast of expected generation per region and group of
generating units has region_id and group_id dimensions and an
expected_generation column:
{
"outputs": {
"generation": {
"shape": "long",
"fileFormat": "parquet",
"dimensions": [
{
"key": "region_id",
"type": "string",
"values": ["NSW1", "QLD1", "SA1", "TAS1", "VIC1"]
},
{ "key": "group_id", "type": "string" }
],
"columns": [
{
"name": "Expected generation",
"key": "expected_generation",
"type": "float"
}
]
}
}
}Each row of this output holds forecast_datetime, region_id, group_id and
expected_generation. Each entry of dimensions has these fields:
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The dimension’s column in the output file. |
type | string | Yes | string, integer, or boolean. |
values | array | No | The only values a row may hold. Each value matches the dimension’s type. |
describedBy | string | No | The key of a table output that lists the dimension’s values. |
labelColumn | string | No | The column of the describedBy output that labels each value. |
The CLI rejects a dimension that sets only one of describedBy and
labelColumn. Describing a dimension shows the pair
in use.
A dimension key follows the rules for a column key, and no two dimensions or
columns of an output share a key.
When the platform processes a run’s output, it fails the run if any row has no
value for a dimension, or a value outside the dimension’s values. The run’s
error message gives the key the output has in outputs, the row number, the
dimension and the rejected value. pd4castr test runs the same checks locally.
The forecast chart and table on the model page don’t show a long output, so
the model’s views are where its forecast appears
in the pd4castr UI. Through the pd4castr API, the run output endpoints return
every row of a long output. Their dimension query parameter keeps only the
rows that hold a chosen value, such as dimension=region_id:NSW1. Repeat the
parameter to accept several values of one dimension, or to filter on several
dimensions, where a row must match each one.
Table outputs
A table output is a file of rows with no forecast_datetime, such as one row
per group of generating units with the group’s id and name. Its shape is
table, and it declares its columns and, optionally, a primaryKey:
{
"outputs": {
"groups": {
"shape": "table",
"fileFormat": "parquet",
"primaryKey": ["group_id"],
"columns": [
{ "key": "group_id", "type": "string" },
{ "key": "group_name", "type": "string" }
]
}
}
}Each entry of a table output’s columns has these fields:
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The column’s name in the output file. |
type | string | Yes | float, integer, string, date, or boolean. |
name | string | No | A readable name for the column, which the CLI prints in its summary. |
references | string | No | <output_key>.<column_key> of a primaryKey column of a table output. |
primaryKey lists the keys of the columns whose values together identify a row,
as Checks on table outputs describes.
Uploading a table output
Your model uploads each table output with an HTTP PUT request to the URL in its
own environment variable, OUTPUT_<KEY>_URL. The variable’s name holds the
output key uppercased, with - replaced by _, so the groups output above
uploads to the URL in OUTPUT_GROUPS_URL.
Upload every table output, and wait for each upload to finish, before you upload
the forecast output. The upload to OUTPUT_URL starts output processing, which
waits up to a minute for a table output’s file to arrive and then fails the run.
pd4castr test fails when a table output finishes uploading after the forecast
output.
Describing a dimension
A long output’s dimension can set describedBy to the key of a table output
that lists the dimension’s values, and labelColumn to the column of that table
output that holds each value’s label. The describedBy output’s primaryKey is
exactly one column, which holds the dimension’s values, and the CLI rejects a
describedBy output with any other primaryKey. pd4castr checks that every
value of the dimension appears in that column. The app doesn’t show the label
yet, so to show names, join the table output in a view. This config describes
each group_id value with a row of the groups output:
{
"outputs": {
"generation": {
"shape": "long",
"fileFormat": "parquet",
"dimensions": [
{
"key": "group_id",
"type": "string",
"describedBy": "groups",
"labelColumn": "group_name"
}
],
"columns": [
{
"name": "Expected generation",
"key": "expected_generation",
"type": "float"
}
]
},
"groups": {
"shape": "table",
"fileFormat": "parquet",
"primaryKey": ["group_id"],
"columns": [
{ "key": "group_id", "type": "string" },
{ "key": "group_name", "type": "string" }
]
}
}
}Referencing another table output
A table output’s column can set references to a column of a table output, as
<output_key>.<column_key>. A units output whose group_id column sets
"references": "groups.group_id" holds only group ids that the groups output
lists. The CLI rejects a references that doesn’t point at a primaryKey
column.
Checks on table outputs
When the platform processes a run’s output, it fails the run if:
- a table output still has no file a minute after output processing starts;
- a table output is too large for the platform to check;
- the file of a table output has no column for one of the declared columns;
- a row of a table output holds no value, or
null, in aprimaryKeycolumn; - two rows of a table output hold the same
primaryKeyvalues; - a value of a column with
referencesis missing from the column it references; - a value of a dimension with
describedByis missing from theprimaryKeycolumn of the table output that describes it.
The platform accepts a table output with no rows. The run’s error message gives
the key of each output involved, the column, the row number and the value.
pd4castr test runs these checks locally on the files your model uploads, and
also fails a row that leaves out the field of a declared column.
Reading a table output
A view’s SQL reads the forecast output from the SQL table output and each
table output from the SQL table output_<key>. A view can join output to
output_groups to show each group’s name. See
Model run views for how a view’s SQL reads a run.
The public pd4castr API, documented in the API reference, doesn’t serve table outputs yet: its run output endpoints return the forecast output’s rows only.
Next Steps
- See the Configuration File reference for the
rest of
.pd4castrrc.json. - Learn about Sensitivities to run alternative versions of your model with modified inputs.