From 07a0291620579e91dc96777702df9b6c0498a827 Mon Sep 17 00:00:00 2001 From: "Yubing Dong (Tom)" Date: Tue, 1 Feb 2022 00:59:26 -0800 Subject: [PATCH] Log a warning when no tree is loaded It would have made problems like #38 easier to diagnose and debug --- src/model/mod.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/model/mod.rs b/src/model/mod.rs index b4c442f..0300713 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -7,7 +7,7 @@ use crate::mat_util::*; use crate::{Index, IndexValueVec}; use hashbrown::HashMap; use itertools::Itertools; -use log::info; +use log::{info, warn}; use ordered_float::NotNan; use rayon::prelude::*; use serde::{Deserialize, Serialize}; @@ -217,10 +217,18 @@ impl Model { trees.push(tree); } - info!( - "Model loaded; it took {:.2}s", - start_t.elapsed().as_secs_f32() - ); + if !trees.is_empty() { + info!( + "Loaded model with {} trees; it took {:.2}s", + trees.len(), + start_t.elapsed().as_secs_f32() + ); + } else { + warn!( + "Failed to load any trees from model directory {}; returning an empty model", + dir_path.display() + ) + } Ok(Self { trees, settings }) }