<commit_before>import time
import os

from elasticsearch import Elasticsearch
from elasticsearch.exceptions import ConnectionError, NotFoundError

from ..test_cases import TestCase, SkipTest

client = None

def get_client():
    global client
    if client is not None:
        return client

    # construct kwargs from the environment
    kw = {}
    if 'TEST_ES_CONNECTION' in os.environ:
        from elasticsearch import connection
        kw['connection_class'] = getattr(connection, os.environ['TEST_ES_CONNECTION'])

    # try and locate manual override in the local environment
    try:
        from test_elasticsearch.local import get_client as local_get_client
        client = local_get_client([os.environ.get('TEST_ES_SERVER', {})], **kw)
    except ImportError:
        # fallback to using vanilla client
        client = Elasticsearch([os.environ.get('TEST_ES_SERVER', {})], **kw)

    # wait for yellow status
    for _ in range(100):
        time.sleep(.1)
        try:
            client.cluster.health(wait_for_status='yellow')
            return client
        except ConnectionError:
            continue
    else:
        # timeout
        raise SkipTest("Elasticsearch failed to start.")

def setup():
    get_client()

ES_VERSION = None

def _get_version(version_string):
    version = version_string.strip().split('.')
    return tuple(int(v) if v.isdigit() else 999 for v in version)

class ElasticTestCase(TestCase):
    client = None
    def setUp(self):
        if ElasticTestCase.client is None:
            ElasticTestCase.client = get_client()
        self.client = ElasticTestCase.client

    def tearDown(self):
        self.client.indices.delete('*')
        try:
            self.client.indices.delete_template('*')
        except NotFoundError:
            pass

    @property
    def es_version(self):
        global ES_VERSION
        if ES_VERSION is None:
            version_string = self.client.info()['version']['number']
            ES_VERSION = _get_version(version_string)
        return ES_VERSION

<commit_msg>Raise the timeout for the server to come up. Maybe travis will make it.<commit_after>import time
import os

from elasticsearch import Elasticsearch
from elasticsearch.exceptions import ConnectionError, NotFoundError

from ..test_cases import TestCase, SkipTest

client = None

def get_client():
    global client
    if client is not None:
        return client

    # construct kwargs from the environment
    kw = {}
    if 'TEST_ES_CONNECTION' in os.environ:
        from elasticsearch import connection
        kw['connection_class'] = getattr(connection, os.environ['TEST_ES_CONNECTION'])

    # try and locate manual override in the local environment
    try:
        from test_elasticsearch.local import get_client as local_get_client
        client = local_get_client([os.environ.get('TEST_ES_SERVER', {})], **kw)
    except ImportError:
        # fallback to using vanilla client
        client = Elasticsearch([os.environ.get('TEST_ES_SERVER', {})], **kw)

    # wait for yellow status
    for _ in range(200):
        time.sleep(.1)
        try:
            client.cluster.health(wait_for_status='yellow')
            return client
        except ConnectionError:
            continue
    else:
        # timeout
        raise SkipTest("Elasticsearch failed to start.")

def setup():
    get_client()

ES_VERSION = None

def _get_version(version_string):
    version = version_string.strip().split('.')
    return tuple(int(v) if v.isdigit() else 999 for v in version)

class ElasticTestCase(TestCase):
    client = None
    def setUp(self):
        if ElasticTestCase.client is None:
            ElasticTestCase.client = get_client()
        self.client = ElasticTestCase.client

    def tearDown(self):
        self.client.indices.delete('*')
        try:
            self.client.indices.delete_template('*')
        except NotFoundError:
            pass

    @property
    def es_version(self):
        global ES_VERSION
        if ES_VERSION is None:
            version_string = self.client.info()['version']['number']
            ES_VERSION = _get_version(version_string)
        return ES_VERSION


{'fraction_non_alphanumeric': 0.0871647509578544, 'fraction_numerical': 0.003352490421455939, 'mean_word_length': 2.7228163992869874, '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': '6529558', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1143, 'n_words': 323}