Testing Your Model
Before publishing, you can validate that your model container correctly handles
its inputs and produces output. The pd4castr CLI provides two commands for local
testing: pd4castr fetch to pull live data from configured data sources, and
pd4castr test to build and run your container locally.
Fetching test data
The pd4castr fetch command pulls live data from your configured data fetchers
into the local test_input/ directory. Only inputs that have a fetcher block
are fetched — static inputs are skipped automatically.
For AEMO MMS fetchers, the CLI reads your fetch query SQL file, sends it to the
pd4castr API, and writes the result as <key>.<targetFileFormat> in the input
directory.
You must be authenticated before running this command. Run pd4castr login
first if you haven’t already.
pd4castr fetchFetch command flags
| Flag | Default | Description |
|---|---|---|
-i, --input-dir | test_input | Directory to write fetched data. |
-c, --config | .pd4castrrc.json | Path to the config file. |
Local testing
The pd4castr test command validates that your model Docker container correctly
fetches its inputs and uploads its output. It simulates the platform’s IO
contract locally so you can catch issues before publishing.
pd4castr testWhat the test command does
The test command runs through these steps:
- Validates your
.pd4castrrc.jsonconfiguration against the schema. - Checks that all expected input files exist in the input directory.
- Builds the Docker image with
docker build --platform=linux/amd64 -t <image> . - Starts a local web server to serve input files and capture output.
- Runs the container with
INPUT_<KEY>_URLandOUTPUT_URLenvironment variables pointing to the local server. - Reports pass or fail for each input fetch and the output upload.
- On success, saves the captured output to the
test_output/directory.
Test command flags
| Flag | Default | Description |
|---|---|---|
-i, --input-dir | test_input | Directory containing test input files. |
-p, --port | 9800 | Port for the local IO testing web server. |
-c, --config | .pd4castrrc.json | Path to the config file. |
Model container IO contract
Your model container must fulfil a specific IO contract for the test (and production runs) to pass.
The container must:
- Fetch each input from its
INPUT_<KEY>_URLenvironment variable using an HTTP GET request. - Upload the output to the
OUTPUT_URLenvironment variable using an HTTP PUT request.
The test passes only if all inputs are fetched and the output is uploaded. If any input is missed or the output isn’t uploaded, the test fails.
During local testing, input URLs follow this pattern:
http://host.docker.internal:<port>/input/<key>.<format>For example, an input with key dispatch_price and format json on the default
port is served at:
http://host.docker.internal:9800/input/dispatch_price.jsonWSL support
If you’re running Docker on Windows via WSL (Windows Subsystem for Linux), the
container connects via the WSL machine’s eth0 IP address instead of
host.docker.internal.
To override the network interface, set the PD4CASTR_WSL_NETWORK_INTERFACE
environment variable:
export PD4CASTR_WSL_NETWORK_INTERFACE=eth1
pd4castr testTypical workflow
Here’s the recommended sequence of commands when developing and testing your model:
pd4castr fetch # Pull latest data from configured fetchers
pd4castr test # Build and validate locally
# Iterate on model code...
pd4castr test # Re-test after changes
pd4castr publish # Ship it when the tests passNext steps
- See Model inputs for details on configuring fetchers and static inputs.
- When your tests pass, move on to Publishing to ship your model.