Skip to content

Commit

Permalink
Log a warning when no tree is loaded
Browse files Browse the repository at this point in the history
It would have made problems like #38 easier to diagnose and debug
  • Loading branch information
tomtung committed Feb 1, 2022
1 parent fe16cb3 commit 07a0291
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 })
}

Expand Down

0 comments on commit 07a0291

Please sign in to comment.