Package a prepare function, its schema and its examples with a rater, so one bundle carries
the whole program.
Install Relativities and download the example data before running this page.
Bundles and exact rating describes how a bundle carries
and verifies its program.
Lay out the program folder
Put the program module, its helpers and the examples in one folder.
- Import each helper relatively, as
from .common import ages.
- In
program.py, define prepare(book), which returns each submission’s rater input by
submission_id.
- Also define
SCHEMA, such as SCHEMA = ppa.SCHEMA. Use with_columns to declare a column
of your own that prepare reads.
- Put a small book in
examples/book, in the Book.read_csv layout.
Write the expected outcomes
Write one row per example submission in expected.csv.
- Write the
submission_id and status columns.
- Add the rater’s outcome columns that you want to check, such as
premium.
- For a submission that stays unrated, leave its outcome cells empty.
Pack the program
Call Program.pack with the rater, the folder and a new .zip
path.
- Name
prepare and the schema as "module:name", such as "program:prepare" and
"program:SCHEMA".
- To choose the result columns, name a
read function the same way, such as "program:read".
- To add examples, name their folder, such as
"examples".
Program.pack writes the bundle, loads it and checks its examples. The bundle gets a new
bundle_id, and the rater’s own ID stays as engine_id.
Load the program
To load a packaged program, call Program.load with a Path or a catalog ID.
Program.load takes revision= and local_files_only= as Rater.load does. program.examples
holds the example book, and program.expected holds the expected table.
Loading a program runs its Python. Load programs from your own catalog or from files you trust.
Check the examples
Call program.check() to rate the examples again.
The table puts each expected value beside the rated one. Numbers match within half a cent. A
mismatch raises CheckError, and its comparison holds the table.
Carry the program to a rebuilt rater
To move the program to a rater rebuilt from edited RSL, call program.with_rater.
This rebuilt rater has a liability base rate of 400. The examples keep their statuses, so with_rater returns the program with the new outcomes as expected values.
A status change raises CheckError with the submission ID.
with_rater refreshes the expected premiums from the replacement rater. Those refreshed values need independent validation against the intended change.
Use Validate a program before accepting them as regression expectations.
Close the programs
Close each program to close its rater.
with Program.load(...) as program: closes the program at the end of the block.