Skip to content

Commit

Permalink
PUBDEV-8314: ensure that models without metrics are not added to lead…
Browse files Browse the repository at this point in the history
…erboard (#5666)

* ensure that models without metrics are not added to leaderboard

* improved warning messages

* trailing spaces
  • Loading branch information
Seb committed Sep 2, 2021
1 parent f371a8d commit 2e469c0
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,25 +356,39 @@ public void addModels(final Key<Model>[] modelKeys) {

final List<ModelMetrics> modelMetrics = new ArrayList<>();
final Map<Key<Model>, LeaderboardCell[]> extensions = new HashMap<>();

final List<Key<Model>> badKeys = new ArrayList<>();
for (Key<Model> modelKey : allModelKeys) { // fully rebuilding modelMetrics, so we loop through all keys, not only new ones
Model model = modelKey.get();
if (model == null) {
eventLog().warn(Stage.ModelTraining, "Model in the leaderboard has unexpectedly been deleted from H2O: " + modelKey);
badKeys.add(modelKey);
eventLog().warn(Stage.ModelTraining, "Model `"+modelKey+"` has unexpectedly been deleted from H2O: ignoring the model and/or removing it from the leaderboard.");
continue;
}

if (_extensionsProvider != null) {
extensions.put(modelKey, _extensionsProvider.createExtensions(model));
}
modelMetrics.add(getOrCreateModelMetrics(modelKey, extensions));
ModelMetrics mm = getOrCreateModelMetrics(modelKey, extensions);
assert mm != null: "Missing metrics for model "+modelKey;
if (mm == null) {
badKeys.add(modelKey);
eventLog().warn(Stage.ModelTraining, "Metrics for model `"+modelKey+"` are missing: ignoring the model and/or removing it from the leaderboard.");
continue;
}
modelMetrics.add(mm);
}

if (_metrics == null) {
// lazily set to default for this model category
setDefaultMetrics(modelKeys[0].get());
}

for (Key<Model> key : badKeys) {
// keep everything clean for the update
allModelKeys.remove(key);
extensions.remove(key);
}

atomicUpdate(() -> {
_leaderboard_model_metrics.clear();
modelMetrics.forEach(this::addModelMetrics);
Expand Down

0 comments on commit 2e469c0

Please sign in to comment.