Skip to content
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
1 change: 1 addition & 0 deletions changelog.d/+short-force.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`stack shard` counts `-f`, EasyBuild's short form of `--force`, as forcing a rebuild, as it counts `--force` and `--rebuild`. A line that rebuilt an installed module with `-f` was planned as building nothing: the module had no weight and was in no closure, so a line that needs it could land in another shard and build while `eb -f` rebuilt it.
5 changes: 3 additions & 2 deletions docs/orgmode/reference/cli.org
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,9 @@ path minus the installed modules, as ~pr-overlap~ computes a root's set.
Installed modules come from ~--installed-modules-dir~, an Lmod
~modules/all~ tree read as ~Name/Version~ (EESSI's tree for the CPU target
and the site tree, for example), and from ~--installed~ lists, one
~Name/VersionFull~ per line; both repeat. A line with ~--rebuild~ or
~--force~ builds its own module even when it is installed. Two lines share
~Name/VersionFull~ per line; both repeat. A line with ~--rebuild~,
~--force~ or its short form ~-f~ builds its own module even when it is
installed. Two lines share
a shard only when one line's easyconfig is in the other's set, or both name
the same easyconfig; the line that is needed comes first. Every other module
the sets of two or more shards need goes to the prelude, so the shards'
Expand Down
5 changes: 3 additions & 2 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7586,8 +7586,9 @@ path minus the installed modules, as `pr-overlap` computes a root's set.
Installed modules come from `--installed-modules-dir`, an Lmod
`modules/all` tree read as `Name/Version` (EESSI's tree for the CPU target
and the site tree, for example), and from `--installed` lists, one
`Name/VersionFull` per line; both repeat. A line with `--rebuild` or
`--force` builds its own module even when it is installed. Two lines share
`Name/VersionFull` per line; both repeat. A line with `--rebuild`,
`--force` or its short form `-f` builds its own module even when it is
installed. Two lines share
a shard only when one line's easyconfig is in the other's set, or both name
the same easyconfig; the line that is needed comes first. Every other module
the sets of two or more shards need goes to the prelude, so the shards'
Expand Down
15 changes: 12 additions & 3 deletions src/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub struct ShardLine {
pub text: String,
/// The first word, the easyconfig filename.
pub file: String,
/// Whether the line forces a rebuild (`--rebuild` or `--force`), so its
/// own module counts as not installed.
/// Whether the line forces a rebuild (`--rebuild`, `--force` or its short
/// form `-f`), so its own module counts as not installed.
pub forced: bool,
/// Whether EasyBuild fetches the line's easyconfig itself
/// (`--from-pr` or `--from-commit`), so it need not be on the robot path.
Expand Down Expand Up @@ -139,7 +139,9 @@ pub fn parse_lines(text: &str) -> Vec<ShardLine> {
.iter()
.map(|w| w.split('=').next().unwrap_or(w))
.collect();
let forced = keys.iter().any(|k| *k == "--rebuild" || *k == "--force");
let forced = keys
.iter()
.any(|k| matches!(*k, "--rebuild" | "--force" | "-f"));
let fetched = keys
.iter()
.any(|k| *k == "--from-pr" || *k == "--from-commit");
Expand Down Expand Up @@ -539,6 +541,13 @@ mod tests {
assert!(!lines[0].fetched && !lines[1].fetched);
}

#[test]
fn rebuild_force_and_its_short_form_force_a_line() {
let lines = parse_lines("A-1.eb --rebuild\nB-2.eb --force\nC-3.eb -f\nD-4.eb --hooks=-f\n");
let forced: Vec<bool> = lines.iter().map(|line| line.forced).collect();
assert_eq!(forced, [true, true, true, false]);
}

#[test]
fn from_pr_and_from_commit_lines_are_fetched() {
let lines = parse_lines(
Expand Down
32 changes: 32 additions & 0 deletions tests/stack_shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,38 @@ fn wave_one_splits_into_three_shards_and_a_prelude() {
);
}

#[test]
fn a_short_force_line_rebuilds_its_module_before_the_line_that_needs_it() {
let tmp = tempfile::tempdir().unwrap();
let out = tmp.path().join("shards");
let run = shard("force.list", &out, &["--shards", "4"]);
assert!(
run.status.success(),
"{}",
String::from_utf8_lossy(&run.stderr)
);
// CMake is installed, but `-f` rebuilds it, so Szip's closure has it and
// the two lines share a shard with CMake first, as for `--force`.
assert_eq!(
String::from_utf8_lossy(&run.stdout),
"shards=1 prelude=0 lines=2\n"
);
assert_eq!(
listing(&out),
["plan.json", "prelude.list", "shard-01.list"]
);
assert_eq!(
read(out.join("shard-01.list")),
"CMake-3.31.8-GCCcore-15.2.0.eb -f\nSzip-2.1.1-GCCcore-15.2.0.eb\n"
);
let plan: Value = serde_json::from_str(&read(out.join("plan.json"))).unwrap();
assert_eq!(
plan["lines"][0]["closure"],
serde_json::json!(["CMake/3.31.8-GCCcore-15.2.0"])
);
assert_eq!(plan["shards"][0]["weight"], 2);
}

#[test]
fn weights_balance_the_shards_by_time() {
let tmp = tempfile::tempdir().unwrap();
Expand Down
3 changes: 3 additions & 0 deletions tests/stack_shard_fixtures/force.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CMake is installed; -f is EasyBuild's short form of --force
CMake-3.31.8-GCCcore-15.2.0.eb -f
Szip-2.1.1-GCCcore-15.2.0.eb
Loading