<commit_before>import logging
import os
import time
import warnings
import sys
from threading import local
from py2neo import neo4j
from py2neo.exceptions import ClientError
from py2neo.packages.httpstream import SocketError
from py2neo import cypher as py2neo_cypher
from .exception import CypherException, UniqueProperty, TransactionError

if sys.version_info >= (3, 0):
    from urllib.parse import urlparse
else:
    from urlparse import urlparse  # noqa

logger = logging.getLogger(__name__)

path_to_id = lambda val: int(neo4j.URI(val).path.segments[-1])


class PatchedTransaction(py2neo_cypher.Transaction):
    def __init__(self, uri):
        super(PatchedTransaction, self).__init__(uri)

    def _post(self, resource):
        self._assert_unfinished()
        rs = resource._post({"statements": self._statements})
        location = dict(rs.headers).get("location")
        if location:
            self._execute = py2neo_cypher.Resource(location)
        j = rs.json
        rs.close()
        self._clear()
        if "commit" in j:
            self._commit = py2neo_cypher.Resource(j["commit"])
        if "errors" in j and len(j['errors']):
            error = j["errors"][0]
            txid = int(str(self._execute._resource._uri.path).split('/')[-1])
            raise TransactionError(
                error['message'], error['code'], error['stackTrace'], txid
            )
        out = []
        for result in j["results"]:
            producer = py2neo_cypher.RecordProducer(result["columns"])
            out.append([
                producer.produce(_hydrated(r["rest"]))
                for r in result["data"]
            ])
        return out


class Node(object):
    def __init__(self, data):
        self._id = path_to_id(data['self'])
        self._properties = data.get('data', {})


class Rel(object):
    def __init__(self, data):
        self._id = path_to_id(data['self'])
        self._properties = data.get('data', {})
        self._type = data['type']
        self._start_node_id = path_to_id(data['start'])
        self._end_node_id = path_to_id(data['end'])


def _hydrated(data):
    if isinstance(data, dict):<commit_msg>Handle missing trace<commit_after>import logging
import os
import time
import warnings
import sys
from threading import local
from py2neo import neo4j
from py2neo.exceptions import ClientError
from py2neo.packages.httpstream import SocketError
from py2neo import cypher as py2neo_cypher
from .exception import CypherException, UniqueProperty, TransactionError

if sys.version_info >= (3, 0):
    from urllib.parse import urlparse
else:
    from urlparse import urlparse  # noqa

logger = logging.getLogger(__name__)

path_to_id = lambda val: int(neo4j.URI(val).path.segments[-1])


class PatchedTransaction(py2neo_cypher.Transaction):
    def __init__(self, uri):
        super(PatchedTransaction, self).__init__(uri)

    def _post(self, resource):
        self._assert_unfinished()
        rs = resource._post({"statements": self._statements})
        location = dict(rs.headers).get("location")
        if location:
            self._execute = py2neo_cypher.Resource(location)
        j = rs.json
        rs.close()
        self._clear()
        if "commit" in j:
            self._commit = py2neo_cypher.Resource(j["commit"])
        if "errors" in j and len(j['errors']):
            error = j["errors"][0]
            txid = int(str(self._execute._resource._uri.path).split('/')[-1])
            trace = error.get('stackTrace', error.get('stacktrace', ''))
            raise TransactionError(error['message'], error['code'], trace, txid)
        out = []
        for result in j["results"]:
            producer = py2neo_cypher.RecordProducer(result["columns"])
            out.append([
                producer.produce(_hydrated(r["rest"]))
                for r in result["data"]
            ])
        return out


class Node(object):
    def __init__(self, data):
        self._id = path_to_id(data['self'])
        self._properties = data.get('data', {})


class Rel(object):
    def __init__(self, data):
        self._id = path_to_id(data['self'])
        self._properties = data.get('data', {})
        self._type = data['type']
        self._start_node_id = path_to_id(data['start'])
        self._end_node_id = path_to_id(data['end'])


def _hydrated(data):
    if isinstance(data, dict):
{'fraction_non_alphanumeric': 0.1237419945105215, 'fraction_numerical': 0.007319304666056725, 'mean_word_length': 2.842706502636204, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '4285883', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1297, 'n_words': 299}