<commit_before>from flask import Blueprint, render_template, current_app, jsonify, request, redirect, url_for
import subprocess

import cea.scripts
import cea.inputlocator
import cea.config
import os

blueprint = Blueprint(
    'tools_blueprint',
    __name__,
    url_prefix='/tools',
    template_folder='templates',
    static_folder='static',
)


@blueprint.route("/")
def route_index():
    return render_template("job_table.html")


@blueprint.route('/start/<jobid>', methods=['POST'])
def route_start(jobid):
    """Start a ``cea-worker`` subprocess for the script. (FUTURE: add support for cloud-based workers"""
    print("tools/route_start: {jobid}".format(**locals()))
    subprocess.Popen(["cea-worker", jobid])
    return jsonify(jobid)


@blueprint.route('/save-config/<script>', methods=['POST'])
def route_save_config(script):
    """Save the configuration for this tool to the configuration file"""
    for parameter in parameters_for_script(script, current_app.cea_config):
        print('%s: %s' % (parameter.name, request.form.get(parameter.name)))
        parameter.set(parameter.decode(request.form.get(parameter.name)))
    current_app.cea_config.save()
    return jsonify(True)


@blueprint.route('/restore-defaults/<script_name>')
def route_restore_defaults(script_name):<commit_msg>drop PATH requirement<commit_after>from flask import Blueprint, render_template, current_app, jsonify, request, redirect, url_for
import subprocess

import cea.scripts
import cea.inputlocator
import cea.config
import os

blueprint = Blueprint(
    'tools_blueprint',
    __name__,
    url_prefix='/tools',
    template_folder='templates',
    static_folder='static',
)


@blueprint.route("/")
def route_index():
    return render_template("job_table.html")


@blueprint.route('/start/<jobid>', methods=['POST'])
def route_start(jobid):
    """Start a ``cea-worker`` subprocess for the script. (FUTURE: add support for cloud-based workers"""
    print("tools/route_start: {jobid}".format(**locals()))
    subprocess.Popen(["python", "-m", "cea.worker", jobid])
    return jsonify(jobid)


@blueprint.route('/save-config/<script>', methods=['POST'])
def route_save_config(script):
    """Save the configuration for this tool to the configuration file"""
    for parameter in parameters_for_script(script, current_app.cea_config):
        print('%s: %s' % (parameter.name, request.form.get(parameter.name)))
        parameter.set(parameter.decode(request.form.get(parameter.name)))
    current_app.cea_config.save()
    return jsonify(True)


@blueprint.route('/restore-defaults/<script_name>')
def route_restore_defaults(script_name):
{'fraction_non_alphanumeric': 0.14356060606060606, 'fraction_numerical': 0.0, 'mean_word_length': 5.318181818181818, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5887013', 'n_tokens_mistral': 828, 'n_tokens_neox': 818, 'n_words': 173}