Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed packet factory code from the instrument agent and driver

process.
  • Loading branch information...
commit 9cec06da1ed0430f0a1e6ff930b14eda6b98427d 1 parent 9c32d6b
@wfrench wfrench authored
View
150 ion/agents/instrument/driver_process.py
@@ -51,8 +51,6 @@ class DriverProcess(object):
_command_port = None
_event_port = None
- _packet_factories = None
-
@classmethod
def get_process(cls, driver_config, test_mode = False):
"""
@@ -66,10 +64,6 @@ def get_process(cls, driver_config, test_mode = False):
type = driver_config.get("process_type")[0]
driver_module = driver_config.get('dvr_mod')
- log.error("ROGER TYPE " + repr(type))
-
-
-
if not type:
raise DriverLaunchException("missing driver config: process_type")
@@ -331,103 +325,28 @@ def _process_command(self):
return [ python, '-c', cmd_str ]
- def get_packet_factories(self, stream_info):
- """
- Construct packet factories from PACKET_CONFIG member of the driver_config
- and the given stream_info dict.
-
- @param stream_info
-
- @retval a dict indexed by stream name of the packet factories defined.
- """
-
- if not self._packet_factories:
- log.info("generating packet factories")
- self._packet_factories = {}
+class ZMQEggDriverProcess(DriverProcess):
+ '''
+ Object to facilitate ZMQ driver processes using a python egg
- driver_module = self.config.get('dvr_mod')
- if not driver_module:
- raise DriverLaunchException("missing driver config: driver_module")
+ Driver config requirements:
+ dvr_egg :: the filename of the egg
- packet_config = None
- try:
- import_str = 'from %s import PACKET_CONFIG' % driver_module
- exec import_str
- log.debug("PACKET_CONFIG: %s", PACKET_CONFIG)
- packet_config = PACKET_CONFIG
- except:
- log.error('PACKET_CONFIG undefined in driver module %s ' % driver_module)
-
- if packet_config:
- for name in packet_config:
- if not name in stream_info:
- log.error("Name '%s' not found in stream_info" % name)
- continue
-
- stream_config = stream_info[name]
- try:
- packet_builder = create_packet_builder(name, stream_config)
- self._packet_factories[name] = packet_builder
- log.info('created packet builder for stream %s' % name)
- except Exception, e:
- log.error('error creating packet builder: %s' % e)
-
- return self._packet_factories
-
-# TODO remove
-# def get_packet_factories(self):
-# """
-# Construct packet factories from packet_config member of the driver_config.
-# @retval a list of packet factories defined.
-# """
-# if not self._packet_factories:
-# log.info("generating packet factories")
-# self._packet_factories = {}
-#
-# driver_module = self.config.get('dvr_mod')
-# if not driver_module:
-# raise DriverLaunchException("missing driver config: driver_module")
-#
-# # Should we poll the driver process to give us these configurations? If defined in an interface then
-# # this method could be generalized for all driver processes. It also seems like execing an import
-# # might be unsafe.
-# import_str = 'from %s import PACKET_CONFIG' % driver_module
-# try:
-# exec import_str
-# log.debug("PACKET_CONFIG: %s", PACKET_CONFIG)
-# for (name, val) in PACKET_CONFIG.iteritems():
-# if val:
-# try:
-# mod = val[0]
-# cls = val[1]
-# import_str = 'from %s import %s' % (mod, cls)
-# ctor_str = 'ctor = %s' % cls
-# exec import_str
-# exec ctor_str
-# self._packet_factories[name] = ctor
-#
-# except Exception, e:
-# log.error('error creating packet factory: %s', e)
-#
-# else:
-# log.info('created packet factory for stream %s', name)
-# except Exception, e:
-# log.error('Instrument agent %s had error creating packet factories. %s', e)
-#
-# return self._packet_factories
+ Example:
+ driver_config = {
+ dvr_egg: seabird_sbe37smb_ooicore-0.0.1-py2.7.egg
-class ZMQEggDriverProcess(DriverProcess):
- """
- Object to facilitate driver processes launch from an egg as an 'eggsecutable'
- """
+ process_type: DriverProcessType.EGG
+ }
+ @param driver_config configuration parameters for the driver process
+ @param test_mode should the driver be run in test mode
+ '''
def __init__(self, driver_config, test_mode = False):
self.config = driver_config
self.test_mode = test_mode
-
-
def _check_cache_for_egg(self, egg_name):
"""
Check if the egg is already cached, if so, return the path.
@@ -506,46 +425,3 @@ def _process_command(self):
return [ python, '-c', cmd_str ]
- def get_packet_factories(self, stream_info):
- """
- Construct packet factories from PACKET_CONFIG member of the driver_config
- and the given stream_info dict.
-
- @param stream_info
-
- @retval a dict indexed by stream name of the packet factories defined.
- """
-
-
- if not self._packet_factories:
- log.info("generating packet factories")
- self._packet_factories = {}
-
- driver_module = self.config.get('dvr_mod')
- if not driver_module:
- raise DriverLaunchException("missing driver config: driver_module")
-
- packet_config = None
- try:
- import_str = 'from %s import PACKET_CONFIG' % driver_module
- exec import_str
- log.debug("PACKET_CONFIG: %s", PACKET_CONFIG)
- packet_config = PACKET_CONFIG
- except:
- log.error('PACKET_CONFIG undefined in driver module %s ' % driver_module)
-
- if packet_config:
- for name in packet_config:
- if not name in stream_info:
- log.error("Name '%s' not found in stream_info" % name)
- continue
-
- stream_config = stream_info[name]
- try:
- packet_builder = create_packet_builder(name, stream_config)
- self._packet_factories[name] = packet_builder
- log.info('created packet builder for stream %s' % name)
- except Exception, e:
- log.error('error creating packet builder: %s' % e)
-
- return self._packet_factories
View
32 ion/agents/instrument/instrument_agent.py
@@ -155,10 +155,6 @@ def __init__(self, *args, **kwargs):
# stream_config agent config member during process on_init.
self._data_publishers = {}
- # Factories for stream packets. Constructed by driver
- # configuration information on transition to inactive.
- self._packet_factories = {}
-
def on_init(self):
"""
Instrument agent pyon process initialization.
@@ -384,8 +380,6 @@ def _handler_uninitialized_initialize(self, *args, **kwargs):
# Start the driver and switch to inactive.
self._start_driver(self._dvr_config)
- self._construct_packet_factories()
-
next_state = ResourceAgentState.INACTIVE
return (next_state, result)
@@ -401,7 +395,6 @@ def _handler_inactive_reset(self, *args, **kwargs):
next_state = None
result = self._stop_driver()
- self._clear_packet_factories()
next_state = ResourceAgentState.UNINITIALIZED
return (next_state, result)
@@ -455,7 +448,6 @@ def _handler_idle_reset(self, *args, **kwargs):
self._dvr_client.cmd_dvr('disconnect')
self._dvr_client.cmd_dvr('initialize')
result = self._stop_driver()
- self._clear_packet_factories()
next_state = ResourceAgentState.UNINITIALIZED
return (next_state, result)
@@ -495,7 +487,6 @@ def _handler_stopped_reset(self, *args, **kwargs):
self._dvr_client.cmd_dvr('disconnect')
self._dvr_client.cmd_dvr('initialize')
result = self._stop_driver()
- self._clear_packet_factories()
next_state = ResourceAgentState.UNINITIALIZED
return (next_state, result)
@@ -543,7 +534,6 @@ def _handler_command_reset(self, *args, **kwargs):
self._dvr_client.cmd_dvr('disconnect')
self._dvr_client.cmd_dvr('initialize')
result = self._stop_driver()
- self._clear_packet_factories()
next_state = ResourceAgentState.UNINITIALIZED
return (next_state, result)
@@ -641,7 +631,6 @@ def _handler_streaming_reset(self, *args, **kwargs):
self._dvr_client.cmd_dvr('disconnect')
self._dvr_client.cmd_dvr('initialize')
result = self._stop_driver()
- self._clear_packet_factories()
next_state = ResourceAgentState.UNINITIALIZED
return (next_state, result)
@@ -1136,26 +1125,7 @@ def _construct_data_publishers(self):
publisher for stream %s.', self._proc_name,
stream_name)
- def _construct_packet_factories(self):
- """
- Construct packet factories from packet_config member of the
- driver_config and self.CFG.stream_config.
- @retval None
- """
- self._packet_factories = self._dvr_proc.get_packet_factories(
- self.CFG.stream_config)
- log.info('Insturment agent %s constructed its packet factories.',
- self._proc_name)
-
- def _clear_packet_factories(self):
- """
- Delete packet factories.
- @retval None
- """
- self._packet_factories.clear()
- log.info('Instrument agent %s deleted packet factories.',
- self._proc_name)
-
+
###############################################################################
# Event callback and handling for direct access.
###############################################################################
View
10 ion/agents/instrument/test/test_driver_process.py
@@ -84,15 +84,6 @@ def assert_driver_process_launch_success(self, driver_config):
self.assertTrue(driver_client)
driver_client.start_messaging(self.event_received)
- #
- # Do we need to verify events here? Is it deterministic behavior?
- #
-
- stream_info = CFG.get('stream_config', None)
-
- #@TODO re-enable this when stream_info is defined
- #packet_factories = driver_process.get_packet_factories(stream_info)
- #self.assertTrue(packet_factories)
self.assertGreater(driver_process.memory_usage(), 0)
log.info("Driver memory usage before stop: %d", driver_process.memory_usage())
@@ -104,7 +95,6 @@ def test_driver_process_by_class(self):
"""
Test the driver launching process for a class and module
"""
-
self.assert_driver_process_launch_success(self._class_driver_config)
def test_driver_process_by_egg(self):
Please sign in to comment.
Something went wrong with that request. Please try again.