{"action":"created","comment":{"url":"https://api.github.com/repos/nipy/nipype/pulls/comments/47992402","id":47992402,"diff_hunk":"@@ -18,142 +18,34 @@\n \n from collections import OrderedDict\n from copy import deepcopy\n-from glob import glob\n from collections import defaultdict\n import os\n import re\n import numpy as np\n-from nipype.utils.misc import package_check\n from functools import reduce\n \n-package_check('networkx', '1.3')\n-\n-import networkx as nx\n+from nipype.utils.misc import package_check\n+from nipype.external.six import string_types\n+from nipype.utils.filemanip import fname_presuffix\n+from nipype.utils.misc import create_function_from_source\n+from nipype.interfaces.base import (CommandLine, isdefined, Undefined,\n+                                    InterfaceResult)\n+from nipype.interfaces.utility import IdentityInterface\n+from nipype.utils.provenance import ProvStore, pm, nipype_ns, get_id\n \n-from ..external.six import string_types\n-from ..utils.filemanip import (fname_presuffix, FileNotFoundError,\n-                               filename_to_list, get_related_files)\n-from ..utils.misc import create_function_from_source, str2bool\n-from ..interfaces.base import (CommandLine, isdefined, Undefined,\n-                               InterfaceResult)\n-from ..interfaces.utility import IdentityInterface\n-from ..utils.provenance import ProvStore, pm, nipype_ns, get_id\n+from nipype import logging, config\n+from .utils import get_print_name\n \n-from .. import logging, config\n-logger = logging.getLogger('workflow')\n \n+package_check('networkx', '1.3')\n+import networkx as nx\n try:\n     dfs_preorder = nx.dfs_preorder\n+    logger.debug('detected networkx < 1.4 dev')","path":"nipype/pipeline/engine/graph.py","position":42,"original_position":42,"commit_id":"f260a88fecfec63b84ab3abaaeac7e37e2ca39b3","original_commit_id":"f260a88fecfec63b84ab3abaaeac7e37e2ca39b3","user":{"login":"chrisfilo","id":238759,"avatar_url":"https://avatars.githubusercontent.com/u/238759?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisfilo","html_url":"https://github.com/chrisfilo","followers_url":"https://api.github.com/users/chrisfilo/followers","following_url":"https://api.github.com/users/chrisfilo/following{/other_user}","gists_url":"https://api.github.com/users/chrisfilo/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisfilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisfilo/subscriptions","organizations_url":"https://api.github.com/users/chrisfilo/orgs","repos_url":"https://api.github.com/users/chrisfilo/repos","events_url":"https://api.github.com/users/chrisfilo/events{/privacy}","received_events_url":"https://api.github.com/users/chrisfilo/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/versioned/images/favicon.png) Issue found: [Using variable 'logger' before assignment](https://www.codacy.com/app/krzysztof-gorgolewski/nipy_nipype/file/1605601501/issues/source?bid=2767207&fileBranchId=3022732#l44)","created_at":"2015-12-18T03:53:44Z","updated_at":"2015-12-18T03:53:44Z","html_url":"https://github.com/nipy/nipype/pull/1299#discussion_r47992402","pull_request_url":"https://api.github.com/repos/nipy/nipype/pulls/1299","_links":{"self":{"href":"https://api.github.com/repos/nipy/nipype/pulls/comments/47992402"},"html":{"href":"https://github.com/nipy/nipype/pull/1299#discussion_r47992402"},"pull_request":{"href":"https://api.github.com/repos/nipy/nipype/pulls/1299"}}},"pull_request":{"url":"https://api.github.com/repos/nipy/nipype/pulls/1299","id":53688655,"html_url":"https://github.com/nipy/nipype/pull/1299","diff_url":"https://github.com/nipy/nipype/pull/1299.diff","patch_url":"https://github.com/nipy/nipype/pull/1299.patch","issue_url":"https://api.github.com/repos/nipy/nipype/issues/1299","number":1299,"state":"open","locked":false,"title":"[WIP,ENH] Conditional Nodes and Workflows","user":{"login":"oesteban","id":598470,"avatar_url":"https://avatars.githubusercontent.com/u/598470?v=3","gravatar_id":"","url":"https://api.github.com/users/oesteban","html_url":"https://github.com/oesteban","followers_url":"https://api.github.com/users/oesteban/followers","following_url":"https://api.github.com/users/oesteban/following{/other_user}","gists_url":"https://api.github.com/users/oesteban/gists{/gist_id}","starred_url":"https://api.github.com/users/oesteban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oesteban/subscriptions","organizations_url":"https://api.github.com/users/oesteban/orgs","repos_url":"https://api.github.com/users/oesteban/repos","events_url":"https://api.github.com/users/oesteban/events{/privacy}","received_events_url":"https://api.github.com/users/oesteban/received_events","type":"User","site_admin":false},"body":"This is a first take on conditional execution of nodes in workflows. Runtime decisions in nipype are old feature requests (i.e. #819 and #878 for nodes, and #1081 for workflows).\r\n\r\nThe new ```ConditionalNode``` adds an special input to the inner interface named ```donotrun``` that can be used to disable the node. It is the user's responsibility to maintain the consistency along the whole graph.\r\n\r\nThe new ```ConditionalWorkflow``` adds an special input node: when setting ```checknode.donotrun``` to ```True```, the workflow is disabled. These workflows automatically cast all its nodes to ```ConditionalNode```s and connected to the ```checknode.donotrun``` input.\r\n\r\nFinally, a new ```CachedWorkflow``` is derived from ```ConditionalWorkflow```, with the addition of a ```cache_map``` (list of tuples indicating the input name and the output to which it is mapped). If all the inputs of a ```cachenode``` (as listed in the first element of the ```cache_map``` list of tuples) are defined, the ```donotrun``` of the workflow is activated and all the nodes skipped. Additionally, the workflows outputs are mapped from the ```cachenode```. Otherwise, they are filled with the normal execution of the workflow.\r\n\r\nExample:\r\n\r\n```\r\nimport os\r\nfrom nipype.pipeline import engine as pe\r\nfrom nipype.interfaces import utility as niu\r\n\r\ndef _sum(a, b):\r\n    return a + b\r\n\r\ncwf = pe.CachedWorkflow(\r\n    'TestCachedWorkflow', cache_map=[('c', 'out1'), ('d', 'out2')])\r\ncwf.base_dir = os.getcwd()\r\n\r\ninputnode = pe.Node(niu.IdentityInterface(fields=['a', 'b']),\r\n                    name='inputnode')\r\nsumnode = pe.Node(niu.Function(\r\n    input_names=['a', 'b'], output_names=['sum'],\r\n    function=_sum), name='SumNode')\r\ncwf.connect([\r\n    (inputnode, sumnode, [('a', 'a'), ('b', 'b')]),\r\n    (sumnode, 'output', [('sum', 'out1'), ('sum', 'out2')])\r\n])\r\n\r\ncwf.inputs.inputnode.a = 2\r\ncwf.inputs.inputnode.b = 3\r\n# cwf.inputs.cachenode.c = 1\r\ncwf.inputs.cachenode.d = 7\r\n\r\ncwf.run()\r\n\r\n```\r\nThis will return ```outputnode.out1 = 5``` and ```outputnode.out2 = 5```\r\nIf the line ```# cwf.inputs.cachenode.c = 1``` is uncommented, then ```outputnode.out1 = 1``` and ```outputnode.out2 = 7``` since all the cache inputs are set and mapped.\r\n\r\nThis PR is labeled as WIP because there are some missing elements:\r\n  - [ ] Include this example in the documentation, improve documentation\r\n  - [ ] Analyze side-effects of skipping nodes, currently this is just a hard decision. Presumably, something should be cached when ```donotrun``` is ```True```.\r\n  - [ ] Convert sub-workflows of ConditionalWorkflow and CachedWorkflow in ConditionalWorkflows and connect the ```donotrun``` input.\r\n\r\nThis PR requires #1298.","created_at":"2015-12-15T11:04:19Z","updated_at":"2015-12-18T03:53:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"778fc9c5ce0ce7bc29026877fa6a2d6c2c9958f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nipy/nipype/pulls/1299/commits","review_comments_url":"https://api.github.com/repos/nipy/nipype/pulls/1299/comments","review_comment_url":"https://api.github.com/repos/nipy/nipype/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nipy/nipype/issues/1299/comments","statuses_url":"https://api.github.com/repos/nipy/nipype/statuses/f260a88fecfec63b84ab3abaaeac7e37e2ca39b3","head":{"label":"oesteban:enh/ControlNodes","ref":"enh/ControlNodes","sha":"f260a88fecfec63b84ab3abaaeac7e37e2ca39b3","user":{"login":"oesteban","id":598470,"avatar_url":"https://avatars.githubusercontent.com/u/598470?v=3","gravatar_id":"","url":"https://api.github.com/users/oesteban","html_url":"https://github.com/oesteban","followers_url":"https://api.github.com/users/oesteban/followers","following_url":"https://api.github.com/users/oesteban/following{/other_user}","gists_url":"https://api.github.com/users/oesteban/gists{/gist_id}","starred_url":"https://api.github.com/users/oesteban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oesteban/subscriptions","organizations_url":"https://api.github.com/users/oesteban/orgs","repos_url":"https://api.github.com/users/oesteban/repos","events_url":"https://api.github.com/users/oesteban/events{/privacy}","received_events_url":"https://api.github.com/users/oesteban/received_events","type":"User","site_admin":false},"repo":{"id":17021985,"name":"nipype","full_name":"oesteban/nipype","owner":{"login":"oesteban","id":598470,"avatar_url":"https://avatars.githubusercontent.com/u/598470?v=3","gravatar_id":"","url":"https://api.github.com/users/oesteban","html_url":"https://github.com/oesteban","followers_url":"https://api.github.com/users/oesteban/followers","following_url":"https://api.github.com/users/oesteban/following{/other_user}","gists_url":"https://api.github.com/users/oesteban/gists{/gist_id}","starred_url":"https://api.github.com/users/oesteban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oesteban/subscriptions","organizations_url":"https://api.github.com/users/oesteban/orgs","repos_url":"https://api.github.com/users/oesteban/repos","events_url":"https://api.github.com/users/oesteban/events{/privacy}","received_events_url":"https://api.github.com/users/oesteban/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oesteban/nipype","description":"Workflows and interfaces for neuroimaging packages","fork":true,"url":"https://api.github.com/repos/oesteban/nipype","forks_url":"https://api.github.com/repos/oesteban/nipype/forks","keys_url":"https://api.github.com/repos/oesteban/nipype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oesteban/nipype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oesteban/nipype/teams","hooks_url":"https://api.github.com/repos/oesteban/nipype/hooks","issue_events_url":"https://api.github.com/repos/oesteban/nipype/issues/events{/number}","events_url":"https://api.github.com/repos/oesteban/nipype/events","assignees_url":"https://api.github.com/repos/oesteban/nipype/assignees{/user}","branches_url":"https://api.github.com/repos/oesteban/nipype/branches{/branch}","tags_url":"https://api.github.com/repos/oesteban/nipype/tags","blobs_url":"https://api.github.com/repos/oesteban/nipype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oesteban/nipype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oesteban/nipype/git/refs{/sha}","trees_url":"https://api.github.com/repos/oesteban/nipype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oesteban/nipype/statuses/{sha}","languages_url":"https://api.github.com/repos/oesteban/nipype/languages","stargazers_url":"https://api.github.com/repos/oesteban/nipype/stargazers","contributors_url":"https://api.github.com/repos/oesteban/nipype/contributors","subscribers_url":"https://api.github.com/repos/oesteban/nipype/subscribers","subscription_url":"https://api.github.com/repos/oesteban/nipype/subscription","commits_url":"https://api.github.com/repos/oesteban/nipype/commits{/sha}","git_commits_url":"https://api.github.com/repos/oesteban/nipype/git/commits{/sha}","comments_url":"https://api.github.com/repos/oesteban/nipype/comments{/number}","issue_comment_url":"https://api.github.com/repos/oesteban/nipype/issues/comments{/number}","contents_url":"https://api.github.com/repos/oesteban/nipype/contents/{+path}","compare_url":"https://api.github.com/repos/oesteban/nipype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oesteban/nipype/merges","archive_url":"https://api.github.com/repos/oesteban/nipype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oesteban/nipype/downloads","issues_url":"https://api.github.com/repos/oesteban/nipype/issues{/number}","pulls_url":"https://api.github.com/repos/oesteban/nipype/pulls{/number}","milestones_url":"https://api.github.com/repos/oesteban/nipype/milestones{/number}","notifications_url":"https://api.github.com/repos/oesteban/nipype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oesteban/nipype/labels{/name}","releases_url":"https://api.github.com/repos/oesteban/nipype/releases{/id}","created_at":"2014-02-20T13:58:05Z","updated_at":"2015-04-26T18:20:51Z","pushed_at":"2015-12-18T01:55:49Z","git_url":"git://github.com/oesteban/nipype.git","ssh_url":"git@github.com:oesteban/nipype.git","clone_url":"https://github.com/oesteban/nipype.git","svn_url":"https://github.com/oesteban/nipype","homepage":"http://www.mit.edu/~satra/nipype-nightly/","size":24465,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nipy:master","ref":"master","sha":"61721196412223a1d83914b495622208707df12d","user":{"login":"nipy","id":233707,"avatar_url":"https://avatars.githubusercontent.com/u/233707?v=3","gravatar_id":"","url":"https://api.github.com/users/nipy","html_url":"https://github.com/nipy","followers_url":"https://api.github.com/users/nipy/followers","following_url":"https://api.github.com/users/nipy/following{/other_user}","gists_url":"https://api.github.com/users/nipy/gists{/gist_id}","starred_url":"https://api.github.com/users/nipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nipy/subscriptions","organizations_url":"https://api.github.com/users/nipy/orgs","repos_url":"https://api.github.com/users/nipy/repos","events_url":"https://api.github.com/users/nipy/events{/privacy}","received_events_url":"https://api.github.com/users/nipy/received_events","type":"Organization","site_admin":false},"repo":{"id":791477,"name":"nipype","full_name":"nipy/nipype","owner":{"login":"nipy","id":233707,"avatar_url":"https://avatars.githubusercontent.com/u/233707?v=3","gravatar_id":"","url":"https://api.github.com/users/nipy","html_url":"https://github.com/nipy","followers_url":"https://api.github.com/users/nipy/followers","following_url":"https://api.github.com/users/nipy/following{/other_user}","gists_url":"https://api.github.com/users/nipy/gists{/gist_id}","starred_url":"https://api.github.com/users/nipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nipy/subscriptions","organizations_url":"https://api.github.com/users/nipy/orgs","repos_url":"https://api.github.com/users/nipy/repos","events_url":"https://api.github.com/users/nipy/events{/privacy}","received_events_url":"https://api.github.com/users/nipy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nipy/nipype","description":"Workflows and interfaces for neuroimaging packages","fork":false,"url":"https://api.github.com/repos/nipy/nipype","forks_url":"https://api.github.com/repos/nipy/nipype/forks","keys_url":"https://api.github.com/repos/nipy/nipype/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nipy/nipype/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nipy/nipype/teams","hooks_url":"https://api.github.com/repos/nipy/nipype/hooks","issue_events_url":"https://api.github.com/repos/nipy/nipype/issues/events{/number}","events_url":"https://api.github.com/repos/nipy/nipype/events","assignees_url":"https://api.github.com/repos/nipy/nipype/assignees{/user}","branches_url":"https://api.github.com/repos/nipy/nipype/branches{/branch}","tags_url":"https://api.github.com/repos/nipy/nipype/tags","blobs_url":"https://api.github.com/repos/nipy/nipype/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nipy/nipype/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nipy/nipype/git/refs{/sha}","trees_url":"https://api.github.com/repos/nipy/nipype/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nipy/nipype/statuses/{sha}","languages_url":"https://api.github.com/repos/nipy/nipype/languages","stargazers_url":"https://api.github.com/repos/nipy/nipype/stargazers","contributors_url":"https://api.github.com/repos/nipy/nipype/contributors","subscribers_url":"https://api.github.com/repos/nipy/nipype/subscribers","subscription_url":"https://api.github.com/repos/nipy/nipype/subscription","commits_url":"https://api.github.com/repos/nipy/nipype/commits{/sha}","git_commits_url":"https://api.github.com/repos/nipy/nipype/git/commits{/sha}","comments_url":"https://api.github.com/repos/nipy/nipype/comments{/number}","issue_comment_url":"https://api.github.com/repos/nipy/nipype/issues/comments{/number}","contents_url":"https://api.github.com/repos/nipy/nipype/contents/{+path}","compare_url":"https://api.github.com/repos/nipy/nipype/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nipy/nipype/merges","archive_url":"https://api.github.com/repos/nipy/nipype/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nipy/nipype/downloads","issues_url":"https://api.github.com/repos/nipy/nipype/issues{/number}","pulls_url":"https://api.github.com/repos/nipy/nipype/pulls{/number}","milestones_url":"https://api.github.com/repos/nipy/nipype/milestones{/number}","notifications_url":"https://api.github.com/repos/nipy/nipype/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nipy/nipype/labels{/name}","releases_url":"https://api.github.com/repos/nipy/nipype/releases{/id}","created_at":"2010-07-22T17:06:49Z","updated_at":"2015-12-17T20:24:00Z","pushed_at":"2015-12-18T01:55:50Z","git_url":"git://github.com/nipy/nipype.git","ssh_url":"git@github.com:nipy/nipype.git","clone_url":"https://github.com/nipy/nipype.git","svn_url":"https://github.com/nipy/nipype","homepage":"http://www.mit.edu/~satra/nipype-nightly/","size":64801,"stargazers_count":156,"watchers_count":156,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":189,"mirror_url":null,"open_issues_count":203,"forks":189,"open_issues":203,"watchers":156,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nipy/nipype/pulls/1299"},"html":{"href":"https://github.com/nipy/nipype/pull/1299"},"issue":{"href":"https://api.github.com/repos/nipy/nipype/issues/1299"},"comments":{"href":"https://api.github.com/repos/nipy/nipype/issues/1299/comments"},"review_comments":{"href":"https://api.github.com/repos/nipy/nipype/pulls/1299/comments"},"review_comment":{"href":"https://api.github.com/repos/nipy/nipype/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nipy/nipype/pulls/1299/commits"},"statuses":{"href":"https://api.github.com/repos/nipy/nipype/statuses/f260a88fecfec63b84ab3abaaeac7e37e2ca39b3"}}}}