Closed SeanBryan51 closed 6 months ago
I'm going to attempt to implement this, we'll see how I go.
After discussing with @ccarouge, we have decided to add support for spack and to deprecate support for legacy CABLE build systems in benchcab. This adds the requirement that users will only be able to test benchcab on branches that can be built by spack. ACCESS-NRI will help with transitioning legacy build systems to use the latest build system compatible with spack.
Moving to spack will solve existing issues around supporting bespoke build scripts (e.g. #244, #249). This is the best way forward considering support for legacy build systems is a temporary that will be deprecated sooner or later.
Closing this issue.
For compiling CABLE with a custom build script, benchcab will try to remove any lines that invoke the
module
command in the build script so that benchcab can load the modules specified in config.yaml when compiling the executables. This ensures that when we run CABLE we have the correct module dependencies loaded (see related issue: https://github.com/CABLE-LSM/benchcab/issues/94). This is done via theremove_module_lines
function:https://github.com/CABLE-LSM/benchcab/blob/dd9bc12e554b218b1090c31ffaa41cdafd10fc7d/benchcab/model.py#L154-L162
However, this approach of removing lines from the bash script is brittle and can easily produce a broken bash script. For example, a bash script snippet such as the following would break when applying the above function:
I think it is best to avoid modifying the build script as much as possible.
We could instead disable
module
invocations by creating a wrapper around themodule
command which prevents anymodule load
ormodule add
statements from being executed. To invoke the wrapper instead of the actual command when callingsubprocess.run
, we can prepend the path to the wrapper to thePATH
environment variable (see here for using python subprocess with a modified environment). This approach could be relevant for #244 if the user specifies a list of shell commands to compile CABLE instead of a build script path.