<commit_before>from functools import partial

from requests_futures.sessions import FuturesSession

from wristband.common.utils import extract_version_from_slug
from wristband.providers import providers_config
from wristband.providers.generics import JsonDataProvider

EXPIRY_JOB_TIME_MINUTES = 10
CONCURRENT_JOBS_LIMIT = 30


class GenericDocktorDataProvider(JsonDataProvider):
    def _get_raw_data(self):
        docktor_config = providers_config.providers['docktor']
        apps = []
        session = FuturesSession(max_workers=10)
        for stage in docktor_config:
            for zone in docktor_config[stage]:
                apps_uri = '{uri}/apps/'.format(uri=docktor_config[stage][zone]['uri'])
                apps_list = session.get(apps_uri).result().json()

                future_apps_details = [session.get('{apps_uri}{app}'.format(apps_uri=apps_uri, app=app)) for app in apps_list]

                apps_details = [a.result() for a in future_apps_details]

                partial_get_app_info = partial(self.get_app_info, stage)

                apps.extend(map(lambda a: partial_get_app_info(a), apps_details))
        return apps

    @staticmethod
    def get_app_info(stage, response):
        data = response.json()
        return {
            'name': data['app'],
            'stage': stage,
            'security_zone': security_zone,
            'version': extract_version_from_slug(data['slug_uri']),
            'state': data['state']
        }<commit_msg>add stage to api output<commit_after>from functools import partial

from requests_futures.sessions import FuturesSession

from wristband.common.utils import extract_version_from_slug
from wristband.providers import providers_config
from wristband.providers.generics import JsonDataProvider

EXPIRY_JOB_TIME_MINUTES = 10
CONCURRENT_JOBS_LIMIT = 30


class GenericDocktorDataProvider(JsonDataProvider):
    def _get_raw_data(self):
        docktor_config = providers_config.providers['docktor']
        apps = []
        session = FuturesSession(max_workers=10)
        for stage in docktor_config:
            for zone in docktor_config[stage]:
                apps_uri = '{uri}/apps/'.format(uri=docktor_config[stage][zone]['uri'])
                apps_list = session.get(apps_uri).result().json()

                future_apps_details = [session.get('{apps_uri}{app}'.format(apps_uri=apps_uri, app=app)) for app in apps_list]

                apps_details = [a.result() for a in future_apps_details]

                partial_get_app_info = partial(self.get_app_info, stage, zone)

                apps.extend(map(lambda a: partial_get_app_info(a), apps_details))
        return apps

    @staticmethod
    def get_app_info(stage, zone, response):
        data = response.json()
        return {
            'name': data['app'],
            'stage': stage,
            'security_zone': zone,
            'version': extract_version_from_slug(data['slug_uri']),
            'state': data['state']
        }
{'fraction_non_alphanumeric': 0.0975609756097561, 'fraction_numerical': 0.004009355162044771, 'mean_word_length': 3.0080321285140563, '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': '3716174', 'n_tokens_mistral': 905, 'n_tokens_neox': 877, 'n_words': 174}