<commit_before>from fabric.api import cd, get, run, settings, shell_env

from logger import logger
from perfrunner.remote.context import all_clients
from perfrunner.settings import REPO


class Remote:

    CLIENT_PROCESSES = 'celery', 'cbc-pillowfight'

    def __init__(self, cluster_spec, test_config, os):
        self.os = os
        self.cluster_spec = cluster_spec
        self.test_config = test_config

    @staticmethod
    def wget(url, outdir='/tmp', outfile=None):
        logger.info('Fetching {}'.format(url))
        if outfile is not None:
            run('wget -nc "{}" -P {} -O {}'.format(url, outdir, outfile))
        else:
            run('wget -N "{}" -P {}'.format(url, outdir))

    @all_clients
    def clean_clients(self, temp_dir):
        run('killall -2 {}'.format(' '.join(self.CLIENT_PROCESSES)), quiet=True)

        run('rm -fr {}'.format(temp_dir))

    @all_clients
    def init_repo(self, worker_home: str):
        run('mkdir -p {}'.format(worker_home))

        with cd(worker_home):
            run('git clone -q {}'.format(REPO))

            with cd('perfrunner'):
                run('make')

    def start_celery_worker(self, worker, worker_home):
        with settings(host_string=worker):
            with cd(worker_home), shell_env(PYTHONOPTIMIZE='1',<commit_msg>Revert "Gracefully terminate remote Celery workers"<commit_after>from fabric.api import cd, get, run, settings, shell_env

from logger import logger
from perfrunner.remote.context import all_clients
from perfrunner.settings import REPO


class Remote:

    CLIENT_PROCESSES = 'celery', 'cbc-pillowfight'

    def __init__(self, cluster_spec, test_config, os):
        self.os = os
        self.cluster_spec = cluster_spec
        self.test_config = test_config

    @staticmethod
    def wget(url, outdir='/tmp', outfile=None):
        logger.info('Fetching {}'.format(url))
        if outfile is not None:
            run('wget -nc "{}" -P {} -O {}'.format(url, outdir, outfile))
        else:
            run('wget -N "{}" -P {}'.format(url, outdir))

    @all_clients
    def clean_clients(self, temp_dir):
        run('killall -9 {}'.format(' '.join(self.CLIENT_PROCESSES)), quiet=True)

        run('rm -fr {}'.format(temp_dir))

    @all_clients
    def init_repo(self, worker_home: str):
        run('mkdir -p {}'.format(worker_home))

        with cd(worker_home):
            run('git clone -q {}'.format(REPO))

            with cd('perfrunner'):
                run('make')

    def start_celery_worker(self, worker, worker_home):
        with settings(host_string=worker):
            with cd(worker_home), shell_env(PYTHONOPTIMIZE='1',
{'fraction_non_alphanumeric': 0.1346877351392024, 'fraction_numerical': 0.0015048908954100827, 'mean_word_length': 2.8204022988505746, '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': '2336149', 'n_tokens_mistral': 892, 'n_tokens_neox': 856, 'n_words': 202}