所以,這是一個kluge。我正在與luigi和sciluigi合作。Lie isinstance
的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(對象)
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)
# ==============================================================================
難道你不能只用你自己的實現monkeypatch'_parse_outputitem'來省略那個步驟嗎? – karlson
您沒有顯示任何實際存在問題的代碼。請儘量創建一個[MCVE](http://stackoverflow.com/help/mcve)並提供實際的錯誤細節,回溯等。 –
@Karlson - 我可以monkeypatch,但是我們有一個自定義的sciluigi實現 - 它我試圖避免。 – RightmireM