{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/177510179","pull_request_review_id":107393888,"id":177510179,"diff_hunk":"@@ -72,125 +82,139 @@ def run(self, requests, info, openmrs_config, person_uuid, attributes):\n             if person_attribute_type in existing_person_attributes:\n                 attribute_uuid, existing_value = existing_person_attributes[person_attribute_type]\n                 if value != existing_value:\n-                    rollback_task = Task(\n-                        update_person_attribute,\n-                        requests, person_uuid, attribute_uuid, person_attribute_type, existing_value,\n-                    )\n-                    self._subtasks.append(\n+                    subtasks.append(\n                         WorkflowTask(\n-                            rollback_task,\n-                            None,  # pass_result_as=None because both tasks are updates; rollback just resets\n-                            update_person_attribute,\n-                            requests, person_uuid, attribute_uuid, person_attribute_type, value,\n+                            func=update_person_attribute,\n+                            func_args=(requests, person_uuid, attribute_uuid, person_attribute_type, value),\n+                            rollback_func=update_person_attribute,\n+                            rollback_args=(requests, person_uuid, attribute_uuid, person_attribute_type,\n+                                           existing_value),\n                         )\n                     )\n             else:\n-                self._subtasks.append(\n+                subtasks.append(\n                     WorkflowTask(\n-                        delete_person_attribute_task(requests, person_uuid),\n-                        'attribute_uuid',  # create_person_attribute returns attribute_uuid: Pass to rollback task.\n-\n-                        # Note: We can't use the `@workflow_task` decorator on create_person_attribute() because we\n-                        # need to call delete_person_attribute_task() with values for `requests` and `person_uuid`\n-                        # for it to return a Task instance for WorkflowTask.rollback_task.\n-                        create_person_attribute,\n-                        requests, person_uuid, person_attribute_type, value,\n+                        func=create_person_attribute,\n+                        func_args=(requests, person_uuid, person_attribute_type, value),\n+                        rollback_func=delete_person_attribute,\n+                        rollback_args=(requests, person_uuid),\n+                        pass_result=True\n                     )\n                 )\n+        return subtasks\n \n \n class CreateVisitsTask(WorkflowTask):\n \n     def __init__(self, *args, **kwargs):\n-        super(CreateVisitsTask, self).__init__(None, None, None, *args, **kwargs)\n+        super(CreateVisitsTask, self).__init__(func=None, func_args=args, func_kwargs=kwargs)\n \n-    def run(self, requests, info, form_json, form_question_values, openmrs_config, person_uuid):\n+    def run(self):\n         \"\"\"\n         This task does not make any changes itself. It uses subtasks for creating visits, encounters and\n         observations\n         \"\"\"\n+        requests, info, form_json, form_question_values, openmrs_config, person_uuid = unpack_args(\n+            ('requests', 'info', 'form_json', 'form_question_values', 'openmrs_config', 'person_uuid'),\n+            *self.func_args, **self.func_kwargs,\n+        )","path":"corehq/motech/openmrs/handler.py","position":null,"original_position":139,"commit_id":"40f2394565567e48cb09ae05322b04c0cdaaed11","original_commit_id":"40f2394565567e48cb09ae05322b04c0cdaaed11","user":{"login":"kaapstorm","id":708421,"avatar_url":"https://avatars3.githubusercontent.com/u/708421?v=4","gravatar_id":"","url":"https://api.github.com/users/kaapstorm","html_url":"https://github.com/kaapstorm","followers_url":"https://api.github.com/users/kaapstorm/followers","following_url":"https://api.github.com/users/kaapstorm/following{/other_user}","gists_url":"https://api.github.com/users/kaapstorm/gists{/gist_id}","starred_url":"https://api.github.com/users/kaapstorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaapstorm/subscriptions","organizations_url":"https://api.github.com/users/kaapstorm/orgs","repos_url":"https://api.github.com/users/kaapstorm/repos","events_url":"https://api.github.com/users/kaapstorm/events{/privacy}","received_events_url":"https://api.github.com/users/kaapstorm/received_events","type":"User","site_admin":false},"body":"I am not loving this construct. It reminds me of bad Perl. Any ideas @snopoke ? The alternative is not to override the same method that is called by `execute_workflow()` but rather have something like ...\r\n```python\r\n    def __run(self, requests, info, form_json, form_question_values, openmrs_config, person_uuid):\r\n        # ...\r\n```\r\n... that `run()` calls if `self.func` is None.\r\n","created_at":"2018-03-27T17:37:35Z","updated_at":"2018-03-27T17:37:35Z","html_url":"https://github.com/dimagi/commcare-hq/pull/19758#discussion_r177510179","pull_request_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/177510179"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/19758#discussion_r177510179"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758","id":174441189,"html_url":"https://github.com/dimagi/commcare-hq/pull/19758","diff_url":"https://github.com/dimagi/commcare-hq/pull/19758.diff","patch_url":"https://github.com/dimagi/commcare-hq/pull/19758.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/19758","number":19758,"state":"open","locked":false,"title":"Implement rollback for OpenMRS","user":{"login":"kaapstorm","id":708421,"avatar_url":"https://avatars3.githubusercontent.com/u/708421?v=4","gravatar_id":"","url":"https://api.github.com/users/kaapstorm","html_url":"https://github.com/kaapstorm","followers_url":"https://api.github.com/users/kaapstorm/followers","following_url":"https://api.github.com/users/kaapstorm/following{/other_user}","gists_url":"https://api.github.com/users/kaapstorm/gists{/gist_id}","starred_url":"https://api.github.com/users/kaapstorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaapstorm/subscriptions","organizations_url":"https://api.github.com/users/kaapstorm/orgs","repos_url":"https://api.github.com/users/kaapstorm/repos","events_url":"https://api.github.com/users/kaapstorm/events{/privacy}","received_events_url":"https://api.github.com/users/kaapstorm/received_events","type":"User","site_admin":false},"body":"Builds on PRs #19756 and #19757. \r\n\r\nProbably easiest to take the last 5 commits :blowfish: ... and ignoring whitespace might make it more readable.\r\n\r\nThis implements the work done in the previous 2 PRs. Please hold off on merge. I'd like to test from Staging.\r\n\r\n@nickpell I understand that you're probably going to be a bit thin on context wrt OpenMRS API calls, but hopefully this isn't too bad -- it doesn't add any new functionality. It just wraps existing calls as Tasks, and adds a few rollback functions for the calls that need them.\r\n\r\n@dannyroberts buddy @nickpell cc @snopoke \r\n","created_at":"2018-03-12T17:30:58Z","updated_at":"2018-03-27T17:37:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a3a8753520407904f7faf2cf21f011b5bed78f4","assignee":null,"assignees":[],"requested_reviewers":[{"login":"dannyroberts","id":137212,"avatar_url":"https://avatars1.githubusercontent.com/u/137212?v=4","gravatar_id":"","url":"https://api.github.com/users/dannyroberts","html_url":"https://github.com/dannyroberts","followers_url":"https://api.github.com/users/dannyroberts/followers","following_url":"https://api.github.com/users/dannyroberts/following{/other_user}","gists_url":"https://api.github.com/users/dannyroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/dannyroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dannyroberts/subscriptions","organizations_url":"https://api.github.com/users/dannyroberts/orgs","repos_url":"https://api.github.com/users/dannyroberts/repos","events_url":"https://api.github.com/users/dannyroberts/events{/privacy}","received_events_url":"https://api.github.com/users/dannyroberts/received_events","type":"User","site_admin":false},{"login":"nickpell","id":1757035,"avatar_url":"https://avatars2.githubusercontent.com/u/1757035?v=4","gravatar_id":"","url":"https://api.github.com/users/nickpell","html_url":"https://github.com/nickpell","followers_url":"https://api.github.com/users/nickpell/followers","following_url":"https://api.github.com/users/nickpell/following{/other_user}","gists_url":"https://api.github.com/users/nickpell/gists{/gist_id}","starred_url":"https://api.github.com/users/nickpell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickpell/subscriptions","organizations_url":"https://api.github.com/users/nickpell/orgs","repos_url":"https://api.github.com/users/nickpell/repos","events_url":"https://api.github.com/users/nickpell/events{/privacy}","received_events_url":"https://api.github.com/users/nickpell/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":724787015,"url":"https://api.github.com/repos/dimagi/commcare-hq/labels/product/invisible","name":"product/invisible","color":"cfd2d6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/19758/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/40f2394565567e48cb09ae05322b04c0cdaaed11","head":{"label":"dimagi:nh/omrs/rollback","ref":"nh/omrs/rollback","sha":"40f2394565567e48cb09ae05322b04c0cdaaed11","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-03-27T17:27:00Z","pushed_at":"2018-03-27T17:26:46Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":421956,"stargazers_count":88,"watchers_count":88,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":105,"mirror_url":null,"archived":false,"open_issues_count":72,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":105,"open_issues":72,"watchers":88,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"d2dd23bec44e638542ebcfe258ca8da4bdbed8d5","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-03-27T17:27:00Z","pushed_at":"2018-03-27T17:26:46Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":421956,"stargazers_count":88,"watchers_count":88,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":105,"mirror_url":null,"archived":false,"open_issues_count":72,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":105,"open_issues":72,"watchers":88,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/19758"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/19758"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/19758/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/19758/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-hq/statuses/40f2394565567e48cb09ae05322b04c0cdaaed11"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kaapstorm"}}