I have a module whose behavior I can modify by setting an environment variable before loading it. This module loads an environment, that again provides other modules. I.e. interactively, I'd do:
export X=foo
module load Y/1.1 # the load behaviour is affected by the value of X
module avail bar # bar is available in this environment (but only if X=foo)
I'd like reframe.utility.find_modules to be able to find bar. I've noticed that I cannot simply specify environment.env_vars because those only get set after reframe.core.runtime.loadenv has already called the module commands. So, I figured I'll just leverage prepare_cmds instead:
'environments': [
{
'prepare_cmds': ['export X=foo'],
'modules': ['Y/1.1']
}
Alas, this didn't work. Looking at the code, I can see why: the prepare_cmds are appended to the returned commands here, but they are not executed when loadenv() is called. According to my AI friend, they are only emitted to the job script that reframe stages (this may or may not be accurate, I'm not sure: I cannot get that far, since it won't generate a test for bar, since it cannot find it :)).
What I'm wondering is: is this a bug? If it is intended behaviour, I'm wondering in which scenario you want to have these prepare commands be emitted in the job script, but not during the find_modules. Also: would it be worth making this more explicit in the documentation? ("List of shell commands to be emitted before any commands that load the environment." => that sounds like it would also happen when find_modules loads an environment)
I have a module whose behavior I can modify by setting an environment variable before loading it. This module loads an environment, that again provides other modules. I.e. interactively, I'd do:
I'd like
reframe.utility.find_modulesto be able to findbar. I've noticed that I cannot simply specifyenvironment.env_varsbecause those only get set afterreframe.core.runtime.loadenvhas already called the module commands. So, I figured I'll just leverageprepare_cmdsinstead:Alas, this didn't work. Looking at the code, I can see why: the
prepare_cmdsare appended to the returnedcommandshere, but they are not executed whenloadenv()is called. According to my AI friend, they are only emitted to the job script that reframe stages (this may or may not be accurate, I'm not sure: I cannot get that far, since it won't generate a test forbar, since it cannot find it :)).What I'm wondering is: is this a bug? If it is intended behaviour, I'm wondering in which scenario you want to have these prepare commands be emitted in the job script, but not during the
find_modules. Also: would it be worth making this more explicit in the documentation? ("List of shell commands to be emitted before any commands that load the environment." => that sounds like it would also happen whenfind_modulesloads an environment)