From f85e083198cc9d502beefeda2be97513dbedbad3 Mon Sep 17 00:00:00 2001 From: Thomas Krause Date: Wed, 20 Sep 2023 08:23:06 +0200 Subject: [PATCH 1/2] Report progress when importing a single Excel file --- Cargo.toml | 13 +++++++------ src/importer/spreadsheet.rs | 33 +++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3644d56d..01ac6c09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,12 +56,13 @@ tower = {version = "0.4", features = ["util"]} default = ["embed-documentation"] embed-documentation = ["dep:include_dir", "dep:axum", "dep:tokio", "dep:mime_guess", "dep:portpicker", "dep:open"] -# Compile some of the dev dependencies in release mode -[profile.dev.package.insta] -opt-level = 3 - -[profile.dev.package.similar] -opt-level = 3 +# Compile some of the dependencies in release mode if when we are ourself in +# "dev" mode (like building debug binaries or running tests) +[profile.dev.package] +graphannis-core.opt-level = 3 +graphannis.opt-level = 3 +insta.opt-level = 3 +similar.opt-level = 3 [profile.release] panic = 'abort' diff --git a/src/importer/spreadsheet.rs b/src/importer/spreadsheet.rs index 1dbc7b41..90ca94ec 100644 --- a/src/importer/spreadsheet.rs +++ b/src/importer/spreadsheet.rs @@ -301,16 +301,29 @@ impl Importer for ImportSpreadsheet { let mut update = GraphUpdate::default(); let column_map = &self.column_map; let all_files = get_all_files(input_path, vec!["xlsx"])?; - all_files.into_iter().try_for_each(|pb| { - import_workbook( - &mut update, - input_path, - pb.as_path(), - column_map, - &self.fallback, - &tx, - ) - })?; + let number_of_files = all_files.len(); + all_files + .into_iter() + .enumerate() + .try_for_each(|(job_nr, pb)| { + let result = import_workbook( + &mut update, + input_path, + pb.as_path(), + column_map, + &self.fallback, + &tx, + ); + + if let Some(tx) = &tx { + tx.send(StatusMessage::Progress { + id: self.step_id(Some(&pb)), + total_work: number_of_files, + finished_work: job_nr, + })?; + } + result + })?; Ok(update) } } From ab95517fe166537f2f5ff6cfef43555223be514a Mon Sep 17 00:00:00 2001 From: Thomas Krause Date: Wed, 20 Sep 2023 08:27:14 +0200 Subject: [PATCH 2/2] Send progress before running the import. The job_nr is the index of the current job, so 0 for the first, 1 for the second and so on. --- src/importer/spreadsheet.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/importer/spreadsheet.rs b/src/importer/spreadsheet.rs index 90ca94ec..29332565 100644 --- a/src/importer/spreadsheet.rs +++ b/src/importer/spreadsheet.rs @@ -306,15 +306,6 @@ impl Importer for ImportSpreadsheet { .into_iter() .enumerate() .try_for_each(|(job_nr, pb)| { - let result = import_workbook( - &mut update, - input_path, - pb.as_path(), - column_map, - &self.fallback, - &tx, - ); - if let Some(tx) = &tx { tx.send(StatusMessage::Progress { id: self.step_id(Some(&pb)), @@ -322,7 +313,14 @@ impl Importer for ImportSpreadsheet { finished_work: job_nr, })?; } - result + import_workbook( + &mut update, + input_path, + pb.as_path(), + column_map, + &self.fallback, + &tx, + ) })?; Ok(update) }