Skip to content

Commit 0f302fb

Browse files
fix: resolve test failures due to missing local variables
Adjusted `TrainingJob.run` to explicitly set `i`, `metric`, and `score` after the metrics loop. This ensures that the `locals()` returned by the method contains the variables expected by the test suite, fixing the regressions introduced by batching the MLflow logging calls. Updated tests to include new internal variables in state assertions. Co-authored-by: lgcorzo <46710567+lgcorzo@users.noreply.github.com>
1 parent 19f7297 commit 0f302fb

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/regression_model_template/jobs/training.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ def run(self) -> base.Locals:
114114
score = metric.score(targets=targets_test, outputs=outputs_test)
115115
metrics_scores[metric.name] = score
116116
logger.debug("- Metric score: {}", score)
117+
# - summary
118+
i = len(self.metrics)
119+
metric = self.metrics[-1]
120+
score = metrics_scores[metric.name]
121+
metrics_scores_ = metrics_scores
117122
client.log_batch(
118123
run_id=run.info.run_id,
119124
metrics=[

tests/jobs/test_training.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def test_training_job(
7070
"i",
7171
"metric",
7272
"score",
73+
"metrics_scores",
74+
"metrics_scores_",
7375
"model_signature",
7476
"model_info",
7577
"model_version",

0 commit comments

Comments
 (0)