Model Axes

An axis lets one model run several times on every trigger, once for each value you declare. This page covers when to use an axis, how axes change your runs, how to declare one, and how to partition an input or dataset so each run reads only its own rows.

A trigger is the event that starts a model’s runs: new input data arriving, or someone pressing “Run model”, as Run modes and scheduling describes. Without axes, each trigger starts one run, plus one run for each sensitivity. Declare a ref_year axis with the values 2023, 2024, and 2025, and every trigger starts three runs instead of one: the same model, run once per reference year.

When to Use an Axis

Declare an axis when the same forecast logic runs over a dimension of your data, such as one run per reference year. Your model code stays the same, every result sits under a single model, and people choose which axis values to view in the pd4castr app. Without an axis, you would publish one model per value.

To give each run its own slice of the data, partition an input by the axis: the 2024 run then reads only the 2024 rows. An input you don’t partition reaches every run whole, and no environment variable holds a run’s axis values. So when a model partitions none of its inputs, every run from a trigger does the same work.

A sensitivity and an axis vary different things. A sensitivity changes a run’s input data with a SQL query. An axis value picks a run’s slice of a partitioned input. A model can use both.

An input that comes from more than one data provider uses a special kind of axis, the source-binding axis, which Input sources covers.

How Axes Change Your Runs

Each combination of axis values is a variant. A trigger starts one run per variant, plus one more run per variant for each sensitivity:

runs per trigger = (product of each axis's value count) × (1 + number of sensitivities)

A model with a three-value ref_year axis, a second axis with two values, and three sensitivities starts 3 × 2 × (1 + 3) = 24 runs every time it triggers. All 24 runs share one run datetime, the runDatetime value that labels a set of runs in the app and the API. Custom run datetime describes how pd4castr sets it.

The base run is the run people get without choosing anything: the variant with every axis at its default, with no sensitivity applied. The app opens on it, and the API’s Get the latest run returns it unless the request picks other axis values.

A model can start at most 200 runs per trigger, counted with the formula above. An axis can hold at most 100 values. The CLI checks your configuration against both limits before it uploads anything, so a publish over either limit fails in your terminal. On a model with several input sources, each trigger belongs to one input source, so the formula leaves out the source-binding axis. The CLI adds up every input source’s runs and checks the total against the 200-run limit. If you need more runs than these limits allow, contact us to discuss your requirements.

What Your Model Container Sees

Your model code needs no changes for an axis. The container receives the same environment variables as on a model without axes: one INPUT_<KEY>_URL per input, plus OUTPUT_URL and MODEL_RUN_ID. No environment variable holds the run’s axis values.

For an input you partition by an axis, the file behind INPUT_<KEY>_URL holds only the rows for the run’s own value, so the 2024 run downloads the 2024 rows and nothing else. The partition column stays in the file, holding the run’s own value on every row. Queries that filter or group by that column keep working.

Configuration

Declare axes in the axes array in .pd4castrrc.json. Each entry has the following fields.

FieldTypeRequiredDescription
keystringYesIdentifier for this axis. Lowercase letters and digits, with hyphens or underscores. Unique within the model.
labelstringNoName the pd4castr app shows above the axis’s values.
descriptionstringNoHelp text in the axis’s tooltip in the pd4castr app.
typestringYesThe value type: number, string, or boolean.
valuesFromobjectYesThe axis’s values, as { "kind": "static", "values": [...] } with at least one value.
defaultmatches typeYesThe axis’s value in the base run. One of the values in valuesFrom.values.

An axis that lists its own values is a static axis. A source-binding axis declares "type": "string" and "valuesFrom": { "kind": "source-binding" } instead. Its values are the input source keys of the inputs connected to it, and its default is one of those keys, as Input sources describes.

Declared values must be unique within the axis and match the declared type. A number value is a whole number from 0 to 9,007,199,254,740,991, the largest whole number JavaScript represents exactly. A string value can’t be empty, can hold letters, digits, underscores, dots, and hyphens, and must start with a letter or a digit.

Here’s a ref_year axis with three values and a default:

{
  "axes": [
    {
      "key": "ref_year",
      "label": "Reference Year",
      "type": "number",
      "valuesFrom": {
        "kind": "static",
        "values": [2023, 2024, 2025]
      },
      "default": 2024
    }
  ]
}

Partitioning Inputs and Datasets by an Axis

To give each run only its own rows of an input or dataset, partition it by an axis: in the input’s or dataset’s own axes field, map the axis to the column of the file that holds the axis’s values. An input or dataset that maps no axis is shared, and every run gets its whole file.

"inputs": [
  {
    "key": "forecast_values",
    "axes": { "ref_year": { "kind": "partition", "column": "REF_YR" } }
  },
  { "key": "mt" }
]

Each run reads only its own year’s rows of forecast_values. mt maps no axis, so every run gets the whole file, unchanged.

When you partition an input or dataset:

  • Partition only a static input, and declare both its uploadFileFormat and targetFileFormat as parquet.
  • Declare a partitioned dataset’s fileFormat as parquet.
  • Partition it by one axis at most, declared in the model’s axes array.

An input with several input sources can’t be partitioned.

The partitioned file must follow three rules:

  • Every row has a value in the partition column.
  • Every value the axis declares appears in the column.
  • The column holds at most 100 distinct values. pd4castr splits the file by every distinct value, so values the axis doesn’t declare count towards the 100, although no run reads their rows.

The CLI checks the file before it uploads anything, so a file that breaks a rule fails the publish in your terminal. pd4castr rejects a file uploaded between publishes that breaks a rule, and starts no runs from it.

Axis Values in Model Run Views

A view parameter can default to the axis value of the run that the view executes against, with defaultFrom: "run.axis.<key>". See Model run views.

What You See in the App

The app shows each axis as a checklist of its values, headed by the axis’s label, with its description as a tooltip. It opens on the base run, with every axis at its default.

Changing Axes on a Published Model

You can republish a model by updating its current revision in place or by creating a new revision, as Updating an existing model describes. The base run is the variant with every axis at its default, so adding an axis, removing one, or moving an axis’s default changes which variant is the base run. An update in place can’t change which variant is the base run, so the CLI and the API reject those three changes in an update in place. Publish a new revision for any of them.

An update in place can add or remove a value other than the default. The app no longer offers a removed value, so its earlier runs drop out of view. The API’s run list still includes them when you don’t filter by axis.

The API rejects a publish that declares an axis key with a different type from an earlier revision in the same model group. To change an axis’s value type, declare a new key.

Custom Run Datetime Queries

A custom run datetime query runs once for each run. When it reads only unpartitioned inputs, every run reads the same rows, so every run from one trigger gets the same runDatetime and the app shows them as one set of runs.

Keep the query away from partitioned inputs. Each run reads different rows of a partitioned input, so the query can give each run its own runDatetime, and the app then shows the runs from one trigger at different run datetimes.

On a model with several input sources, the query can read an input with several input sources. Every run from one trigger reads the same input source’s file, so those runs still share one runDatetime.

Next Steps