<commit_before>import contextlib
import logging
import subprocess

LOGGER = logging.getLogger(__name__)

def execute(command):
    LOGGER.debug("Executing %s", ' '.join(command))
    proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = proc.communicate(input=None)
    if proc.returncode != 0:
        raise Exception("Failed to execute command {}".format(' '.join(command)))
    LOGGER.debug("stdout %s", stdout)
    LOGGER.debug("stderr %s", stderr)

@contextlib.contextmanager
def stash():
    execute(['git', 'stash', '-u', '--keep-index'])
    yield
    execute(['git', 'reset', '--hard'])
    execute(['git', 'stash', 'pop', '--quiet', '--index'])<commit_msg>Put un-stash in finally block<commit_after>import contextlib
import logging
import subprocess

LOGGER = logging.getLogger(__name__)

def execute(command):
    LOGGER.debug("Executing %s", ' '.join(command))
    proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = proc.communicate(input=None)
    if proc.returncode != 0:
        raise Exception("Failed to execute command {}".format(' '.join(command)))
    LOGGER.debug("stdout %s", stdout)
    LOGGER.debug("stderr %s", stderr)

@contextlib.contextmanager
def stash():
    execute(['git', 'stash', '-u', '--keep-index'])
    try:
       yield
    finally:
        execute(['git', 'reset', '--hard'])
        execute(['git', 'stash', 'pop', '--quiet', '--index'])
{'fraction_non_alphanumeric': 0.1780636425186188, 'fraction_numerical': 0.0013540961408259986, 'mean_word_length': 4.149825783972125, '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': '5855005', 'n_tokens_mistral': 474, 'n_tokens_neox': 476, 'n_words': 109}