<commit_before>import threading
from itertools import ifilter
from py2neo import neo4j
from engine import Engine
from session import Session

__all__ = ['metadata']

class MetaData(object):

    def __init__(self, url='http://localhost:7474/db/data/', debug=False):
        self.url = url
        self.engine = url
        self.debug = debug
        self._session = Session(metadata=self)
        self._classes = {}

    @property
    def engine(self):
        return self._engine.instance

    @engine.setter
    def engine(self, url):
        self._engine = Engine(url=url, metadata=self)

    @property
    def batch(self):
        return self._engine.batch

    @property
    def cypher(self):
        return self._engine.cypher

    @property
    def session(self):
        return self._session

    @property
    def classes(self):
        return self._classes

    def init(self, reset=False):
        from node import Node
        batch = self.batch()
        for cls in ifilter(lambda x: issubclass(x, Node), self.classes.itervalues()):
            n = cls.classnode
            if reset:
                batch.cypher("start n=node({0}) match n-[r:EXTENDS]->() delete r".format(n.id))
            for b in (x.classnode for x in cls.__bases__ if issubclass(x, Node)):
                batch.cypher("start n=node({0}), b=node({1}) create unique n-[r:EXTENDS]->b".format(n.id, b.id))
        batch.submit()

metadata = MetaData()<commit_msg>fix to classnode hierarchy reset<commit_after>import threading
from itertools import ifilter
from py2neo import neo4j
from engine import Engine
from session import Session

__all__ = ['metadata']

class MetaData(object):

    def __init__(self, url='http://localhost:7474/db/data/', debug=False):
        self.url = url
        self.engine = url
        self.debug = debug
        self._session = Session(metadata=self)
        self._classes = {}

    @property
    def engine(self):
        return self._engine.instance

    @engine.setter
    def engine(self, url):
        self._engine = Engine(url=url, metadata=self)

    @property
    def batch(self):
        return self._engine.batch

    @property
    def cypher(self):
        return self._engine.cypher

    @property
    def session(self):
        return self._session

    @property
    def classes(self):
        return self._classes

    def init(self, reset=False):
        from node import Node
        batch = self.batch()
        for cls in ifilter(lambda x: issubclass(x, Node), self.classes.itervalues()):
            n = cls.classnode
            if reset:
                batch.cypher("start n=node({0}) match n-[r:EXTENDS]-() delete r".format(n.id))
            for b in (x.classnode for x in cls.__bases__ if issubclass(x, Node)):
                batch.cypher("start n=node({0}), b=node({1}) create unique n-[r:EXTENDS]->b".format(n.id, b.id))
        batch.submit()

metadata = MetaData()
{'fraction_non_alphanumeric': 0.11718213058419244, 'fraction_numerical': 0.006185567010309278, 'mean_word_length': 2.4613555291319855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '1139261', 'n_tokens_mistral': 903, 'n_tokens_neox': 871, 'n_words': 233}