<commit_before>#!/bin/python
from .import API
from .import dataset
from .import backtest<commit_msg>moving all gekko-specific ops here<commit_after>#!/bin/python
import os
import subprocess

from .import API
from .import dataset
from .import backtest
from .statistics import *
import pathlib


class GekkoEvaluator():
    def __init__(self):
        pass


SettingsFiles = [
    "generation",
    "Global",
    "dataset",
    #"indicator",
    "backtest",
    "evalbreak"
]


def validateSettings(settings):
    # LOCATE & VALIDATE RUNNING GEKKO INSTANCES FROM CONFIG URLs;
    possibleInstances = settings['Global']['GekkoURLs']
    validatedInstances = []
    for instance in possibleInstances:
        Response = API.checkInstance(instance)
        if Response:
            validatedInstances.append(instance)
            print("found gekko @ %s" % instance)
        else:
            print("unable to locate %s" % instance)

    if validatedInstances:
        settings['Global']['GekkoURLs'] = validatedInstances

    else:
        print("Aborted: No running gekko instances found.")
        return False

    GekkoPath = settings['Global']['gekkoPath'] + '/gekko.js'
    GekkoPath = GekkoPath.replace("$HOME", str(pathlib.Path.home()))
    if not os.path.isfile(GekkoPath):
        print(
            "Aborted: gekko.js not found" + 
            "on path specified @Settings.py;\n%s" % GekkoPath)
        return False

    return True


# DEPRECATED;
def launchGekkoChildProcess(settings):
    gekko_args = [
        'node',
        '--max-old-space-size=8192',
        settings['global']['gekkoPath'] + '/web/server.js',
    ]
    gekko_server = subprocess.Popen(gekko_args,
                                    stdin=subprocess.PIPE,
                                    stdout=subprocess.PIPE)
    return gekko_server


{'fraction_non_alphanumeric': 0.11013698630136987, 'fraction_numerical': 0.002191780821917808, 'mean_word_length': 2.545631067961165, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5974248', 'n_tokens_mistral': 573, 'n_tokens_neox': 554, 'n_words': 126}