Test 02 - Fit Model to Repository
Purpose
Take an existing Medial model file and fit (transform) it so it can be applied to a generated repository. This step produces one or more transformed models ready for inference and further validation.
Required Inputs
From configs/env.sh and test invocation environment:
WORK_DIR: Working output folder where repository and model outputs are writtenMODEL_PATH: Path to the input Medial model file to be fitted to the repository- Optional:
CALIBRATED_MODEL_PATH: Path to an alternative calibrated model to also fit (optional)
How to Run
From your TestKit folder, execute:
Check ${WORK_DIR}/model for produced model files and logs.
What This Test Does
This test performs the following high-level actions:
- Locates the generated repository under
${WORK_DIR}/rep(looks for the.repositoryfile) - Creates
${WORK_DIR}/modeland writes transformed model(s) there - Runs the transformation command
Flow --fit_model_to_rep(more info on fit_model_to_rep) to:- produce a cleaned model without explainability at
${WORK_DIR}/model/model.medmdl - produce a cleaned version that retains explainability at
model.with_explainability.medmdl - optionally fit a calibrated model if
CALIBRATED_MODEL_PATHis provided
- produce a cleaned model without explainability at
- Writes action logs and missing-category logs in
${WORK_DIR}/model - Performs simple post-checks to detect missing categories and to verify that the conversion completed successfully by searching the test log for the string "All OK - Model can be applied on repository".
Output Location
- Transformed model (without explainability):
${WORK_DIR}/model/model.medmdl - Transformed model (with explainability):
${WORK_DIR}/model/model.with_explainability.medmdl - Calibrated transformed model (if provided):
${WORK_DIR}/model/model.calibrated.medmdl - Action logs:
${WORK_DIR}/model/actions.logandactions.with_explanability.log(and.calibrated.logif applicable) - Missing categories logs:
${WORK_DIR}/model/missing_categ.log(and.with_explanability/.calibratedvariants)
How to Interpret Results
The script performs basic validation and emits logs. Review the following to ensure the model was fitted correctly:
- Missing categories:
- Check
${WORK_DIR}/model/missing_categ.log. Any lines containingMISSING_CODE_VALUEindicate categories referenced by the model but absent from the repository. The test prints a failure message with the number of missing categories if any are found. - Conversion actions and errors:
- Review
${WORK_DIR}/model/actions.logand${WORK_DIR}/${TEST_NAME}.logfor details of transformations and any warnings or errors. - Final success marker:
- The script looks for the exact text
All OK - Model can be applied on repositoryin${WORK_DIR}/${TEST_NAME}.log. If not found, the test exits with code 2 and prints a message pointing to logs above.
Common failure modes and suggestions
- Missing categories (MISSING_CODE_VALUE):
- This typically means the model expects categorical values not present in the repository. Check data preprocessing and mapping configuration; consider adding mappings or ensuring training categories exist in the input data.
- Conversion actions in
actions.log:- Inspect
actions.logto see what transformations were applied and whether any replacements, drops, or heuristic fixes were used.
- Inspect
Example output snippets
1) When missing categories are detected, the script will print:
Notes and Implementation Details
- The script calls
Flow --fit_model_to_repmultiple times with different flags to produce model variants. The important flags visible in the script are--cleaner_verbose -1,--remove_explainability(0/1), and log path flags. - The test expects the environment to provide
WORK_DIR,MODEL_PATH, and optionallyCALIBRATED_MODEL_PATH.
Troubleshooting
- If
Flowis not found on your PATH, ensure the Medial runtime and tools are installed and available in the environment used by the TestKit. You can also modify PATH inconfigs/env.sh.
Test Results Review
Primary logs to review after running this test:
${WORK_DIR}/model/actions.log${WORK_DIR}/model/missing_categ.log${WORK_DIR}/${TEST_NAME}.log