<aside> 📘

Tutorial 3 of the Kalix tutorial series. You'll reorganise Tutorial 2's Stringybark model into a typical multi-folder project layout, add a wetter-climate scenario at a deeper folder, and switch from fragile relative paths to portable trailhead paths. Expected time: about 15 minutes.

</aside>

What you'll build

A small project with shared input data in one place and two model variants — a baseline and a wetter scenario — at different depths under a models/ folder. Along the way you'll experience how relative paths break, and you’ll fix it once-and-for-all using Kalix's trailhead paths.

image.png

image.png

Prerequisites

003/
├── data/
│   ├── climate_data.csv
│   ├── observed.csv
│   ├── rain_north.csv
│   ├── rain_central.csv
│   └── rain_south.csv
└── models/
    └── baseline/
        └── stringybark.ini

The three path styles

Kalix accepts three styles of path in [inputs]:

Style Example How it resolves
Absolute /Users/chas/data/climate.csv
C:/data/climate.csv Resolved exactly as written. Always points to the same place on this machine; never travels.
Relative ../data/climate.csv Resolved against the folder the model file lives in. Travels as long as the folder structure around the model stays the same.
Trailhead ^/data/climate.csv Starts at the model's folder and searches upward through parent folders until the target is found. Travels gracefully when models move to different depths.

<aside> 📚

For the full reference on path syntax and resolution, see Declaring Input Data.

</aside>

Step 1 — Run the baseline

Open models/baseline/stringybark.ini in Kalix IDE. The [inputs] section uses relative paths — each one starts with ../../ to step up out of baseline/ and models/, then into data/:

[inputs]
../../data/climate_data.csv
../../data/observed.csv
../../data/rain_north.csv
../../data/rain_central.csv
../../data/rain_south.csv

Run the model. It works — the relative paths resolve correctly because ../../data/... does in fact point at the data folder from where this model sits.

image.png

Step 2 — Add a wetter-climate scenario

Now imagine you want to explore what happens if rainfall is 20% higher. The clean way to manage variants is to put each scenario in its own folder so files don't collide.

Create a new folder models/scenarios/wetter/, then copy baseline/stringybark.ini into it. Your tree should now look like: