mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-01 03:23:27 +08:00
exception paths are now relative to zipline_repo. if the path is outside of zipline_repo, it is truncated to just the filename.
This commit is contained in:
@@ -94,66 +94,66 @@ class ExceptionTestCase(TestCase):
|
||||
|
||||
|
||||
INITIALIZE_TB =\
|
||||
[{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
|
||||
[{'filename': '/zipline/core/component.py',
|
||||
'line': 'self._run()',
|
||||
'lineno': 204,
|
||||
'method': 'run'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
|
||||
{'filename': '/zipline/core/component.py',
|
||||
'line': 'self.loop()',
|
||||
'lineno': 195,
|
||||
'method': '_run'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
|
||||
{'filename': '/zipline/core/component.py',
|
||||
'line': 'self.do_work()',
|
||||
'lineno': 235,
|
||||
'method': 'loop'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'self.initialize_algo()',
|
||||
'lineno': 97,
|
||||
'method': 'do_work'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'self.do_op(self.algorithm.initialize)',
|
||||
'lineno': 80,
|
||||
'method': 'initialize_algo'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'callable_op(*args, **kwargs)',
|
||||
'lineno': 206,
|
||||
'method': 'do_op'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py',
|
||||
{'filename': '/zipline/test_algorithms.py',
|
||||
'line': 'raise Exception("Algo exception in initialize")',
|
||||
'lineno': 166,
|
||||
'method': 'initialize'}]
|
||||
|
||||
|
||||
HANDLE_DATA_TB =\
|
||||
[{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
|
||||
[{'filename': '/zipline/core/component.py',
|
||||
'line': 'self._run()',
|
||||
'lineno': 204,
|
||||
'method': 'run'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
|
||||
{'filename': '/zipline/core/component.py',
|
||||
'line': 'self.loop()',
|
||||
'lineno': 195,
|
||||
'method': '_run'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py',
|
||||
{'filename': '/zipline/core/component.py',
|
||||
'line': 'self.do_work()',
|
||||
'lineno': 235,
|
||||
'method': 'loop'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'self.process_event(event)',
|
||||
'lineno': 116,
|
||||
'method': 'do_work'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'self.run_algorithm()',
|
||||
'lineno': 164,
|
||||
'method': 'process_event'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'self.do_op(self.algorithm.handle_data, data)',
|
||||
'lineno': 186,
|
||||
'method': 'run_algorithm'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py',
|
||||
{'filename': '/zipline/components/tradesimulation.py',
|
||||
'line': 'callable_op(*args, **kwargs)',
|
||||
'lineno': 206,
|
||||
'method': 'do_op'},
|
||||
{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py',
|
||||
{'filename': '/zipline/test_algorithms.py',
|
||||
'line': 'raise Exception("Algo exception in handle_data")',
|
||||
'lineno': 187,
|
||||
'method': 'handle_data'}]
|
||||
|
||||
+21
-1
@@ -119,6 +119,8 @@ import numbers
|
||||
import datetime
|
||||
import pytz
|
||||
import traceback
|
||||
import re
|
||||
import os
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -524,8 +526,9 @@ def EXCEPTION_FRAME(exception_tb):
|
||||
stack_list = traceback.extract_tb(exception_tb)
|
||||
rlist = []
|
||||
for stack in stack_list:
|
||||
filename = shorten_filename(stack[0])
|
||||
rstack = {
|
||||
'filename' : stack[0],
|
||||
'filename' : filename,
|
||||
'lineno' : stack[1],
|
||||
'method' : stack[2],
|
||||
'line' : stack[3]
|
||||
@@ -538,6 +541,23 @@ def EXCEPTION_FRAME(exception_tb):
|
||||
|
||||
return BT_UPDATE_FRAME('EXCEPTION', result)
|
||||
|
||||
def shorten_filename(filename):
|
||||
if filename == None:
|
||||
return None
|
||||
|
||||
# check if the path contains zipeline_repo
|
||||
path_re = r'(?<=zipline_repo).*'
|
||||
match = re.search(path_re, filename)
|
||||
|
||||
if match:
|
||||
return match.group(0)
|
||||
parts = filename.split('zipline_repo')
|
||||
return parts[1]
|
||||
else:
|
||||
# return just the filename.
|
||||
head, tail = os.path.split(filename)
|
||||
return tail
|
||||
|
||||
def CANCEL_FRAME(date):
|
||||
result = {
|
||||
'date' : EPOCH(date)
|
||||
|
||||
Reference in New Issue
Block a user