@@ -353,12 +353,14 @@ def set_mod_paths(self, mod_paths=None):
353353
354354 self .log .debug ("$MODULEPATH after set_mod_paths: %s" % os .environ .get ('MODULEPATH' , '' ))
355355
356- def use (self , path , priority = None ):
356+ def use (self , path , priority = None , force_module_command = False ):
357357 """
358358 Add path to $MODULEPATH via 'module use'.
359359
360360 :param path: path to add to $MODULEPATH
361361 :param priority: priority for this path in $MODULEPATH (Lmod-specific)
362+ :param force_module_command: If False running the module command may be skipped which is faster
363+ but does not reload modules
362364 """
363365 if priority :
364366 self .log .info ("Ignoring specified priority '%s' when running 'module use %s' (Lmod-specific)" ,
@@ -372,8 +374,14 @@ def use(self, path, priority=None):
372374 mkdir (path , parents = True )
373375 self .run_module (['use' , path ])
374376
375- def unuse (self , path ):
376- """Remove module path via 'module unuse'."""
377+ def unuse (self , path , force_module_command = False ):
378+ """
379+ Remove a module path (usually) via 'module unuse'.
380+
381+ :param path: path to remove from $MODULEPATH
382+ :param force_module_command: If False running the module command may be skipped which is faster
383+ but does not reload modules
384+ """
377385 self .run_module (['unuse' , path ])
378386
379387 def add_module_path (self , path , set_mod_paths = True ):
@@ -1464,12 +1472,14 @@ def _has_module_paths_with_priority(self):
14641472 # See https://github.com/TACC/Lmod/issues/509
14651473 return bool (os .environ .get ('__LMOD_Priority_MODULEPATH' ))
14661474
1467- def use (self , path , priority = None ):
1475+ def use (self , path , priority = None , force_module_command = False ):
14681476 """
14691477 Add path to $MODULEPATH via 'module use'.
14701478
14711479 :param path: path to add to $MODULEPATH
14721480 :param priority: priority for this path in $MODULEPATH (Lmod-specific)
1481+ :param force_module_command: If False running the module command may be skipped which is faster
1482+ but does not reload modules
14731483 """
14741484 if not path :
14751485 raise EasyBuildError ("Cannot add empty path to $MODULEPATH" )
@@ -1483,17 +1493,26 @@ def use(self, path, priority=None):
14831493 else :
14841494 # LMod allows modifying MODULEPATH directly. So do that to avoid the costly module use
14851495 # unless priorities are in use already
1486- if self ._has_module_paths_with_priority ():
1496+ if force_module_command or self ._has_module_paths_with_priority ():
14871497 self .run_module (['use' , path ])
14881498 else :
14891499 path = normalize_path (path )
14901500 self ._set_module_path ([path ] + [p for p in curr_module_paths (clean = False ) if normalize_path (p ) != path ])
14911501
1492- def unuse (self , path ):
1493- """Remove a module path"""
1494- # We can simply remove the path from MODULEPATH to avoid the costly module call
1495- path = normalize_path (path )
1496- self ._set_module_path (p for p in curr_module_paths (clean = False ) if normalize_path (p ) != path )
1502+ def unuse (self , path , force_module_command = False ):
1503+ """
1504+ Remove a module path
1505+
1506+ :param path: path to remove from $MODULEPATH
1507+ :param force_module_command: If False running the module command may be skipped which is faster
1508+ but does not reload modules
1509+ """
1510+ if force_module_command :
1511+ super (Lmod , self ).unuse (path )
1512+ else :
1513+ # We can simply remove the path from MODULEPATH to avoid the costly module call
1514+ path = normalize_path (path )
1515+ self ._set_module_path (p for p in curr_module_paths (clean = False ) if normalize_path (p ) != path )
14971516
14981517 def prepend_module_path (self , path , set_mod_paths = True , priority = None ):
14991518 """
0 commit comments