<commit_before>import copy
import types
import time

SILENCE = -3

class AALModel:
    def __init__(self, model_globals):
        self._all_guards = self._get_all("guard", "action")
        self._all_bodies = self._get_all("body", "action")
        self._all_adapters = self._get_all("adapter", "action")
        self._all_names = self._get_all("name", "action")
        self._all_types = self._get_all("type", "action")
        self._all_tagnames = self._get_all("name", "tag")
        self._all_tagguards = self._get_all("guard", "tag")
        self._variables = model_globals
        self._variables['action'] = lambda name: self._all_names.index(name)
        self._variables['name'] = lambda name: self._all_names.index(name)
        self._variables['variable'] = lambda varname: self._variables[varname]
        self._variables['assign'] = lambda varname, v: self._variables.__setitem__(varname, v)
        self._stack = []

    def _get_all(self, property_name, itemtype):
        plist = []
        i = 1
        while 1:
            try: plist.append(getattr(self, itemtype + str(i) + property_name))
            except: return plist
            i += 1

    def call(self, func, call_arguments = ()):
        try:
            self._variables['args'] = call_arguments
            return eval(func.func_code, self._variables)
        except Exception, e:
            self._log("Exception %s in %s: %s" % (e.__class__, func.func_name, e))

    def reset(self):<commit_msg>aalmodel.py: pass through exceptions on calls for better logging<commit_after>import copy
import types
import time

SILENCE = -3

class AALModel:
    def __init__(self, model_globals):
        self._all_guards = self._get_all("guard", "action")
        self._all_bodies = self._get_all("body", "action")
        self._all_adapters = self._get_all("adapter", "action")
        self._all_names = self._get_all("name", "action")
        self._all_types = self._get_all("type", "action")
        self._all_tagnames = self._get_all("name", "tag")
        self._all_tagguards = self._get_all("guard", "tag")
        self._variables = model_globals
        self._variables['action'] = lambda name: self._all_names.index(name)
        self._variables['name'] = lambda name: self._all_names.index(name)
        self._variables['variable'] = lambda varname: self._variables[varname]
        self._variables['assign'] = lambda varname, v: self._variables.__setitem__(varname, v)
        self._stack = []

    def _get_all(self, property_name, itemtype):
        plist = []
        i = 1
        while 1:
            try: plist.append(getattr(self, itemtype + str(i) + property_name))
            except: return plist
            i += 1

    def call(self, func, call_arguments = ()):
        try:
            args = []
            for arg in call_arguments:
                if arg == '':
                    args.append('')
                else:
                    args.append(eval(arg, self._variables))
            self._variables['args'] = args
            return eval(func.func_code, self._variables)
        except Exception, e:
            self._log("Exception %s in %s: %s" % (e.__class__, func.func_name, e))
            raise e

    def reset(self):
{'fraction_non_alphanumeric': 0.12895226286422815, 'fraction_numerical': 0.0024798512089274642, 'mean_word_length': 2.492424242424242, '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': '186119', 'n_tokens_mistral': 987, 'n_tokens_neox': 961, 'n_words': 214}