<commit_before>import gevent
import logging
import os
import signal
import six
import sys
from setproctitle import setproctitle

from lymph.utils import import_object
from lymph.autoreload import set_source_change_callback
from lymph.cli.base import Command
from lymph.core.container import create_container


logger = logging.getLogger(__name__)


def install_plugins(container, plugins):
    for name, plugin_config in six.iteritems(plugins):
        cls = import_object(plugin_config['class'])
        container.install_plugin(cls, **plugin_config)


def install_interfaces(container, interfaces):
    for name, instance_config in six.iteritems(interfaces):
        try:
            cls_name = instance_config['class']
        except KeyError:
            print("no instance class for '%s'" % name)
            sys.exit(1)
        cls = import_object(cls_name)
        instance = container.install(cls)
        instance.apply_config(instance_config)


class InstanceCommand(Command):
    """
    Usage: lymph instance [--ip=<address> | --guess-external-ip | -g]
                         [--port <port> | -p <port>] [--reload] [--debug]
                         [--interface=<cls>]... [options]

    {INSTANCE_OPTIONS}<commit_msg>Setting the service_type from the config<commit_after>import gevent
import logging
import os
import signal
import six
import sys
from setproctitle import setproctitle

from lymph.utils import import_object
from lymph.autoreload import set_source_change_callback
from lymph.cli.base import Command
from lymph.core.container import create_container


logger = logging.getLogger(__name__)


def install_plugins(container, plugins):
    for name, plugin_config in six.iteritems(plugins):
        cls = import_object(plugin_config['class'])
        container.install_plugin(cls, **plugin_config)


def install_interfaces(container, interfaces):
    for name, instance_config in six.iteritems(interfaces):
        try:
            cls_name = instance_config['class']
        except KeyError:
            print("no instance class for '%s'" % name)
            sys.exit(1)
        cls = import_object(cls_name)
        cls.service_type = name
        instance = container.install(cls)
        instance.apply_config(instance_config)


class InstanceCommand(Command):
    """
    Usage: lymph instance [--ip=<address> | --guess-external-ip | -g]
                         [--port <port> | -p <port>] [--reload] [--debug]
                         [--interface=<cls>]... [options]

    {INSTANCE_OPTIONS}
{'fraction_non_alphanumeric': 0.09988109393579073, 'fraction_numerical': 0.0007927070947284979, 'mean_word_length': 3.0709677419354837, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7017467', 'n_tokens_mistral': 729, 'n_tokens_neox': 689, 'n_words': 182}