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 fetchers, and
pd4castr test to build and run your model locally.
Fetching Test Data
The pd4castr fetch command pulls live data from your configured data fetchers
into the local test_input/ directory. It fetches an input with its own
fetcher block and skips static inputs.
For an input with several input sources, the command fetches only the default input source, when that input source is a data fetcher, and lists the input sources it skips.
A data fetcher with
several fetch queries writes
one file per query, at test_input/<key>/<query_key>.<targetFileFormat>. The
CLI sends each fetch query with the check query, which the platform runs first
and binds into the fetch query the way a scheduled fetch does. pd4castr test
then serves each file at its own INPUT_<KEY>_<QUERY_KEY>_URL.
pd4castr fetch stops each query after 20 seconds, even when the fetcher’s
statementTimeoutSeconds is longer, so it can’t fetch test data with a query
that runs longer than 20 seconds. With fetchQueries, the check query and the
fetch query together also need to finish inside the request’s 30 seconds.
Scheduled fetches run under the full statementTimeoutSeconds
(Data fetcher queries).
You must be authenticated before running this command. Run pd4castr login
first if you haven’t already.
pd4castr fetchFetch Command Flags
The following flags are available for the pd4castr fetch command:
| Flag | Default | Description |
|---|---|---|
-c, --config | .pd4castrrc.json | Path to the config file. |
The command writes fetched data to the test_input/ directory.
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. - Checks that all expected input files exist, including the file of every input source that has one. For an input with several input sources, the test runs on the default input source.
- Builds your model’s Docker image.
- Runs your model’s container with the input files in the input directory.
- Reports pass or fail for each input fetch and the output upload.
- On success, saves the captured output to the
test_output/directory.
pd4castr publish runs this same validation before its own I/O test, so these
rules apply at publish time too.
Test Command Flags
The following flags are available for the pd4castr test command:
| Flag | Default | Description |
|---|---|---|
-c, --config | .pd4castrrc.json | Path to the config file. |
-p, --port | 9800 | Port for the local testing server. |
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.
Typical 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.