Good to see you found some way!
Using "getVariantList" is not future-proof, especially that this
procedure requires some refactoring.
Please open some issue to have a proper modulefile command to query
variant of loaded modules.
Merry christmas,
Xavier
Le mar. 24 déc. 2024 à 14:53, Adrien COTTE <adr...@as...> a écrit :
>
> The "is-loading" instruction doesn't seem to handle variants.
>
> siteconfig.tcl
>
> set modulefile_extra_cmds {is-loading is-loading}
>
> goat/2.0
>
> if { [is-loading ziege compiler=gcc] } {
> // always executed, nevermind compiler value
> }
>
> But I've found the "getVariantList" which is not bad at all.
> Thanks to modulefile_extra_cmds i've written my own "getvariantlist" call.
>
> siteconfig.tcl
>
> proc printVariantList {mod} {
> getVariantList $mod 1
> }
> set modulefile_extra_cmds {getvariantlist printVariantList}
>
> goat/2.0
>
> if { [string match *compiler=gcc* [getvariantlist ziege] ] } {
> // code
> }
>
> This solution works perfectly!
> Is it safe/futurproof to use "getVariantList" internal proc like this?
>
> Thanks again for your help,
> Adrien
>
> ________________________________
> De : Adrien COTTE <adr...@as...>
> Envoyé : mardi 24 décembre 2024 11:52
> À : Environment Modules usage and discussion. <mod...@li...>
> Objet : Re: [Modules] Get variant of another module
>
> The compiler variant here is really dummy, of course.
> My internal real use case is very complex, and I am not able to summarize in an e-mail.
>
> I'll give a try to "modulefile_extra_cmds" and "is-loading".
>
> Many thanks and Merry Christmas 🙂!
>
> Best,
> Adrien
> ________________________________
> De : Xavier Delaruelle <xav...@gm...>
> Envoyé : mardi 24 décembre 2024 11:24
> À : Environment Modules usage and discussion. <mod...@li...>
> Objet : Re: [Modules] Get variant of another module
>
> The "is-loading" procedure exists but is not currently exposed in the
> modulefile evaluation context. You may try to expose it with
> "modulefile_extra_cmds" hook variable and see if it cope with your use
> case.
>
> The variant propagation method is a good one also. But I feel with
> your message that the "goat" module is not compiler-specific so it may
> not be semantically correct to have a compiler variant?
>
> Best regards,
> Xavier
>
> Le mar. 24 déc. 2024 à 11:13, Adrien COTTE <adr...@as...> a écrit :
> >
> > Hi Xavier,
> > Thank you for your quick response.
> > Indeed, it works. I thought I had already tried that, but my case was slightly different, unfortunately.
> > What about an "asked variant"? Perhaps an equivalent of "is-loading"?
> > If goat/2.0 is a prerequisite for ziege/1.0, the "is-loaded" approach cannot work.
> > Example:
> > File: /usr/share/modulefiles/ziege/1.0
> >
> > #%Module
> >
> > set name "ziege"
> > set version "1.0"
> >
> > variant compiler
> >
> > prereq goat/2.0
> >
> > File: /usr/share/modulefiles/goat/2.0
> >
> > #%Module
> >
> > set name "goat"
> > set version "2.0"
> >
> > if { [is-loaded ziege compiler=gcc] } {
> > // does not work
> > }
> >
> > The only solution I've found is to propagate variants across my modules.
> > Updated Example:
> > File: /usr/share/modulefiles/ziege/1.0
> >
> > #%Module
> >
> > set name "ziege"
> > set version "1.0"
> >
> > variant compiler
> >
> > prereq goat/2.0 compiler=[getvariant compiler]
> >
> > File: /usr/share/modulefiles/goat/2.0
> >
> > #%Module
> >
> > set name "goat"
> > set version "2.0"
> >
> > variant compiler
> >
> > if { [getvariant compiler] == gcc } {
> > // code
> > }
> >
> > Let me know if you see any better way to handle this.
> > Best regards,
> > Adrien
> > ________________________________
> > De : Xavier Delaruelle <xav...@gm...>
> > Envoyé : mardi 24 décembre 2024 09:52
> > À : Environment Modules usage and discussion. <mod...@li...>
> > Objet : Re: [Modules] Get variant of another module
> >
> > Hi Adrien,
> >
> > As far as I remind, there is no function that currently gives you the
> > variants of a loaded module from another module, but you may try using
> > the "is-loaded" command:
> >
> > if {[is-loaded ziege compiler=gcc]} {
> > // code
> > } elseif {[is-loaded ziege compiler=llvm]}
> > ..
> > }
> >
> > Best,
> > Xavier
> >
> > Le mar. 24 déc. 2024 à 09:44, Adrien COTTE <adr...@as...> a écrit :
> > >
> > > Hi,
> > >
> > > Is it possible to get the variant of another module?
> > >
> > > A dummy example.
> > >
> > > $ module load ziege/1.0 compiler=gcc
> > > $ module load goat/2.0
> > >
> > > In the goat/2.0 modulefile, I would like to check the ziege/1.0 compiler variant.
> > >
> > > Best,
> > > Adrien Cotte
> > > _______________________________________________
> > > Modules-interest mailing list
> > > Mod...@li...
> > > https://lists.sourceforge.net/lists/listinfo/modules-interest
> >
> >
> > _______________________________________________
> > Modules-interest mailing list
> > Mod...@li...
> > https://lists.sourceforge.net/lists/listinfo/modules-interest
> > _______________________________________________
> > Modules-interest mailing list
> > Mod...@li...
> > https://lists.sourceforge.net/lists/listinfo/modules-interest
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|