queens.drivers package#
Drivers.
Modules for calling external simulation software.
Submodules#
queens.drivers.driver module#
QUEENS driver module base class.
- class Driver(parameters, files_to_copy=None)[source]#
Bases:
object
Abstract base class for drivers in QUEENS.
- parameters#
Parameters object
- Type:
- files_to_copy#
files or directories to copy to experiment_dir
- Type:
list
- abstract run(sample, job_id, num_procs, experiment_dir, experiment_name)[source]#
Abstract method for driver run.
- Parameters:
sample (dict) – Dict containing sample
job_id (int) – Job ID
num_procs (int) – number of processors
experiment_name (str) – name of QUEENS experiment.
experiment_dir (Path) – Path to QUEENS experiment directory.
- Returns:
Result and potentially the gradient
queens.drivers.fourc_driver module#
Driver to run 4C.
- class FourcDriver(parameters, input_templates, executable, files_to_copy=None, data_processor=None, gradient_data_processor=None, post_processor='', post_options='', mpi_cmd='/usr/bin/mpirun --bind-to none')[source]#
Bases:
JobscriptDriver
Driver to run 4C.
queens.drivers.function_driver module#
Function Driver.
- class FunctionDriver(parameters, function, external_python_module_function=None)[source]#
Bases:
Driver
Driver to run an python function.
- function#
Function to evaluate.
- Type:
function
- function_requires_job_id#
True if function requires job_id
- Type:
bool
- static function_wrapper(function)[source]#
Wrap the function to be used.
This wrapper calls the function by a kwargs dict only and reshapes the output as needed. This way if called in a pool, the reshaping is also done by the workers.
- Parameters:
function (function) – Function to be wrapped
- Returns:
reshaped_output_function (function) – Wrapped function
- run(sample, job_id, num_procs, experiment_dir, experiment_name)[source]#
Run the driver.
- Parameters:
sample (dict) – Dict containing sample
job_id (int) – Job ID
num_procs (int) – number of processors
experiment_name (str) – name of QUEENS experiment.
experiment_dir (Path) – Path to QUEENS experiment directory.
- Returns:
Result and potentially the gradient
queens.drivers.jobscript_driver module#
Driver to run a jobscript.
- class JobOptions(job_dir: Path, output_dir: Path, output_file: Path, job_id: int, num_procs: int, experiment_dir: Path, experiment_name: str, input_files: dict)[source]#
Bases:
object
Dataclass for job options.
All the attributes of this dataclass can be injected into input and jobscript files. The input files dictionary will be flattened, such that the input files are injected by their key.
- add_data_and_to_dict(additional_data)[source]#
Add additional options to the job options dict.
- Parameters:
additional_data (dict) – Additional data to combine with the job options.
- Returns:
dict – Dict combining the job options and the additional data.
- experiment_dir: Path#
- experiment_name: str#
- input_files: dict#
- job_dir: Path#
- job_id: int#
- num_procs: int#
- output_dir: Path#
- output_file: Path#
- class JobscriptDriver(parameters, input_templates, jobscript_template, executable, files_to_copy=None, data_processor=None, gradient_data_processor=None, jobscript_file_name='jobscript.sh', extra_options=None, raise_error_on_jobscript_failure=True)[source]#
Bases:
Driver
Driver to run an executable with a jobscript.
- input_templates#
Read in simulation input template as string.
- Type:
Path
- data_processor#
Instance of data processor class.
- Type:
obj
- gradient_data_processor#
Instance of data processor class for gradient data.
- Type:
obj
- jobscript_template#
Read-in jobscript template.
- Type:
str
- jobscript_options#
Dictionary containing jobscript options.
- Type:
dict
- jobscript_file_name#
Jobscript file name (default: ‘jobscript.sh’).
- Type:
str
- raise_error_on_jobscript_failure#
Whether to raise an error for a non-zero jobscript exit code.
- Type:
bool
- static create_input_templates_dict(input_templates)[source]#
Cast input templates into a dict.
- Parameters:
input_templates (str, Path, dict) – Input template(s).
- Returns:
dict – Dict containing input file names and template paths.
- static get_read_in_jobscript_template(jobscript_template)[source]#
Get the jobscript template contents.
If the provided jobscript template is a Path or a string of a path and a valid file, the corresponding file is read.
- Parameters:
jobscript_template (str, Path) – Path to jobscript template or read-in jobscript template.
- Returns:
str – Read-in jobscript template
- prepare_input_files(sample_dict, experiment_dir, input_files)[source]#
Prepare and parse data to input files.
- Parameters:
sample_dict (dict) – Dict containing sample.
experiment_dir (Path) – Path to QUEENS experiment directory.
input_files (dict) – Dict with name and path of the input file(s).
- run(sample, job_id, num_procs, experiment_dir, experiment_name)[source]#
Run the driver.
- Parameters:
sample (dict) – Dict containing sample.
job_id (int) – Job ID.
num_procs (int) – Number of processors.
experiment_dir (Path) – Path to QUEENS experiment directory.
experiment_name (str) – Name of QUEENS experiment.
- Returns:
Result and potentially the gradient.
queens.drivers.mpi_driver module#
Convenience wrapper around Jobscript Driver.
- class MpiDriver(parameters, input_templates, executable, files_to_copy=None, data_processor=None, gradient_data_processor=None, mpi_cmd='/usr/bin/mpirun --bind-to none')[source]#
Bases:
JobscriptDriver
Driver to run a generic MPI run.