<commit_before>#!/usr/bin/env python3
"""
enable_mount_voluems - Creator and Configurator of MOUNT volumes

Features:
1. Create GP2 SSD volumes for each private agent
2. Attaches volumes to each private agent
3. Formats volumes and configures fstab entires
4. Configures Mesos Agent and relaunches instances for changes to take effect.

Note: Currently, enable_mount_volumes only works with AWS DC/OS clusters.
"""

import boto3
import botocore
import logging
import os
import pprint
import sys
import time
import uuid

from fabric.api import run, env
from fabric.tasks import execute

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(message)s")


def tag_match(instance, key, value):
    tags = instance.get('Tags')
    if not tags:
        return False
    for tag in tags:
        if tag.get('Key') == key and tag.get('Value') == value:
            return True
    return False


def filter_reservations_tags(reservations, filter_key, filter_value):
    filtered_reservations = []
    logger.info('Values for {} (searching for "{}"):'.format(filter_key, filter_value))
    for reservation in reservations:
        instances = reservation['Instances']
        if tag_match(reservation['Instances'][0], filter_key, filter_value):
            filtered_reservations.append(reservation)
    return filtered_reservations<commit_msg>Force fabric spam to stderr, not stdout<commit_after>#!/usr/bin/env python3
"""
enable_mount_voluems - Creator and Configurator of MOUNT volumes

Features:
1. Create GP2 SSD volumes for each private agent
2. Attaches volumes to each private agent
3. Formats volumes and configures fstab entires
4. Configures Mesos Agent and relaunches instances for changes to take effect.

Note: Currently, enable_mount_volumes only works with AWS DC/OS clusters.
"""

import boto3
import botocore
import logging
import os
import pprint
import sys
import time
import uuid

from fabric.api import run, env
from fabric.tasks import execute

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(message)s")

# fabric spams to stdout, which causes problems with launch_ccm_cluster.
# force total redirect to stderr:
stdout = sys.stdout
sys.stdout = sys.stderr


def tag_match(instance, key, value):
    tags = instance.get('Tags')
    if not tags:
        return False
    for tag in tags:
        if tag.get('Key') == key and tag.get('Value') == value:
            return True
    return False


def filter_reservations_tags(reservations, filter_key, filter_value):
    filtered_reservations = []
    logger.info('Values for {} (searching for "{}"):'.format(filter_key, filter_value))
    for reservation in reservations:
        instances = reservation['Instances']
        if tag_match(reservation['Instances'][0], filter_key, filter_value):
            filtered_reservations.append(reservation)
    return filtered_reservations
{'fraction_non_alphanumeric': 0.08476321207961565, 'fraction_numerical': 0.00549073438572409, 'mean_word_length': 4.2428057553956835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2243010', 'n_tokens_mistral': 841, 'n_tokens_neox': 827, 'n_words': 287}