feat(navi/dr_transform): add filename:line to file reader error message

This commit is contained in:
Pouriya Jahanbakhsh 2023-04-01 02:33:51 +03:30
parent 2dbdfe173c
commit ee5e7fc18d

View file

@ -9,15 +9,17 @@ use std::{
pub fn load_batch_prediction_request_base64(file_name: &str) -> Vec<Vec<u8>> {
let file = File::open(file_name).expect("could not read file");
let mut result = vec![];
for line in io::BufReader::new(file).lines() {
for (mut line_count, line) in io::BufReader::new(file).lines().enumerate() {
line_count += 1;
match base64::decode(line.unwrap().trim()) {
Ok(payload) => result.push(payload),
Err(err) => println!("error decoding line {err}"),
Err(err) => println!("error decoding line {file_name}:{line_count} - {err}"),
}
}
println!("result len: {}", result.len());
return result
result
}
pub fn save_to_npy<T: npyz::Serialize + AutoSerialize>(data: &[T], save_to: String) {
let mut writer = WriteOptions::new()
.default_dtype()