<commit_before>package gw2trades.importer;

import com.fasterxml.jackson.databind.ObjectMapper;
import gw2trades.importer.dao.TradingPost;
import gw2trades.importer.http.ApiClient;
import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

/**
 * TODO
 * @author <NAME> (<EMAIL>)
 */
public class Main {
    public static void main(String[] args) throws Exception {
        ApiClient apiClient = new ApiClient();
        ObjectMapper objectMapper = new ObjectMapper();

        TradingPost tradingPost = new TradingPost();
        tradingPost.setApiClient(apiClient);
        tradingPost.setObjectMapper(objectMapper);

        Config config = readConfig("/import.yaml");

        Importer importer = new Importer(config, tradingPost);
        // TODO: handle errors
        importer.execute();
    }

    private static Config readConfig(String fileName) throws IOException {
        Yaml yamlConfig = new Yaml();
        try (InputStream in = Main.class.getResourceAsStream(fileName)) {
            Map configData = (Map) yamlConfig.load(in);
            return new Config(configData);
        }
    }
}<commit_msg>exit with a specific status code when the import fails<commit_after>package gw2trades.importer;

import com.fasterxml.jackson.databind.ObjectMapper;
import gw2trades.importer.dao.TradingPost;
import gw2trades.importer.http.ApiClient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

/**
 * The importer pulls data from the Guild Wars 2 API and writes it into the repository used by the server module.
 * @author <NAME> (<EMAIL>)
 */
public class Main {
    private static final Logger LOGGER = LogManager.getLogger(Main.class);

    public static void main(String[] args) throws Exception {
        ApiClient apiClient = new ApiClient();
        ObjectMapper objectMapper = new ObjectMapper();

        TradingPost tradingPost = new TradingPost();
        tradingPost.setApiClient(apiClient);
        tradingPost.setObjectMapper(objectMapper);

        Config config = readConfig("/import.yaml");

        Importer importer = new Importer(config, tradingPost);
        try {
            importer.execute();
        } catch (IOException e) {
            LOGGER.error("Could not import: {}", e.getMessage(), e);
            System.exit(1);
        }
    }

    private static Config readConfig(String fileName) throws IOException {
        Yaml yamlConfig = new Yaml();
        try (InputStream in = Main.class.getResourceAsStream(fileName)) {
            Map configData = (Map) yamlConfig.load(in);
            return new Config(configData);
        }
    }
}
{'fraction_non_alphanumeric': 0.10018018018018018, 'fraction_numerical': 0.0036036036036036037, 'mean_word_length': 3.174436090225564, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '928388', 'n_tokens_mistral': 786, 'n_tokens_neox': 771, 'n_words': 202}