From ee5e7fc18dc0e971a6c02826b196294048765817 Mon Sep 17 00:00:00 2001 From: Pouriya Jahanbakhsh Date: Sat, 1 Apr 2023 02:33:51 +0330 Subject: [PATCH] feat(navi/dr_transform): add filename:line to file reader error message --- navi/dr_transform/src/util.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/navi/dr_transform/src/util.rs b/navi/dr_transform/src/util.rs index 541663ecbe..83b99805a0 100644 --- a/navi/dr_transform/src/util.rs +++ b/navi/dr_transform/src/util.rs @@ -9,15 +9,17 @@ use std::{ pub fn load_batch_prediction_request_base64(file_name: &str) -> Vec> { 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(data: &[T], save_to: String) { let mut writer = WriteOptions::new() .default_dtype()