def __init__(self, *args, **kwargs): super(TestClientResponseParam, self).__init__(*args, **kwargs) self.driver = 'ClientResponseDriver' self.args = None self.attr_list += ['comm', 'msg_id', 'response_address'] self.comm_name = tools.get_default_comm() self.server_comm = tools.get_default_comm() self.icomm_name = self.server_comm self.ocomm_name = self.comm_name
def __init__(self, *args, **kwargs): super(TestClientParam, self).__init__(*args, **kwargs) self.driver = 'ClientDriver' self.args = None self.attr_list += ['comm', 'response_drivers', 'request_name', 'request_address'] # Increased to allow forwarding between IPC comms on OSX # self.timeout = 5.0 self.route_timeout = 2 * self.timeout # self.debug_flag = True self.comm_name = tools.get_default_comm() self.server_comm = tools.get_default_comm() self.icomm_name = self.comm_name self.ocomm_name = self.server_comm
def __init__(self, *args, **kwargs): super(TestServerParam, self).__init__(*args, **kwargs) self.driver = 'ServerDriver' self.args = None self.attr_list += ['comm', 'response_drivers', 'nclients', 'request_name'] # Increased to allow forwarding between IPC comms on OSX self.timeout = 5.0 self.route_timeout = 2 * self.timeout # if tools.get_default_comm() == "IPCComm": # self.route_timeout = 120.0 # self.debug_flag = True # self.sleeptime = 0.5 # self.timeout = 10.0 self.comm_name = tools.get_default_comm() self.client_comm = tools.get_default_comm() self.icomm_name = self.client_comm self.ocomm_name = self.comm_name
def __init__(self, *args, **kwargs): super(TestConnectionParam, self).__init__(*args, **kwargs) self.driver = 'ConnectionDriver' self.comm_name = tools.get_default_comm() self.attr_list += ['icomm_kws', 'ocomm_kws', 'icomm', 'ocomm', 'nrecv', 'nproc', 'nsent', 'state', 'translator'] # self.timeout = 1.0 self.icomm_name = self.comm_name self.ocomm_name = self.comm_name self._extra_instances = []
def get_comm_class(comm=None): r"""Return a communication class given it's name. Args: comm (str, optional): Name of communicator class. Defaults to tools.get_default_comm() if not provided. Returns: class: Communicator class. """ if comm is None: comm = tools.get_default_comm() mod = importlib.import_module('cis_interface.communication.%s' % comm) comm_cls = getattr(mod, comm) return comm_cls
def get_comm(name, comm=None, new_comm_class=None, **kwargs): r"""Return communicator for existing comm components. Args: name (str): Communicator name. comm (str, optional): Name of communicator class. new_comm_class (str, optional): Name of communicator class that will override comm if set. **kwargs: Additional keyword arguments are passed to communicator class. Returns: Comm: Communicator of given class. """ if comm is None: comm = tools.get_default_comm() if new_comm_class is not None: comm = new_comm_class comm_cls = get_comm_class(comm) return comm_cls(name, **kwargs)
def new_comm(name, comm=None, **kwargs): r"""Return a new communicator, creating necessary components for communication (queues, sockets, channels, etc.). Args: name (str): Communicator name. comm (str, optional): Name of communicator class. **kwargs: Additional keyword arguments are passed to communicator class method new_comm. Returns: Comm: Communicator of given class. """ if comm is None: comm = tools.get_default_comm() # elif comm == 'ErrorComm': # comm = kwargs.get('base_comm', tools.get_default_comm()) # kwargs['new_comm_class'] = 'ErrorComm' comm_cls = get_comm_class(comm) return comm_cls.new_comm(name, **kwargs)
def get_flags(for_cmake=False): r"""Get the necessary flags for compiling & linking with CiS libraries. Args: for_cmake (bool, optional): If True, the returned flags will match the format required by cmake. Defaults to False. Returns: tuple(list, list): compile and linker flags. """ _compile_flags = [] _linker_flags = [] if not tools._c_library_avail: # pragma: windows logging.warning("No library installed for models written in C") return _compile_flags, _linker_flags if platform._is_win: # pragma: windows assert (os.path.isfile(_regex_win32_lib)) _compile_flags += ["/nologo", "-D_CRT_SECURE_NO_WARNINGS"] _compile_flags += ['-I' + _top_dir] if not for_cmake: _regex_win32 = os.path.split(_regex_win32_lib) _linker_flags += [ _regex_win32[1], '/LIBPATH:"%s"' % _regex_win32[0] ] if tools._zmq_installed_c: zmq_flags = get_zmq_flags(for_cmake=for_cmake) _compile_flags += zmq_flags[0] _linker_flags += zmq_flags[1] if tools._ipc_installed: ipc_flags = get_ipc_flags(for_cmake=for_cmake) _compile_flags += ipc_flags[0] _linker_flags += ipc_flags[1] for x in [_incl_interface, _incl_io, _incl_comm, _incl_seri, _incl_regex]: _compile_flags += ["-I" + x] if tools.get_default_comm() == 'IPCComm': _compile_flags += ["-DIPCDEF"] return _compile_flags, _linker_flags
def cleanup_comm_classes(self): r"""list: Comm classes that should be cleaned up following the test.""" return [get_default_comm()]
from cis_interface import tools, timing, backwards, platform from cis_interface.tests import CisTestClass _test_size = 1 _test_count = 1 _test_nrep = 1 _test_lang = 'c' # On windows, it's possible to not have a C/C++ communication library installed if 'c' not in timing._lang_list: # pragma: windows _test_lang = 'python' # _test_run = timing.TimedRun(_test_lang, _test_lang) # _test_run.time_run(_test_count, _test_size, nrep=_test_nrep) _this_platform = (platform._platform, backwards._python_version, tools.get_default_comm()) _base_environment = {'platform': 'Linux', 'python_ver': '2.7', 'comm_type': 'ZMQComm'} _valid_platforms = [('Linux', '2.7', 'ZMQComm'), ('Linux', '2.7', 'IPCComm'), ('Linux', '3.5', 'ZMQComm'), ('MacOS', '2.7', 'ZMQComm'), ('Windows', '2.7', 'ZMQComm')] _testfile_json = 'test_run123.json' _testfile_dat = 'test_run123.dat' def test_get_source(): r"""Test getting source file for test.""" lang_list = timing._lang_list