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/+variant-other-command.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`--variant` now works only with a recipe build or `submit`. Other commands refuse it instead of running as if it were absent.
1 change: 1 addition & 0 deletions docs/orgmode/reference/cli.org
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ The flags reach the C, C++ and Fortran compilers through EasyBuild's toolchain;
An easyconfig with the =SYSTEM= toolchain keeps its options and gets only the suffix.
Dependencies build as usual.
=--explain= shows the variant as =EB_LOCAL_VARIANT= and =EB_LOCAL_VARIANT_BLOCK=, the lines appended.
With another command, including =eb=, =env=, =config=, =profiles= and =dev=, it is refused: those would otherwise run as if it were not there, and =eb= would install the optimised module. =submit= keeps it and puts it on the batch command.
[[file:../howto/build-for-profiling.org][Build software to profile or debug]] uses both.

** eb
Expand Down
1 change: 1 addition & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ The flags reach the C, C++ and Fortran compilers through EasyBuild's toolchain;
An easyconfig with the `SYSTEM` toolchain keeps its options and gets only the suffix.
Dependencies build as usual.
`--explain` shows the variant as `EB_LOCAL_VARIANT` and `EB_LOCAL_VARIANT_BLOCK`, the lines appended.
With another command, including `eb`, `env`, `config`, `profiles` and `dev`, it is refused: those would otherwise run as if it were not there, and `eb` would install the optimised module. `submit` keeps it and puts it on the batch command.
[Build software to profile or debug](../howto/build-for-profiling.md) uses both.

### eb
Expand Down
5 changes: 5 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7820,6 +7820,11 @@ fn runMain(init: std.process.Init) u8 {
// would run as if it were not there.
if (g.explain and command != .build and command != .eb)
die("--explain goes with a recipe or with eb, not with {s}", .{@tagName(command)});
// --variant changes the easyconfig a recipe build compiles, and submit
// puts that option on the batch command. Another command would run as
// if it were not there, and eb would install the optimised module.
if (g.variant != null and command != .build and command != .submit)
die("--variant goes with a recipe or with submit, not with {s}", .{@tagName(command)});
// The cache is a pair of files. It does not read the site file.
if (command == .@"lmod-cache") return lmodcache.run(init.io, a, c.env, cache);
if (command == .overlay) {
Expand Down
50 changes: 50 additions & 0 deletions tests/test_extend_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,56 @@ def test_explain_with_a_command_it_does_not_explain_is_refused(self):
self.assertIn(f"--explain goes with a recipe or with eb, not with {args[0]}", run.stderr)
self.assertTrue(old.exists())

def test_variant_before_another_command_is_refused(self):
# Parsed while the command is still a recipe build, then left set.
# eb would install the optimised module; env, config and profiles
# would succeed as if --variant were not there.
cases = (
(["--variant", "perf", "eb", "x.eb"], "eb"),
(["--variant=debug", "eb", "x.eb"], "eb"),
(["--variant", "perf", "--explain", "eb", "x.eb"], "eb"),
(["--variant", "perf", "env"], "env"),
(["--variant", "perf", "config"], "config"),
(["--variant", "perf", "profiles"], "profiles"),
(["--variant", "perf", "dev"], "dev"),
)
for args, command in cases:
with self.subTest(args=args):
ran = self.root / "eb-ran"
ran.unlink(missing_ok=True)
run = self.run_tool(args)
self.assertEqual(run.returncode, 2, run.stdout + run.stderr)
self.assertEqual(run.stdout, "")
self.assertIn(f"--variant goes with a recipe or with submit, not with {command}", run.stderr)
self.assertFalse(ran.exists())

def test_variant_stays_on_a_recipe_and_on_submit(self):
prefix = self.root / "gpu"
site = self.root / "site.toml"
site.write_text(
'[storage]\nnode_local_root = "/local"\n'
'[build.node_types]\nmilan = "--constraint=milan"\n'
f'[profile.gpu]\nprefix = "{prefix}"\n',
encoding="utf-8",
)
site.chmod(0o600)
explained = self.run_tool(
["--config", str(site), "--profile", "gpu", "--explain", "--variant", "perf", "pigz.eb", "--robot"],
EB_LOCAL_CONFIG=str(site),
)
self.assertEqual(explained.returncode, 0, explained.stderr)
self.assertIn("export EB_LOCAL_VARIANT=perf\n", explained.stdout)
self.assertIn("--variant perf", explained.stdout)
submitted = self.run_tool(
["--config", str(site), "--profile", "gpu", "--variant", "perf", "submit", "--print", "pigz.eb"],
EB_LOCAL_CONFIG=str(site),
)
self.assertEqual(submitted.returncode, 0, submitted.stdout + submitted.stderr)
self.assertIn("--profile gpu", submitted.stdout)
self.assertIn("--variant perf", submitted.stdout)
self.assertIn("exec ", submitted.stdout)
self.assertFalse((self.root / "eb-ran").exists())

def test_eb_accepts_trailing_slash_in_install_variable(self):
mine = self.root / "mine"
run = self.run_tool(
Expand Down
Loading