python - Lie to isinstance -
so, kluge. i'm working luigi , sciluigi.
the isinstance check in sciluigi package, , i'd rather kluge have branch entire sciluigi small issue :)
simply put, had subclass 1 of package's classes (luigi.localtarget)- add additional functionality. functionality works great, there's object check in sciluigi package...
sciluigi.dependencies.dependencyhelpers._parse_outputitem()
...which causes run fail because isinstance line set check 'targetinfo' objects.
what i'd tell child class 'lie' isinstance reports targetinfo object , passes :d
forgiveness asked in advance :d
def _parse_outputitem(self, val, targets): ''' recursively loop through lists of targetinfos, or callables returning targetinfos, or lists of ... (repeat recursively) ... , return targets. ''' if callable(val): val = val() if isinstance(val, targetinfo): targets.append(val.target) elif isinstance(val, list): valitem in val: targets = self._parse_outputitem(valitem, targets) elif isinstance(val, dict): _, valitem in iteritems(val): targets = self._parse_outputitem(valitem, targets) else: raise exception('input item neither callable, targetinfo, nor list: %s' % val) return targets error message:
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 neither callable, targetinfo, nor list: %s' % val) 2017-04-06 22:26:09,755 - pipeinetest1 - debug - runsubprocess:exception: input item neither callable, targetinfo, nor list: <bioproximity.common.luigi_extensions.local_target.toppaslocaltarget object @ 0x110e48190> ...unfortunately, thats 100% of error traceback sciluigi provides output.
sciluigi.dependencies.targetinfo(object)
class targetinfo(object): ''' class used sending specification of target, task, use, when stitching workflow tasks' outputs , 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, luigi's target class ''' return self.target.open(*args, **kwargs) # ==============================================================================
it looks need subclass targetinfo object pass isinstance check. can have this:
class foo(<whatever other base classes have>, targetinfo): ... if have targetinfo root descendant shouldn't interfere class's functionality because other base classes override conflicting methods.
Comments
Post a Comment