<commit_before>package org.rakam.bootstrap;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
import com.google.inject.Module;
import io.airlift.bootstrap.Bootstrap;
import io.airlift.log.Logger;
import org.rakam.ServiceStarter;

import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;

public class ProxyBootstrap
        extends Bootstrap {
    private final static Logger LOGGER = Logger.get(ProxyBootstrap.class);

    public ProxyBootstrap(Set<Module> modules) {
        super(modules);
    }

    @Override
    public Injector initialize()
            throws Exception {
        Field modules = Bootstrap.class.getDeclaredField("modules");
        modules.setAccessible(true);
        List<Module> installedModules = (List<Module>) modules.get(this);
        SystemRegistry systemRegistry = new SystemRegistry(null, ImmutableSet.copyOf(installedModules));

        modules.set(this, ImmutableList.builder().addAll(installedModules).add((Module) binder -> {
            binder.bind(SystemRegistry.class).toInstance(systemRegistry);
        }).build());

        String env = System.getProperty("env");
        ArrayList<String> objects = new ArrayList<>();
        if (env != null) {
            LOGGER.info("Reading environment variables starting with `%s`", env);
            System.getenv().entrySet().stream().forEach(e -> System.out.println(e.getKey()));

            System.getenv().entrySet().stream()
                    .filter(entry -> entry.getKey().startsWith(env)).forEach(entry -> {
                String configName = entry.getKey().substring(env.length() + 1)
                        .toLowerCase(Locale.ENGLISH).replaceAll("_", ".");
                objects.add(configName);
                this.setOptionalConfigurationProperty(configName, entry.getValue());
            });

            LOGGER.info("Set the configurations using environment variables (%s)", objects.stream().collect(Collectors.joining(". ")));<commit_msg>Remove hyphen from environment variables<commit_after>package org.rakam.bootstrap;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
import com.google.inject.Module;
import io.airlift.bootstrap.Bootstrap;
import io.airlift.log.Logger;
import org.rakam.ServiceStarter;

import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;

public class ProxyBootstrap
        extends Bootstrap {
    private final static Logger LOGGER = Logger.get(ProxyBootstrap.class);

    public ProxyBootstrap(Set<Module> modules) {
        super(modules);
    }

    @Override
    public Injector initialize()
            throws Exception {
        Field modules = Bootstrap.class.getDeclaredField("modules");
        modules.setAccessible(true);
        List<Module> installedModules = (List<Module>) modules.get(this);
        SystemRegistry systemRegistry = new SystemRegistry(null, ImmutableSet.copyOf(installedModules));

        modules.set(this, ImmutableList.builder().addAll(installedModules).add((Module) binder -> {
            binder.bind(SystemRegistry.class).toInstance(systemRegistry);
        }).build());

        String env = System.getProperty("env");
        ArrayList<String> objects = new ArrayList<>();
        if (env != null) {
            LOGGER.info("Reading environment variables starting with `%s`", env);

            System.getenv().entrySet().stream()
                    .filter(entry -> entry.getKey().startsWith(env)).forEach(entry -> {
                String configName = entry.getKey().substring(env.length() + 1)
                        .toLowerCase(Locale.ENGLISH).replaceAll("__", "-").replaceAll("_", ".");
                objects.add(configName);
                this.setOptionalConfigurationProperty(configName, entry.getValue());
            });

            LOGGER.info("Set the configurations using environment variables (%s)", objects.stream().collect(Collectors.joining(". ")));
{'fraction_non_alphanumeric': 0.12790976721862252, 'fraction_numerical': 0.00047996160307175426, 'mean_word_length': 3.2143579373104147, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 20, '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': '3017436', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1091, 'n_words': 205}