所以,这是一个kluge。我正在与 luigi 和 sciluigi 合作。
isinstance
支票在 sciluigi 包中,我宁愿把它弄好,然后必须为这个小问题分支整个 sciluigi :)
简而言之,我必须继承包的一个类 (luigi.LocalTarget) - 以添加额外的功能。该功能效果很好,但是 sciluigi 包中有一个对象检查...
sciluigi.dependencies.DependencyHelpers._parse_outputitem()
...这会导致运行失败,因为某isinstance
行设置为仅检查“TargetInfo”对象。
我想做的只是告诉我的孩子类“撒谎”,isinstance
以便它作为一个TargetInfo
对象报告并通过:D
事先请求宽恕:D
def _parse_outputitem(self, val, targets):
'''
Recursively loop through lists of TargetInfos, or
callables returning TargetInfos, or lists of ...
(repeat recursively) ... and return all targets.
'''
if callable(val):
val = val()
if isinstance(val, TargetInfo):
targets.append(val.target)
elif isinstance(val, list):
for valitem in val:
targets = self._parse_outputitem(valitem, targets)
elif isinstance(val, dict):
for _, valitem in iteritems(val):
targets = self._parse_outputitem(valitem, targets)
else:
raise Exception('Input item is neither callable, TargetInfo, nor list: %s' % val)
return targets
错误信息:
2017-04-06 22:26:09,753 - PipeineTest1 - DEBUG - RunSubprocess:Traceback (most recent call last):
2017-04-06 22:26:09,754 - PipeineTest1 - DEBUG - RunSubprocess: File "/Library/Python/2.7/site-packages/luigi/worker.py", line 305, in check_complete
2017-04-06 22:26:09,754 - PipeineTest1 - DEBUG - RunSubprocess: is_complete = task.complete()
2017-04-06 22:26:09,754 - PipeineTest1 - DEBUG - RunSubprocess: File "/Library/Python/2.7/site-packages/luigi/task.py", line 482, in complete
2017-04-06 22:26:09,754 - PipeineTest1 - DEBUG - RunSubprocess: outputs = flatten(self.output())
2017-04-06 22:26:09,754 - PipeineTest1 - DEBUG - RunSubprocess: File "/Library/Python/2.7/site-packages/sciluigi/dependencies.py", line 99, in output
2017-04-06 22:26:09,754 - PipeineTest1 - DEBUG - RunSubprocess: return self._output_targets()
2017-04-06 22:26:09,755 - PipeineTest1 - DEBUG - RunSubprocess: File "/Library/Python/2.7/site-packages/sciluigi/dependencies.py", line 111, in _output_targets
2017-04-06 22:26:09,755 - PipeineTest1 - DEBUG - RunSubprocess: output_targets = self._parse_outputitem(attrval, output_targets)
2017-04-06 22:26:09,755 - PipeineTest1 - DEBUG - RunSubprocess: File "/Library/Python/2.7/site-packages/sciluigi/dependencies.py", line 132, in _parse_outputitem
2017-04-06 22:26:09,755 - PipeineTest1 - DEBUG - RunSubprocess: raise Exception('Input item is neither callable, TargetInfo, nor list: %s' % val)
2017-04-06 22:26:09,755 - PipeineTest1 - DEBUG - RunSubprocess:Exception: Input item is neither callable, TargetInfo, nor list: <Bioproximity.common.luigi_extensions.local_target.ToppasLocalTarget object at 0x110e48190>
...不幸的是,这是 Sciluigi 作为输出提供的 100% 的错误回溯。
sciluigi.dependencies.TargetInfo(object)
class TargetInfo(object):
'''
Class to be used for sending specification of which target, from which
task, to use, when stitching workflow tasks' outputs and inputs together.
'''
task = None
path = None
target = None
def __init__(self, task, path, format=None, is_tmp=False):
self.task = task
self.path = path
self.target = luigi.LocalTarget(path, format, is_tmp)
def open(self, *args, **kwargs):
'''
Forward open method, from luigi's target class
'''
return self.target.open(*args, **kwargs)
# ==============================================================================