当前位置: 首页>>代码示例>>Python>>正文


Python bunch.Bunch方法代码示例

本文整理汇总了Python中bunch.Bunch方法的典型用法代码示例。如果您正苦于以下问题:Python bunch.Bunch方法的具体用法?Python bunch.Bunch怎么用?Python bunch.Bunch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bunch的用法示例。


在下文中一共展示了bunch.Bunch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, name=None, application_settings=None, global_settings=None):
        RootService.__init__(self, settings=global_settings)

        # Compute name for Twisted service
        self.name = u'app-{name}'.format(name=name)

        # Make channel object from application settings configuration object
        self.channel = Bunch(**application_settings)

        # Create application service object composed of subsystem components
        service = MqttInfluxGrafanaService(
            channel  = self.channel,
            # Data processing strategy and graphing components
            strategy=WanBusStrategy(),
            graphing=GrafanaManager(settings=global_settings, channel=self.channel)
            )

        # Register service component with its container
        self.registerService(service) 
开发者ID:daq-tools,项目名称:kotori,代码行数:21,代码来源:mqttkit.py

示例2: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, name=None, application_settings=None, global_settings=None):
        RootService.__init__(self, settings=global_settings)

        # Compute name for Twisted service
        self.name = u'app-{name}'.format(name=name)

        # Make channel object from application settings configuration object
        self.channel = Bunch(**application_settings)

        # Create application service object composed of subsystem components
        service = MqttInfluxGrafanaService(
            channel=self.channel,
            # Data processing strategy and graphing components
            strategy=LanStrategy(),
            graphing=GrafanaManager(settings=global_settings, channel=self.channel)
            )

        # Register service component with its container
        self.registerService(service) 
开发者ID:daq-tools,项目名称:kotori,代码行数:21,代码来源:basic.py

示例3: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, name=None, application_settings=None, global_settings=None):
        RootService.__init__(self, settings=global_settings)

        # Compute name for Twisted service
        self.name = u'app-{name}'.format(name=name)

        # Make channel object from application settings configuration object
        application_settings = deepcopy(application_settings)
        application_settings.update(name=name)
        self.channel = Bunch(**application_settings)

        # Create application service object composed of subsystem components
        service = FirmwareBuilderService(
            channel = self.channel
        )

        # Register service component with its container
        self.registerService(service) 
开发者ID:daq-tools,项目名称:kotori,代码行数:20,代码来源:service.py

示例4: get_configuration

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def get_configuration(*args):
    config_files = []
    # TODO: Only use when logged in interactively?
    config_files += [os.path.expanduser('~/.kotori.ini')]
    config_files += list(args)
    log.info('Requested configuration files: {}'.format(make_list(config_files)))
    config, used = read_config(config_files, kind=Bunch)
    if config:
        if 'main' in config and 'include' in config.main:
            includes = read_list(config.main.include)
            for include in includes:
                if '*' in include or '?' in include:
                    config_files += glob(include)
                else:
                    config_files.append(include)
            log.info('Expanded configuration files:  {}'.format(make_list(config_files)))
            config, used = read_config(config_files, kind=Bunch)
        log.info('Used configuration files:      {}'.format(make_list(used)))
        return config
    else:
        msg = u'Could not read settings from configuration files: {}'.format(config_files)
        log.critical(msg)
        raise ValueError(msg) 
开发者ID:daq-tools,项目名称:kotori,代码行数:25,代码来源:configuration.py

示例5: main

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def main():
  cross_tower_ops = cross_tower_ops_lib.AllReduceCrossTowerOps('nccl')
  distribution = tf.contrib.distribute.MirroredStrategy(num_gpus=2, cross_tower_ops=cross_tower_ops)
  config = tf.estimator.RunConfig(train_distribute=distribution)
  multi_task_config = Bunch(json.load(tf.gfile.Open(FLAGS.multi_task_config)))
  def input_fn():
    features = tf.data.Dataset.from_tensors([[1.]]).repeat(10)
    labels = tf.data.Dataset.from_tensors([1.]).repeat(10)
    return tf.data.Dataset.zip((features, labels))

  def input_fn_generator():
    features = tf.data.Dataset.from_generator(data_generator, tf.float32, tf.TensorShape([None,1]))
    labels = tf.data.Dataset.from_generator(data_generator, tf.float32, tf.TensorShape([None,1]))
    dataset = tf.data.Dataset.zip((features, labels)).repeat(10)
    return dataset
  def input_fn_generator():
    dataset = train_eval_input_fn(FLAGS, multi_task_config, "train", 0)
    return dataset

  model_fn = build_model_fn_optimizer()

  est = tf.estimator.Estimator(model_fn=model_fn, config=config)
  print("==begin to train==")
  est.train(input_fn=input_fn_generator, max_steps=1000) 
开发者ID:yyht,项目名称:BERT,代码行数:26,代码来源:module_test.py

示例6: process_args

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def process_args(args,model):
    config = Bunch(args)

    if(config.model_type==const.VAE or config.model_type==const.VAECNN):
        config.model_name = get_model_name_VAE(model, config)
    if(config.model_type==const.GMVAE or config.model_type==const.GMVAECNN):
        config.model_name = get_model_name_GMVAE(model, config)

    if(config.extra is not ''):
        config.model_name += '_' + config.extra

    config.summary_dir = os.path.join("experiments/"+config.log_dir+"/", config.model_name)
    config.checkpoint_dir = os.path.join("experiments/"+config.checkpoint_dir+"/", config.model_name)
    config.results_dir = os.path.join("experiments/"+config.result_dir+"/", config.model_name)

    flags = Bunch()
    flags.train = args['train']
    flags.restore = args['restore']
    flags.results = args['results']
    flags.plot = args['plot']
    flags.early_stopping =  args['early_stopping']

    return config, flags 
开发者ID:psanch21,项目名称:VAE-GMVAE,代码行数:25,代码来源:args_processing.py

示例7: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, name=None, application_settings=None, global_settings=None):
        RootService.__init__(self, settings=global_settings)

        # Compute name for Twisted service
        self.name = u'app-{name}'.format(name=name)

        # Make channel object from application settings configuration object
        self.channel = Bunch(**application_settings)

        # Main application components
        for service_reference in read_list(application_settings.services):

            # Load service component
            try:
                service_factory = KotoriBootloader.load_entrypoint(service_reference)
            except Exception as ex:
                log.failure('Error loading composite service component "{service_name}" into "{app_name}":\n{log_failure}"',
                            service_name=service_reference, app_name=name)
                continue

            # Load data processing strategy and graphing components
            # TODO: Review whether this should be per-service or not
            # TODO: Introduce strict/non-strict handling
            strategy_factory = KotoriBootloader.load_entrypoint(application_settings.strategy, onerror='ignore')
            graphing_factory = KotoriBootloader.load_entrypoint(application_settings.graphing, onerror='ignore')

            # Create application service object composed of subsystem components
            # TODO: Bundle all arguments into yet another wrapper object for an universal object factory

            service = service_factory(
                channel=self.channel,
                strategy=strategy_factory(settings=global_settings),
                graphing=graphing_factory(settings=global_settings, channel=self.channel)
                )

            # Register service component with its container
            self.registerService(service) 
开发者ID:daq-tools,项目名称:kotori,代码行数:39,代码来源:composite.py

示例8: setupChannel

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def setupChannel(self, channel=None, name=None):
        """
        Make channel object from application settings configuration object
        """

        assert channel is not None, 'Channel object must not be None'

        channel = deepcopy(channel)
        if name:
            channel.update(name=name)
        self.channel = Bunch(**channel) 
开发者ID:daq-tools,项目名称:kotori,代码行数:13,代码来源:__init__.py

示例9: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, channel=None, graphing=None, strategy=None):

        MultiService.__init__(self)

        # TODO: Sanity checks/assertions against channel, graphing and strategy

        # TODO: Make subsystems dynamic
        self.subsystems = ['channel', 'graphing', 'strategy']
        self.channel = channel or Bunch(realm=None, subscriptions=[])
        self.graphing = to_list(graphing)
        self.strategy = strategy

        self.name = u'service-mig-' + self.channel.get('realm', unicode(id(self))) 
开发者ID:daq-tools,项目名称:kotori,代码行数:15,代码来源:mig.py

示例10: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, channel=None, preset='standard'):
        self.channel = channel or Bunch()
        self.preset = preset
        MultiService.__init__(self) 
开发者ID:daq-tools,项目名称:kotori,代码行数:6,代码来源:service.py

示例11: capture

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def capture(self):
        """
        Capture output of the whole build process.
        Return stacktrace of Python driver and output of make command, if any.
        """

        # The result object containing build success flag and error outputs.
        # This gets bound to the context manager variable.
        result = Bunch()
        self.build_result['capture'] = result

        # A temporary file to redirect make output to
        self.stream = NamedTemporaryFile()
        try:
            # Pass execution flow to context manager body,
            # effectively running the main build process
            yield result

            # Signal success if build engine completed
            result.success = True

        except Exception as ex:

            # Signal failure
            result.success = False

            # Capture Python traceback
            result.error = last_error_and_traceback()

        # Capture make output
        self.stream.seek(0)
        result.output = self.stream.read() 
开发者ID:daq-tools,项目名称:kotori,代码行数:34,代码来源:builder.py

示例12: bunchify

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def bunchify(cls, x):
        """
        Recursively transforms a dictionary into a SmartBunch via copy.
        Generic "bunchify", also works with descendants of Bunch.
        """
        if isinstance(x, dict):
            return cls( (k, cls.bunchify(v)) for k,v in x.iteritems() )
        elif isinstance(x, (list, tuple)):
            return type(x)( cls.bunchify(v) for v in x )
        else:
            return x 
开发者ID:daq-tools,项目名称:kotori,代码行数:13,代码来源:common.py

示例13: storage_location

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def storage_location(self, data):
        """
        Compute storage location (database- and timeseries-names) from message information
        """
        sanitize = self.sanitize_db_identifier
        location = Bunch({
            'database': sanitize(self.topic),
            'series':   '{:02d}_{}'.format(data['ID'], sanitize(data['_name_'].replace('struct_', ''))),
        })
        return location 
开发者ID:daq-tools,项目名称:kotori,代码行数:12,代码来源:application.py

示例14: __init__

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def __init__(self, bus, config):
        self.bus = bus
        self.config = config
        log.info('Starting InfluxStorage')
        # TODO: Refactor the _active_ mechanics
        topic = unicode(self.config['_active_']['wamp_topic'])
        channel = Bunch(
            settings = self.config['_active_']
        )
        # TODO: Improve parameter passing
        InfluxStorage(bus=self.bus, topic=topic, config=self.config, channel=channel) 
开发者ID:daq-tools,项目名称:kotori,代码行数:13,代码来源:application.py

示例15: render

# 需要导入模块: import bunch [as 别名]
# 或者: from bunch import Bunch [as 别名]
def render(self, request):
        """
        Main Twisted Resource rendering method,
        overridden to provide custom logic.
        """

        # Pluck ``error_response`` method to request object
        request.error_response = self.error_response

        # Pluck ``channel_identifier`` attribute to request object
        request.channel_identifier = re.sub('/data.*$', '', request.path.replace('/api', ''))

        # Pluck response messages object to request object
        request.messages = []

        # Add informational headers
        request.setHeader('Channel-Id', request.channel_identifier)

        # Main bucket data container object serving the whole downstream processing chain
        bucket = Bunch(path=request.path, request=request)

        # Request processing chain, worker-threaded
        deferred = threads.deferToThread(self.dispatch, request, bucket)
        deferred.addErrback(handleFailure, request)
        deferred.addBoth(self.render_messages, request)
        deferred.addBoth(request.write)
        deferred.addBoth(lambda _: request.finish())
        return server.NOT_DONE_YET 
开发者ID:daq-tools,项目名称:kotori,代码行数:30,代码来源:http.py


注:本文中的bunch.Bunch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。