Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report progress when importing a single Excel file #142

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
31 changes: 21 additions & 10 deletions src/importer/spreadsheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

pub const MODULE_NAME: &str = "import_spreadsheet";

#[derive(Default, Deserialize)]

Check warning on line 25 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

25 line is not covered with tests
#[serde(default)]
pub struct ImportSpreadsheet {
column_map: BTreeMap<String, BTreeSet<String>>,
Expand Down Expand Up @@ -71,7 +71,7 @@
}
}
}
}

Check warning on line 74 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

74 line is not covered with tests
}
m
};
Expand All @@ -87,14 +87,14 @@
let start_col = match cell_range.get_coordinate_start_col().as_ref() {
Some(c) => c,
None => {
if let Some(sender) = tx {
let message = StatusMessage::Warning(format!(
"Could not parse start column of merged cell {}",
cell_range.get_range()
));
sender.send(message)?;
}
continue;

Check warning on line 97 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

90-97 lines are not covered with tests
}
};
let col_1i = start_col.get_num();
Expand All @@ -107,7 +107,7 @@
cell_range.get_range()
));
sender.send(message)?;
}

Check warning on line 110 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

110 line is not covered with tests
start_col
}
};
Expand All @@ -123,14 +123,14 @@
let start_row = match cell_range.get_coordinate_start_row().as_ref() {
Some(r) => r,
None => {
if let Some(sender) = tx {
let message = StatusMessage::Warning(format!(
"Could not parse start row of merged cell {}",
cell_range.get_range()
));
sender.send(message)?;
}
continue;

Check warning on line 133 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

126-133 lines are not covered with tests
}
};
let start_1i = start_row.get_num();
Expand All @@ -143,7 +143,7 @@
cell_range.get_range()
));
sender.send(message)?;
}

Check warning on line 146 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

146 line is not covered with tests
start_row
}
};
Expand All @@ -159,7 +159,7 @@
cell_range.get_range()
));
sender.send(message)?;
}

Check warning on line 162 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

162 line is not covered with tests
}
m
};
Expand Down Expand Up @@ -286,7 +286,7 @@
StatusMessage::Info(format!("No column `{name}` in file {}", &doc_path));
sender.send(message)?;
continue;
}

Check warning on line 289 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

289 line is not covered with tests
}
}
Ok(())
Expand All @@ -301,16 +301,27 @@
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)| {
if let Some(tx) = &tx {
tx.send(StatusMessage::Progress {
id: self.step_id(Some(&pb)),
total_work: number_of_files,
finished_work: job_nr,
})?;
}
import_workbook(
&mut update,
input_path,
pb.as_path(),
column_map,
&self.fallback,
&tx,
)
})?;
Ok(update)
}
}
Expand Down Expand Up @@ -402,7 +413,7 @@
let count = cs.count(query)?;
assert_eq!(
count, expected_result,
"Result for query `{}` does not match",

Check warning on line 416 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

416 line is not covered with tests
query_s
);
}
Expand All @@ -414,8 +425,8 @@
let import = run_spreadsheet_import(false, None);
assert!(
import.is_ok(),
"Spreadsheet import failed with error: {:?}",
import.err()

Check warning on line 429 in src/importer/spreadsheet.rs

View workflow job for this annotation

GitHub Actions / Execute tests with code coverage

428-429 lines are not covered with tests
);
}

Expand Down
Loading