I have just added the ability to send content that will be evaluated
in shell session prior any environment changes: using the puts command
over the 'prestdout' channel [1].
This change will be included in version 5.1.
Best regards,
Xavier
[1] https://modules.readthedocs.io/en/latest/modulefile.html#mfcmd-puts
Le mer. 5 janv. 2022 à 06:57, Xavier Delaruelle
<xav...@gm...> a écrit :
>
> Dear Marius, Dear Paul,
>
> The content of puts statements are applied at the very end of the
> produced environment change. These commands are run after all
> environment change commands (generated by all evaluated modulefiles)
> and whatever the position of the puts statement in the modulefile.
>
> The workaround I found here is to mark the conda module sticky, with a
> "module-tag sticky conda" command placed right above the "module load
> conda" command. This way the conda module is not automatically
> unloaded if it has been automatically loaded. This workaround requires
> Modules 4.7 or above.
>
> On the upcoming Modules 5.1, it will be possible to tag a module
> "keep-loaded" to avoid the auto unload mechanism.
>
> I have just created a new feature ticket to add the ability to put
> such command at the start of the environment change commands rather at
> the end [1].
>
> I wish to everybody the best things for this new year.
>
> Best regards,
> Xavier
>
> [1] https://github.com/cea-hpc/modules/issues/432
>
> Le mar. 4 janv. 2022 à 16:53, Paul Markfort <pau...@gm...> a écrit :
> >
> > Just a simple logic problem (you want to deactivate before you unload).
> >
> > Try this:
> >
> > if { [module-info mode remove] && ![module-info mode switch3] } {
> > puts stdout "conda deactivate"
> > }
> >
> > module load conda
> >
> > if { [module-info mode load] || [module-info mode switch2] } {
> > puts stdout "conda activate $path"
> > }
> >
> >
> >
> >
> >
> > On 2022-01-04 04:43 AM, Marius Retegan wrote:
> > > Dear all,
> > >
> > > First of all happy new year and best wishes for 2022!
> > >
> > > I would like to use environment modules to load/unload Conda environments (https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-envs <https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-envs>).
> > >
> > > I have a working environment module for Conda alone. Now I need a module for a specific Conda environment. For this I use the code below to load/unload the environment:
> > >
> > > ## My conda environment module file
> > >
> > > module load conda
> > >
> > > if { [module-info mode load] || [module-info mode switch2] } {
> > > puts stdout "conda activate $path"
> > > } elseif { [module-info mode remove] && ![module-info mode switch3] } {
> > > puts stdout "conda deactivate"
> > > }
> > >
> > > If I do module load my_conda_environment; module unload my_conda_environment, I get an error because the conda dependency is unloaded first and then the conda command is not found anymore.
> > >
> > > However this works: module load conda; module load my_conda_environment; module unload my_conda_environemt; module unload conda.
> > >
> > > Is there a way to have the result of the previous line, without having to explicitly load conda? Thank you for your help.
> > >
> > > Best regards,
> > > Marius
|