{"action":"created","issue":{"url":"https://api.github.com/repos/pharmbio/sciluigi/issues/36","repository_url":"https://api.github.com/repos/pharmbio/sciluigi","labels_url":"https://api.github.com/repos/pharmbio/sciluigi/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/pharmbio/sciluigi/issues/36/comments","events_url":"https://api.github.com/repos/pharmbio/sciluigi/issues/36/events","html_url":"https://github.com/pharmbio/sciluigi/issues/36","id":219932020,"number":36,"title":"Subclassing LocalTarget and TargetInfo causing sciluigi run to fail","user":{"login":"BioComSoftware","id":6683102,"avatar_url":"https://avatars3.githubusercontent.com/u/6683102?v=3","gravatar_id":"","url":"https://api.github.com/users/BioComSoftware","html_url":"https://github.com/BioComSoftware","followers_url":"https://api.github.com/users/BioComSoftware/followers","following_url":"https://api.github.com/users/BioComSoftware/following{/other_user}","gists_url":"https://api.github.com/users/BioComSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/BioComSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BioComSoftware/subscriptions","organizations_url":"https://api.github.com/users/BioComSoftware/orgs","repos_url":"https://api.github.com/users/BioComSoftware/repos","events_url":"https://api.github.com/users/BioComSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/BioComSoftware/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-06T15:11:28Z","updated_at":"2017-04-06T20:47:35Z","closed_at":null,"body":"Hi,\r\n\r\nA quick suggestion...\r\n\r\nThe method…\r\n\r\n**sciluigi.dependencies.DependencyHelpers._parse_outputitem()**\r\n(see below)\r\n\r\n…is used to verify an 'out target' is either a 'TargetIfo' object a 'list' or a 'dict'. \r\n\r\nBut, since the target **exists()** method is used by (sci)luigi to decide if it will run the command (again) – AND **exists()** ONLY checks if the output directory 'exists' (not that it has useful data) I've found I often need to subclass the Target or LocalTarget class. \r\n\r\nFor example I subclassed the LUIGI LocalTarget class with 'class ToppasLocalTarget(LocalTarget)' which decides whether the out_target subdirectory structure matches the expected output of the TOPPAS file and – if it does not – returns False for exists().\r\n\r\nPoint being, the **_parse_outputitem()** does not recognize my subclass, and errors out the run with: \r\n\r\n```\r\nraise Exception('Input item is neither callable, TargetInfo, nor list: %s' % val)\r\nException: Input item is neither callable, TargetInfo, nor list: <Bioproximity.common.luigi_extensions.local_target.ToppasLocalTarget object at 0x10d9d1190>\r\n\r\n```\r\nIt might be useful to have it instead check the root parent class, instead of the class itself – otherwise my child class fails the sciluigi run because it doesn't recognize it as a valid target :)\r\n\r\nThanks :)\r\n\r\n```\r\ndef _parse_outputitem(self, val, targets):\r\n        '''\r\n        Recursively loop through lists of TargetInfos, or\r\n        callables returning TargetInfos, or lists of ...\r\n        (repeat recursively) ... and return all targets.\r\n        '''\r\n        if callable(val):\r\n            val = val()\r\n        if isinstance(val, TargetInfo):\r\n            targets.append(val.target)\r\n        elif isinstance(val, list):\r\n            for valitem in val:\r\n                targets = self._parse_outputitem(valitem, targets)\r\n        elif isinstance(val, dict):\r\n            for _, valitem in iteritems(val):\r\n                targets = self._parse_outputitem(valitem, targets)\r\n        else:\r\n            raise Exception('Input item is neither callable, TargetInfo, nor list: %s' % val)\r\n        return targets\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pharmbio/sciluigi/issues/comments/292314185","html_url":"https://github.com/pharmbio/sciluigi/issues/36#issuecomment-292314185","issue_url":"https://api.github.com/repos/pharmbio/sciluigi/issues/36","id":292314185,"user":{"login":"BioComSoftware","id":6683102,"avatar_url":"https://avatars3.githubusercontent.com/u/6683102?v=3","gravatar_id":"","url":"https://api.github.com/users/BioComSoftware","html_url":"https://github.com/BioComSoftware","followers_url":"https://api.github.com/users/BioComSoftware/followers","following_url":"https://api.github.com/users/BioComSoftware/following{/other_user}","gists_url":"https://api.github.com/users/BioComSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/BioComSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BioComSoftware/subscriptions","organizations_url":"https://api.github.com/users/BioComSoftware/orgs","repos_url":"https://api.github.com/users/BioComSoftware/repos","events_url":"https://api.github.com/users/BioComSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/BioComSoftware/received_events","type":"User","site_admin":false},"created_at":"2017-04-06T20:47:35Z","updated_at":"2017-04-06T20:47:35Z","body":"Ah. I just realized that TargetInfo is not a subclass of the luigi.Target classes. I think my answer is to subclass targetinfo and not luigi.LocalTarget"}}
{"actor":{"display_login":"BioComSoftware"}}