Exemplo n.º 1
0
 def __init__(self,
              modelYmls,
              namespace=None,
              host=None,
              rank=0,
              ygg_debug_level=None,
              rmq_debug_level=None,
              ygg_debug_prefix=None,
              connection_task_method='thread',
              as_function=False,
              production_run=False):
     super(YggRunner, self).__init__('runner')
     if namespace is None:
         namespace = ygg_cfg.get('rmq', 'namespace', False)
     if not namespace:  # pragma: debug
         raise Exception('rmq:namespace not set in config file')
     self.namespace = namespace
     self.host = host
     self.rank = rank
     self.connection_task_method = connection_task_method
     self.modeldrivers = {}
     self.connectiondrivers = {}
     self.interrupt_time = 0
     self._old_handlers = {}
     self.production_run = production_run
     self.error_flag = False
     self.as_function = as_function
     self.debug("Running in %s with path %s namespace %s rank %d",
                os.getcwd(), sys.path, namespace, rank)
     # Update environment based on config
     cfg_environment()
     # Parse yamls
     self.drivers = yamlfile.parse_yaml(modelYmls, as_function=as_function)
     self.connectiondrivers = self.drivers['connection']
     self.modeldrivers = self.drivers['model']
Exemplo n.º 2
0
 def __init__(self, modelYmls, namespace, host=None, rank=0,
              ygg_debug_level=None, rmq_debug_level=None,
              ygg_debug_prefix=None):
     super(YggRunner, self).__init__('runner')
     self.namespace = namespace
     self.host = host
     self.rank = rank
     self.modeldrivers = {}
     self.inputdrivers = {}
     self.outputdrivers = {}
     self.serverdrivers = {}
     self.interrupt_time = 0
     self._inputchannels = {}
     self._outputchannels = {}
     self._old_handlers = {}
     self.error_flag = False
     # Setup logging
     # if ygg_debug_prefix is None:
     #     ygg_debug_prefix = namespace
     # setup_ygg_logging(ygg_debug_prefix, level=ygg_debug_level)
     # Update environment based on config
     cfg_environment()
     # Parse yamls
     drivers = yamlfile.parse_yaml(modelYmls)
     self.inputdrivers = drivers['input']
     self.outputdrivers = drivers['output']
     self.modeldrivers = drivers['model']
     for x in self.outputdrivers.values():
         self._outputchannels[x['args']] = x
     for x in self.inputdrivers.values():
         self._inputchannels[x['args']] = x
Exemplo n.º 3
0
 def __init__(self,
              modelYmls,
              namespace=None,
              host=None,
              rank=0,
              ygg_debug_level=None,
              rmq_debug_level=None,
              ygg_debug_prefix=None):
     super(YggRunner, self).__init__('runner')
     if namespace is None:
         namespace = ygg_cfg.get('rmq', 'namespace', False)
     if not namespace:  # pragma: debug
         raise Exception('rmq:namespace not set in config file')
     self.namespace = namespace
     self.host = host
     self.rank = rank
     self.modeldrivers = {}
     self.inputdrivers = {}
     self.outputdrivers = {}
     self.serverdrivers = {}
     self.interrupt_time = 0
     self._inputchannels = {}
     self._outputchannels = {}
     self._old_handlers = {}
     self.error_flag = False
     self.debug("Running in %s with path %s namespace %s rank %d",
                os.getcwd(), sys.path, namespace, rank)
     # Update environment based on config
     cfg_environment()
     # Parse yamls
     drivers = yamlfile.parse_yaml(modelYmls)
     self.inputdrivers = drivers['input']
     self.outputdrivers = drivers['output']
     self.modeldrivers = drivers['model']
     for x in self.outputdrivers.values():
         self._outputchannels[x['args']] = x
     for x in self.inputdrivers.values():
         self._inputchannels[x['args']] = x
Exemplo n.º 4
0
 def __init__(self,
              modelYmls,
              namespace=None,
              host=None,
              rank=0,
              ygg_debug_level=None,
              rmq_debug_level=None,
              ygg_debug_prefix=None,
              connection_task_method='thread',
              as_service=False,
              complete_partial=False,
              partial_commtype=None,
              production_run=False,
              mpi_tag_start=None,
              yaml_param=None,
              validate=False):
     self.mpi_comm = None
     name = 'runner'
     if MPI is not None:
         comm = MPI.COMM_WORLD
         if comm.Get_size() > 1:
             self.mpi_comm = comm
             rank = comm.Get_rank()
             name += str(rank)
     super(YggRunner, self).__init__(name)
     if namespace is None:
         namespace = ygg_cfg.get('rmq', 'namespace', False)
     if not namespace:  # pragma: debug
         raise Exception('rmq:namespace not set in config file')
     if as_service:
         complete_partial = True
     self.namespace = namespace
     self.host = host
     self.rank = rank
     self.connection_task_method = connection_task_method
     self.base_dup = {}
     self.modelcopies = {}
     self.modeldrivers = {}
     self.connectiondrivers = {}
     self.interrupt_time = 0
     self._old_handlers = {}
     self.production_run = production_run
     self.error_flag = False
     self.complete_partial = complete_partial
     self.partial_commtype = partial_commtype
     self.validate = validate
     self.debug("Running in %s with path %s namespace %s rank %d",
                os.getcwd(), sys.path, namespace, rank)
     # Update environment based on config
     cfg_environment()
     # Parse yamls
     self.mpi_tag_start = mpi_tag_start
     if self.mpi_comm and (self.rank > 0):
         pass
     else:
         self.drivers = yamlfile.parse_yaml(
             modelYmls,
             complete_partial=complete_partial,
             partial_commtype=partial_commtype,
             yaml_param=yaml_param)
         self.connectiondrivers = self.drivers['connection']
         self.modeldrivers = self.drivers['model']
         for x in self.modeldrivers.values():
             if x['driver'] == 'DummyModelDriver':
                 x['runner'] = self
                 if as_service:
                     for io in x['output_drivers']:
                         for comm in io['inputs']:
                             comm['for_service'] = True
                     for io in x['input_drivers']:
                         for comm in io['outputs']:
                             comm['for_service'] = True