@@ -54,6 +54,8 @@ class BaseModelWrapper(BlueMathModel, ABC):
5454
5555 sbatch_file_example = sbatch_file_example
5656
57+ available_launchers = {}
58+
5759 def __new__ (cls , * args , ** kwargs ):
5860 if cls is BaseModelWrapper :
5961 raise TypeError (
@@ -77,9 +79,8 @@ def __init__(
7779 Parameters
7880 ----------
7981 templates_dir : str
80- The directory where the templates are searched.
81- Both binary and text files are supported, for the case where the user
82- needs to have a fixed binary file in all cases directories.
82+ The directory where the templates are searched. If None, no templates will be used.
83+ Both binary and text files are supported as templates.
8384 metamodel_parameters : dict
8485 The parameters to be used for the different cases.
8586 fixed_parameters : dict
@@ -109,15 +110,24 @@ def __init__(
109110 self .metamodel_parameters = metamodel_parameters
110111 self .fixed_parameters = fixed_parameters
111112 self .output_dir = output_dir
112- self ._env = Environment (loader = FileSystemLoader (self .templates_dir ))
113- if templates_name == "all" :
114- self .logger .info (
115- f"Templates name is 'all', so all templates in { self .templates_dir } will be used."
116- )
117- self .templates_name = self .env .list_templates ()
118- self .logger .info (f"Templates names: { self .templates_name } " )
113+
114+ if self .templates_dir is not None :
115+ self ._env = Environment (loader = FileSystemLoader (self .templates_dir ))
116+ if templates_name == "all" :
117+ self .logger .info (
118+ f"Templates name is 'all', so all templates in { self .templates_dir } will be used."
119+ )
120+ self .templates_name = self .env .list_templates ()
121+ self .logger .info (f"Templates names: { self .templates_name } " )
122+ else :
123+ self .templates_name = templates_name
119124 else :
120- self .templates_name = templates_name
125+ self .logger .warning (
126+ "No templates directory provided, so no templates will be used."
127+ )
128+ self ._env = None
129+ self .templates_name = []
130+
121131 self .cases_context : List [dict ] = None
122132 self .cases_dirs : List [str ] = None
123133 self .thread : threading .Thread = None
@@ -704,18 +714,34 @@ def get_thread_status(self) -> str:
704714 def run_cases_bulk (
705715 self ,
706716 launcher : str ,
717+ path_to_execute : str = None ,
707718 ) -> None :
708719 """
709720 Run the cases based on the launcher specified.
721+ This is thought to be used in a cluster environment, as it is a bulk execution of the cases.
722+ By default, the command is executed in the output directory, where the cases are saved,
723+ and where the example sbatch file is saved.
710724
711725 Parameters
712726 ----------
713727 launcher : str
714728 The launcher to run the cases.
729+ path_to_execute : str, optional
730+ The path to execute the command. Default is None.
731+
732+ Examples
733+ --------
734+ # This will execute the specified launcher in the output directory.
735+ >>> wrapper.run_cases_bulk(launcher="sbatch sbatch_example.sh")
736+ # This will execute the specified launcher in the specified path.
737+ >>> wrapper.run_cases_bulk(launcher="my_launcher.sh", path_to_execute="/my/path/to/execute")
715738 """
716739
717- self .logger .info (f"Running cases with launcher={ launcher } ." )
718- self ._exec_bash_commands (str_cmd = launcher , cwd = self .output_dir )
740+ if path_to_execute is None :
741+ path_to_execute = self .output_dir
742+
743+ self .logger .info (f"Running cases with launcher={ launcher } in { path_to_execute } " )
744+ self ._exec_bash_commands (str_cmd = launcher , cwd = path_to_execute )
719745
720746 def monitor_cases (
721747 self , cases_status : dict , value_counts : str
0 commit comments