Skip to content

Commit 3576740

Browse files
committed
fix(gap): choose the bump source by toolchain family and generation
For a no-recipe row, stack gap names the newest easyconfig of the name on any toolchain as the bump source. Between builds of the newest version the file name decided, so an upper-case toolchain name sorted first and an older toolchain before a newer one: QuantumESPRESSO 7.5 was bumped from NVHPC-25.3-CUDA-12.8.0 rather than foss-2025b, and Bandage 0.9.0 from GCCcore-11.3.0 rather than GCCcore-14.3.0. Between builds of one version the bump source is now one on a toolchain family the generation uses, then the one on the newest toolchain generation, as data/eessi-generations.toml and the shipped hierarchies place it, then the newest toolchain of one name. Versions of two toolchain names are not compared. The recipe route keeps its order. On the EESSI 2026.06 site list from the deck demo, 120 of 249 no-recipe rows change bump source, each to a build from a newer toolchain generation; recipe.tsv and roots.txt are unchanged. Unit tests in gap.rs cover the family, the generation, and the family match; the first two fail without the fix.
1 parent 72ea4e5 commit 3576740

5 files changed

Lines changed: 158 additions & 17 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`stack gap` picks the bump source of a `no-recipe` row among builds of the newest version by toolchain family and generation instead of file name: a build on a toolchain family of the generation comes first, then the newest toolchain generation, so QuantumESPRESSO 7.5 is bumped from `foss-2025b` rather than `NVHPC-25.3-CUDA-12.8.0`, and a recipe on `GCCcore-14.3.0` is preferred to one on `GCCcore-11.3.0`.

‎docs/orgmode/howto/module-gap.org‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ A toolchain whose version is the generation counts as on it, so
2020
generation in ~data/eessi-generations.toml~, such as
2121
~llvm-compilers-21.1.8~.
2222

23+
When the newest version has several builds, the bump source is one on a
24+
toolchain family the generation uses, ~foss~ for ~foss-2026.1~, and of
25+
those the one on the newest toolchain generation. QuantumESPRESSO 7.5 is
26+
bumped from ~foss-2025b~, not from ~NVHPC-25.3-CUDA-12.8.0~ or
27+
~foss-2025a~.
28+
2329
* Capture the live inventories
2430

2531
The helper uses the shell's ~module~ function.

‎docs/orgmode/reference/cli.org‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,9 @@ toolchain whose version is that generation, or on the system toolchain),
783783
~open-easyconfigs~ (an ~--open-easyconfigs~ pull request adds a recipe at
784784
that generation; the match is the filename, and a toolchain version equal
785785
to ~--generation~ counts), or ~no-recipe~ (the newest easyconfig on any
786-
toolchain is named as the bump source). ~--eessi-version~ keeps
786+
toolchain is named as the bump source; between builds of that version, one
787+
on a toolchain family of the generation comes first, then the one on the
788+
newest toolchain generation). ~--eessi-version~ keeps
787789
~--open-layer~ easystacks of that version; without it every easystack
788790
version counts. The command writes ~gap.tsv~, one TSV per
789791
route (~site-only.tsv~ for ~excluded~, ~bump.tsv~ for ~no-recipe~, and

‎llms-full.txt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4550,6 +4550,12 @@ A toolchain whose version is the generation counts as on it, so
45504550
generation in `data/eessi-generations.toml`, such as
45514551
`llvm-compilers-21.1.8`.
45524552

4553+
When the newest version has several builds, the bump source is one on a
4554+
toolchain family the generation uses, `foss` for `foss-2026.1`, and of
4555+
those the one on the newest toolchain generation. QuantumESPRESSO 7.5 is
4556+
bumped from `foss-2025b`, not from `NVHPC-25.3-CUDA-12.8.0` or
4557+
`foss-2025a`.
4558+
45534559
# Capture the live inventories
45544560

45554561
The helper uses the shell's `module` function.
@@ -7442,7 +7448,9 @@ toolchain whose version is that generation, or on the system toolchain),
74427448
`open-easyconfigs` (an `--open-easyconfigs` pull request adds a recipe at
74437449
that generation; the match is the filename, and a toolchain version equal
74447450
to `--generation` counts), or `no-recipe` (the newest easyconfig on any
7445-
toolchain is named as the bump source). `--eessi-version` keeps
7451+
toolchain is named as the bump source; between builds of that version, one
7452+
on a toolchain family of the generation comes first, then the one on the
7453+
newest toolchain generation). `--eessi-version` keeps
74467454
`--open-layer` easystacks of that version; without it every easystack
74477455
version counts. The command writes `gap.tsv`, one TSV per
74487456
route (`site-only.tsv` for `excluded`, `bump.tsv` for `no-recipe`, and

‎src/gap.rs‎

Lines changed: 139 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ pub struct GapRow {
3434
#[serde(skip_serializing_if = "Option::is_none")]
3535
pub recipe: Option<String>,
3636
/// The newest easyconfig of the name on any toolchain, for `no-recipe`:
37-
/// the source a bump starts from.
37+
/// the source a bump starts from. Between builds of one version, one on
38+
/// a toolchain family of the generation, then on the newest toolchain
39+
/// generation, is named.
3840
#[serde(skip_serializing_if = "Option::is_none")]
3941
pub newest_elsewhere: Option<String>,
4042
/// Why a name is `excluded` or `filtered`, or the pull requests that
@@ -198,17 +200,62 @@ fn on_generation(candidate: &Candidate, generation: &str, members: &[String]) ->
198200
/// Order candidates newest first: version, then a recipe without a
199201
/// versionsuffix before one with, then by file name.
200202
fn newest_first(a: &&Candidate, b: &&Candidate) -> Ordering {
201-
cmp_version(&b.version, &a.version)
202-
.then_with(|| {
203-
a.versionsuffix
204-
.as_deref()
205-
.unwrap_or("")
206-
.len()
207-
.cmp(&b.versionsuffix.as_deref().unwrap_or("").len())
203+
newer_build(a, b).then_with(|| file_of(a).cmp(&file_of(b)))
204+
}
205+
206+
/// Order bump sources as [`newest_first`], except that between builds of
207+
/// one version a toolchain of a family the generation uses comes first,
208+
/// then the newer toolchain generation, then the newer toolchain of one
209+
/// name. Versions of two toolchain names are not compared: GCC 14.3.0 and
210+
/// foss 2025b do not count the same way.
211+
fn bump_source_first(
212+
a: &Candidate,
213+
b: &Candidate,
214+
members: &[String],
215+
generations: &BTreeMap<String, Option<String>>,
216+
) -> Ordering {
217+
let generation = |candidate: &Candidate| {
218+
generations
219+
.get(&toolchain_label(candidate))
220+
.cloned()
221+
.flatten()
222+
};
223+
newer_build(a, b)
224+
.then_with(|| in_member_family(b, members).cmp(&in_member_family(a, members)))
225+
.then_with(|| match (generation(a), generation(b)) {
226+
(Some(left), Some(right)) => cmp_version(&right, &left),
227+
(Some(_), None) => Ordering::Less,
228+
(None, Some(_)) => Ordering::Greater,
229+
(None, None) => Ordering::Equal,
208230
})
231+
.then_with(|| a.toolchain.name.cmp(&b.toolchain.name))
232+
.then_with(|| cmp_version(&b.toolchain.version, &a.toolchain.version))
209233
.then_with(|| file_of(a).cmp(&file_of(b)))
210234
}
211235

236+
fn newer_build(a: &Candidate, b: &Candidate) -> Ordering {
237+
cmp_version(&b.version, &a.version).then_with(|| {
238+
a.versionsuffix
239+
.as_deref()
240+
.unwrap_or("")
241+
.len()
242+
.cmp(&b.versionsuffix.as_deref().unwrap_or("").len())
243+
})
244+
}
245+
246+
/// Whether the candidate's toolchain name is the name of a member label,
247+
/// `foss` for `foss-2026.1`.
248+
fn in_member_family(candidate: &Candidate, members: &[String]) -> bool {
249+
let name = candidate.toolchain.name.as_str();
250+
members.iter().any(|label| {
251+
label == name
252+
|| label
253+
.strip_prefix(name)
254+
.and_then(|rest| rest.strip_prefix('-'))
255+
.is_some_and(|version| version.starts_with(|c: char| c.is_ascii_digit()))
256+
})
257+
}
258+
212259
fn reason_for<'a>(map: &'a BTreeMap<String, String>, name: &str) -> Option<&'a str> {
213260
if let Some(reason) = map.get(name) {
214261
return Some(reason.as_str());
@@ -267,6 +314,8 @@ pub fn gap(input: &GapInput<'_>) -> Vec<GapRow> {
267314
.or_default()
268315
.push(candidate);
269316
}
317+
let table = crate::generation_lint::GenerationTable::bundled().ok();
318+
let mut generations: BTreeMap<String, Option<String>> = BTreeMap::new();
270319
let mut rows = Vec::new();
271320
for name in input.site {
272321
if stack_lower.contains(&name.to_lowercase()) {
@@ -316,13 +365,18 @@ pub fn gap(input: &GapInput<'_>) -> Vec<GapRow> {
316365
));
317366
continue;
318367
}
319-
rows.push(row(
320-
name,
321-
"no-recipe",
322-
None,
323-
all.first().map(|candidate| file_of(candidate)),
324-
None,
325-
));
368+
for candidate in &all {
369+
generations
370+
.entry(toolchain_label(candidate))
371+
.or_insert_with_key(|label| {
372+
table.as_ref().and_then(|table| table.generation_of(label))
373+
});
374+
}
375+
let source = all
376+
.iter()
377+
.copied()
378+
.min_by(|a, b| bump_source_first(a, b, input.members, &generations));
379+
rows.push(row(name, "no-recipe", None, source.map(file_of), None));
326380
}
327381
rows
328382
}
@@ -761,6 +815,76 @@ mod tests {
761815
})
762816
}
763817

818+
#[test]
819+
fn an_equal_version_prefers_the_generation_toolchain_family() {
820+
let site = names_from_listing("QuantumESPRESSO\n");
821+
let candidates = vec![
822+
cand(
823+
"QuantumESPRESSO",
824+
"7.5",
825+
("NVHPC", "25.3-CUDA-12.8.0"),
826+
None,
827+
),
828+
cand("QuantumESPRESSO", "7.5", ("foss", "2025a"), None),
829+
cand("QuantumESPRESSO", "7.5", ("lfoss", "2025b"), None),
830+
cand("QuantumESPRESSO", "7.5", ("foss", "2025b"), None),
831+
cand("QuantumESPRESSO", "7.4.1", ("foss", "2025a"), None),
832+
];
833+
let rows = classify(
834+
&site,
835+
&BTreeSet::new(),
836+
&candidates,
837+
&BTreeMap::new(),
838+
&BTreeSet::new(),
839+
&BTreeMap::new(),
840+
&BTreeMap::new(),
841+
);
842+
assert_eq!(rows[0].route, "no-recipe");
843+
assert_eq!(
844+
rows[0].newest_elsewhere.as_deref(),
845+
Some("QuantumESPRESSO-7.5-foss-2025b.eb")
846+
);
847+
}
848+
849+
#[test]
850+
fn an_equal_version_prefers_the_newest_toolchain_generation() {
851+
let site = names_from_listing("X\n");
852+
let candidates = vec![
853+
cand("X", "1.0", ("foss", "2023a"), None),
854+
cand("X", "1.0", ("GCCcore", "11.3.0"), None),
855+
cand("X", "1.0", ("GCC", "14.3.0"), None),
856+
cand("X", "1.0", ("GCC", "13.2.0"), None),
857+
];
858+
let rows = classify(
859+
&site,
860+
&BTreeSet::new(),
861+
&candidates,
862+
&BTreeMap::new(),
863+
&BTreeSet::new(),
864+
&BTreeMap::new(),
865+
&BTreeMap::new(),
866+
);
867+
assert_eq!(
868+
rows[0].newest_elsewhere.as_deref(),
869+
Some("X-1.0-GCC-14.3.0.eb")
870+
);
871+
}
872+
873+
#[test]
874+
fn a_member_family_is_the_toolchain_name_of_a_member() {
875+
let members = ["GCCcore-15.2.0", "foss-2026.1", "llvm-compilers-21.1.8"].map(String::from);
876+
let on = |name: &str| {
877+
in_member_family(&cand("X", "1", (name, "2025b"), None), members.as_slice())
878+
};
879+
assert!(on("foss"));
880+
assert!(on("GCCcore"));
881+
assert!(on("llvm-compilers"));
882+
assert!(!on("GCC"));
883+
assert!(!on("fos"));
884+
assert!(!on("llvm"));
885+
assert!(!on("NVHPC"));
886+
}
887+
764888
#[test]
765889
fn routes_each_site_package() {
766890
let site = names_from_listing("BLAST+/2.16.0-gompi-2024a\nLAMMPS\nJulia/1.10.4\nCP2K/2025.2-foss-2025a\nMATLAB/2025b\nzlib/1.3.1\n");

0 commit comments

Comments
 (0)