Model Drivers¶
-
class
cis_interface.drivers.ModelDriver.
ModelDriver
(name, args, is_server=False, client_of=[], with_strace=False, strace_flags=None, with_valgrind=False, valgrind_flags=None, model_index=0, **kwargs)[source]¶ Base class for Model drivers and for running executable based models.
Parameters: - name (str) – Driver name.
- args (str or list) – Argument(s) for running the model on the command line. This should be a complete command including the necessary executable and command line arguments to that executable.
- is_server (bool, optional) – If True, the model is assumed to be a server
and an instance of
cis_interface.drivers.ServerDriver
is started. Defaults to False. - client_of (str, list, optional) – The names of ne or more servers that this model is a client of. Defaults to empty list.
- with_strace (bool, optional) – If True, the command is run with strace (on Linux) or dtrace (on OSX). Defaults to False.
- strace_flags (list, optional) – Flags to pass to strace (or dtrace). Defaults to [].
- with_valgrind (bool, optional) – If True, the command is run with valgrind. Defaults to False.
- valgrind_flags (list, optional) – Flags to pass to valgrind. Defaults to [].
- model_index (int, optional) – Index of model in list of models being run. Defaults to 0.
- **kwargs – Additional keyword arguments are passed to parent class.
-
args
¶ list – Argument(s) for running the model on the command line.
-
process
¶ cis_interface.tools.CisPopen
– Process used to run the model.
-
is_server
¶ bool – If True, the model is assumed to be a server and an instance of
cis_interface.drivers.ServerDriver
is started.
-
client_of
¶ list – The names of server models that this model is a client of.
-
with_strace
¶ bool – If True, the command is run with strace or dtrace.
-
strace_flags
¶ list – Flags to pass to strace/dtrace.
-
with_valgrind
¶ bool – If True, the command is run with valgrind.
-
valgrind_flags
¶ list – Flags to pass to valgrind.
-
model_index
¶ int – Index of model in list of models being run.
Raises: RuntimeError
– If both with_strace and with_valgrind are True.-
after_loop
()[source]¶ Actions to perform after run_loop has finished. Mainly checking if there was an error and then handling it.
-
model_process_complete
¶ bool – Has the process finished or not. Returns True if the process has not started.
-
class
cis_interface.drivers.PythonModelDriver.
PythonModelDriver
(name, args, **kwargs)[source]¶ Class for running Python models.
Parameters:
-
class
cis_interface.drivers.MatlabModelDriver.
MatlabModelDriver
(name, args, **kwargs)[source]¶ Base class for running Matlab models.
Parameters: -
started_matlab
¶ bool – True if the driver had to start a new matlab engine. False otherwise.
-
screen_session
¶ str – Screen session that Matlab was started in.
-
mlengine
¶ object – Matlab engine used to run script.
-
mlsession
¶ str – Name of the Matlab session that was started.
Raises: RuntimeError
– If Matlab is not installed.-
-
class
cis_interface.drivers.GCCModelDriver.
GCCModelDriver
(name, args, cc=None, **kwargs)[source]¶ Class for running gcc compiled drivers.
Parameters: - name (str) – Driver name.
- args (str or list) – Argument(s) for running the model on the command line. If the first element ends with ‘.c’, the driver attempts to compile the code with the necessary interface include directories. Additional arguments that start with ‘-I’ are included in the compile command. Others are assumed to be runtime arguments.
- cc (str, optional) – C/C++ Compiler that should be used. Defaults to gcc for ‘.c’ files, and g++ for ‘.cpp’ or ‘.cc’ files on Linux or OSX. Defaults to cl on Windows.
- **kwargs – Additional keyword arguments are passed to parent class.
- Attributes (in additon to parent class’s):
- compiled (bool): True if the compilation was succesful. False otherwise. cfile (str): Source file. cc (str): C/C++ Compiler that should be used. flags (list): List of compiler flags. efile (str): Compiled executable file.
Raises: RuntimeError
– If neither the IPC or ZMQ C libraries are available.RuntimeError
– If the compilation fails.
-
parse_arguments
(args)[source]¶ Sort arguments based on their syntax. Arguments ending with ‘.c’ or ‘.cpp’ are considered source and the first one will be compiled to an executable. Arguments starting with ‘-L’ or ‘-l’ are treated as linker flags. Arguments starting with ‘-‘ are treated as compiler flags. Any arguments that do not fall into one of the categories will be treated as command line arguments for the compiled executable.
Parameters: args (list) – List of arguments provided. Raises: RuntimeError
– If there is not a valid source file in the argument list.