<commit_before>import csv
import multiprocessing
import os
import traceback
try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

# Import matplotlib ourselves and make it use agg (not any GUI anything)
# before the analyze module pulls it in.
import matplotlib
matplotlib.use('Agg')
from analysis import process, plot  # noqa: E402

from bottle import get, post, redirect, request, response, jinja2_template as template  # noqa: E402

import config  # noqa: E402
import utils   # noqa: E402


@get('/stats/')
def get_stats():
    tracks = request.query.tracks.split('|')
    do_csv = request.query.csv
    stats = []
    all_keys = set()
    for track in tracks:
        curstats = {}
        curstats['Track file'] = track

        try:
            processor = process.TrackProcessor(track)
        except ValueError as e:
            # often 'wrong number of columns' due to truncated file from killed experiment
            return template('error', errormsg="Failed to parse %s.  Please check and correct the file, deselect it, or archive it." % track, exception=traceback.format_exc())

        curstats.update(processor.read_setup(['experiment', 'at_runtime']))
        curstats.update(processor.get_stats())
        for i in range(processor.len_minutes):
            curstats.update(processor.get_stats(minute=i))
            all_keys.update(curstats.keys())
        stats.append(curstats)
    for i in range(len(stats)):
        stat = stats[i]
        for k in all_keys:
            import numpy as np<commit_msg>No more per-minute stats (for now)<commit_after>import csv
import multiprocessing
import os
import traceback
try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

# Import matplotlib ourselves and make it use agg (not any GUI anything)
# before the analyze module pulls it in.
import matplotlib
matplotlib.use('Agg')
from analysis import process, plot  # noqa: E402

from bottle import get, post, redirect, request, response, jinja2_template as template  # noqa: E402

import config  # noqa: E402
import utils   # noqa: E402


@get('/stats/')
def get_stats():
    tracks = request.query.tracks.split('|')
    do_csv = request.query.csv
    stats = []
    all_keys = set()
    for track in tracks:
        curstats = {}
        curstats['Track file'] = track

        try:
            processor = process.TrackProcessor(track)
        except ValueError as e:
            # often 'wrong number of columns' due to truncated file from killed experiment
            return template('error', errormsg="Failed to parse %s.  Please check and correct the file, deselect it, or archive it." % track, exception=traceback.format_exc())

        curstats.update(processor.read_setup(['experiment', 'at_runtime']))
        curstats.update(processor.get_stats())
        #for i in range(processor.len_minutes):
        #    curstats.update(processor.get_stats(minute=i))
        #    all_keys.update(curstats.keys())
        all_keys.update(curstats.keys())
        stats.append(curstats)
    for i in range(len(stats)):
        stat = stats[i]
        for k in all_keys:
            import numpy as np
{'fraction_non_alphanumeric': 0.09316965690903369, 'fraction_numerical': 0.008183821214982689, 'mean_word_length': 3.0227848101265824, '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': '750024', 'n_tokens_mistral': 932, 'n_tokens_neox': 894, 'n_words': 303}