<commit_before>import asyncio
import json
import os
import uuid
from http import client as http_client

import sqlalchemy as sa
from aiohttp import web
from aiopg import sa as aiopg_sa
from yieldfrom.botocore import exceptions as botocore_exceptions
from yieldfrom.botocore import session as botocore_session


create_table = """
CREATE TABLE IF NOT EXISTS test_session (
    pk VARCHAR DISTKEY SORTKEY NOT NULL,
    created_time TIMESTAMP DEFAULT SYSDATE NOT NULL,
    PRIMARY KEY (pk)
)
"""


class ClusterControl(object):
    cluster_name = 'redshift-sqlalchemy-test'
    username = 'travis'
    password = os.environ['PGPASSWORD']

    def __init__(self, client):
        self.client = client

    @asyncio.coroutine
    def get_or_create(self):
        cluster_identifier = self.cluster_name
        client = self.client
        username = self.username
        password = <PASSWORD>

        try:
            response = yield from client.create_cluster(
                ClusterIdentifier=cluster_identifier,
                NodeType='dc1.large',
                ClusterType='single-node',
                VpcSecurityGroupIds=['sg-a8f55bcc'],
                MasterUsername=username,
                MasterUserPassword=password,
                PubliclyAccessible=True,
                ClusterParameterGroupName='default.redshift-1.0',
            )
        except botocore_exceptions.ClientError as e:
            if e.response['Error']['Code'] != 'ClusterAlreadyExists':
                raise e
            return (yield from self.get())
        else:
            return response['Cluster']['Endpoint']

    @asyncio.coroutine
    def get(self):
        client = self.client
        cluster_identifier = self.cluster_name
        response = yield from client.describe_clusters(
            ClusterIdentifier=cluster_identifier,
        )
        return response['Clusters'][0]['Endpoint']

    @asyncio.coroutine
    def destroy(self):
        raise Exception()
        cluster_identifier = self.cluster_name
        client = self.client
        try:
            yield from client.delete_cluster(
                ClusterIdentifier=cluster_identifier,
                SkipFinalClusterSnapshot=True,
            )
        except botocore_exceptions.ClientError as e:
            if e.response['Error']['Code'] != 'InvalidClusterState':
                raise e


class Database(object):
    def __init__(self, conn):
        self.conn = conn

    @asyncio.coroutine
    def add_test_session(self, uuid):
        trans = yield from self.conn.begin()
        try:<commit_msg>enable destruction<commit_after>import asyncio
import json
import os
import uuid
from http import client as http_client

import sqlalchemy as sa
from aiohttp import web
from aiopg import sa as aiopg_sa
from yieldfrom.botocore import exceptions as botocore_exceptions
from yieldfrom.botocore import session as botocore_session


create_table = """
CREATE TABLE IF NOT EXISTS test_session (
    pk VARCHAR DISTKEY SORTKEY NOT NULL,
    created_time TIMESTAMP DEFAULT SYSDATE NOT NULL,
    PRIMARY KEY (pk)
)
"""


class ClusterControl(object):
    cluster_name = 'redshift-sqlalchemy-test'
    username = 'travis'
    password = <PASSWORD>['<PASSWORD>']

    def __init__(self, client):
        self.client = client

    @asyncio.coroutine
    def get_or_create(self):
        cluster_identifier = self.cluster_name
        client = self.client
        username = self.username
        password = self.password

        try:
            response = yield from client.create_cluster(
                ClusterIdentifier=cluster_identifier,
                NodeType='dc1.large',
                ClusterType='single-node',
                VpcSecurityGroupIds=['sg-a8f55bcc'],
                MasterUsername=username,
                MasterUserPassword=password,
                PubliclyAccessible=True,
                ClusterParameterGroupName='default.redshift-1.0',
            )
        except botocore_exceptions.ClientError as e:
            if e.response['Error']['Code'] != 'ClusterAlreadyExists':
                raise e
            return (yield from self.get())
        else:
            return response['Cluster']['Endpoint']

    @asyncio.coroutine
    def get(self):
        client = self.client
        cluster_identifier = self.cluster_name
        response = yield from client.describe_clusters(
            ClusterIdentifier=cluster_identifier,
        )
        return response['Clusters'][0]['Endpoint']

    @asyncio.coroutine
    def destroy(self):
        cluster_identifier = self.cluster_name
        client = self.client
        try:
            yield from client.delete_cluster(
                ClusterIdentifier=cluster_identifier,
                SkipFinalClusterSnapshot=True,
            )
        except botocore_exceptions.ClientError as e:
            if e.response['Error']['Code'] != 'InvalidClusterState':
                raise e


class Database(object):
    def __init__(self, conn):
        self.conn = conn

    @asyncio.coroutine
    def add_test_session(self, uuid):
        trans = yield from self.conn.begin()
        try:
{'fraction_non_alphanumeric': 0.07904984423676012, 'fraction_numerical': 0.0027258566978193145, 'mean_word_length': 2.3400520156046816, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '69053', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1340, 'n_words': 336}