當前位置: 首頁>>代碼示例>>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=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

示例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=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

示例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;未經允許,請勿轉載。