<commit_before>from ..exceptions import InvalidChoiceError
from .base import MarathonObject


class MarathonContainer(MarathonObject):
    """Marathon health check.

    See https://mesosphere.github.io/marathon/docs/native-docker.html

    :param docker: docker field (e.g., {"image": "mygroup/myimage"})'
    :type docker: :class:`marathon.models.container.MarathonDockerContainer` or dict
    :param str type:
    :param volumes:
    :type volumes: list[:class:`marathon.models.container.MarathonContainerVolume`] or list[dict]
    """

    TYPES = ['DOCKER']
    """Valid container types"""

    def __init__(self, docker=None, type='DOCKER', volumes=None):
        if not type in self.TYPES:
            raise InvalidChoiceError('type', type, self.TYPES)
        self.type = type
        self.docker = docker if isinstance(docker, MarathonDockerContainer) \
            else MarathonDockerContainer().from_json(docker)
        self.volumes = [
            v if isinstance(v, MarathonContainerVolume) else MarathonContainerVolume().from_json(v)
            for v in (volumes or [])
        ]


class MarathonDockerContainer(MarathonObject):
    """Docker options.

    See https://mesosphere.github.io/marathon/docs/native-docker.html

    :param str image: docker image
    :param str network:
    :param port_mappings:
    :type port_mappings: list[:class:`marathon.models.container.MarathonContainerPortMapping`] or list[dict]
    :param dict parameters:
    :param bool privileged: run container in privileged mode
    """

    NETWORK_MODES=['BRIDGE', 'HOST']
    """Valid network modes"""

    def __init__(self, image=None, network='HOST', port_mappings=None, parameters=None, privileged=None):
        self.image = image
        if network:
            if not network in self.NETWORK_MODES:
                raise InvalidChoiceError('network', network, self.NETWORK_MODES)
            self.network = network
        self.port_mappings = [
            pm if isinstance(pm, MarathonContainerPortMapping) else MarathonContainerPortMapping().from_json(pm)
            for pm in (port_mappings or [])
        ]
        self.parameters = parameters or {}
        self.privileged = privileged or False


class MarathonContainerPortMapping(MarathonObject):
    """Container port mapping.

    See https://mesosphere.github.io/marathon/docs/native-docker.html<commit_msg>Quick fix #29 - add kwargs to MarathonDockerContainer.__init__<commit_after>from ..exceptions import InvalidChoiceError
from .base import MarathonObject


class MarathonContainer(MarathonObject):
    """Marathon health check.

    See https://mesosphere.github.io/marathon/docs/native-docker.html

    :param docker: docker field (e.g., {"image": "mygroup/myimage"})'
    :type docker: :class:`marathon.models.container.MarathonDockerContainer` or dict
    :param str type:
    :param volumes:
    :type volumes: list[:class:`marathon.models.container.MarathonContainerVolume`] or list[dict]
    """

    TYPES = ['DOCKER']
    """Valid container types"""

    def __init__(self, docker=None, type='DOCKER', volumes=None):
        if not type in self.TYPES:
            raise InvalidChoiceError('type', type, self.TYPES)
        self.type = type
        self.docker = docker if isinstance(docker, MarathonDockerContainer) \
            else MarathonDockerContainer().from_json(docker)
        self.volumes = [
            v if isinstance(v, MarathonContainerVolume) else MarathonContainerVolume().from_json(v)
            for v in (volumes or [])
        ]


class MarathonDockerContainer(MarathonObject):
    """Docker options.

    See https://mesosphere.github.io/marathon/docs/native-docker.html

    :param str image: docker image
    :param str network:
    :param port_mappings:
    :type port_mappings: list[:class:`marathon.models.container.MarathonContainerPortMapping`] or list[dict]
    :param dict parameters:
    :param bool privileged: run container in privileged mode
    """

    NETWORK_MODES=['BRIDGE', 'HOST']
    """Valid network modes"""

    def __init__(self, image=None, network='HOST', port_mappings=None, parameters=None, privileged=None, **kwargs):
        self.image = image
        if network:
            if not network in self.NETWORK_MODES:
                raise InvalidChoiceError('network', network, self.NETWORK_MODES)
            self.network = network
        self.port_mappings = [
            pm if isinstance(pm, MarathonContainerPortMapping) else MarathonContainerPortMapping().from_json(pm)
            for pm in (port_mappings or [])
        ]
        self.parameters = parameters or {}
        self.privileged = privileged or False


class MarathonContainerPortMapping(MarathonObject):
    """Container port mapping.

    See https://mesosphere.github.io/marathon/docs/native-docker.html
{'fraction_non_alphanumeric': 0.10655567117585849, 'fraction_numerical': 0.0004162330905306972, 'mean_word_length': 3.279608192341941, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '1656461', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1310, 'n_words': 330}