{"action":"created","comment":{"url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/comments/29848493","id":29848493,"diff_hunk":"@@ -789,6 +794,99 @@ def set_states(self, tasks, state, error=None):\n         for task in tasks:\n             self.set_task_state(task, state, error=error)\n \n+    @inlineCallbacks\n+    def set_task_progress(self, task, progress):\n+        \"\"\"\n+        Sets the progress of the given task\n+\n+        :param dict task:\n+            The dictionary containing the task we're changing the progress\n+            for.\n+\n+        :param float progress:\n+            The progress to set on ``task``\n+        \"\"\"\n+        if not isinstance(task, dict):\n+            raise TypeError(\n+                \"Expected a dictionary for `task`, cannot set progress\")\n+\n+        if \"id\" not in task or not isinstance(task[\"id\"], INTEGER_TYPES):\n+            raise TypeError(\n+                \"Expected to find 'id' in `task` or for `task['id']` to \"\n+                \"be an integer.\")\n+\n+        if progress < 0.0 or progress > 1.0:\n+            raise ValueError(\"`progress` needs to be between 0.0 and 1.0\")\n+\n+        url = \"%s/jobs/%s/tasks/%s\" % (\n+            config[\"master_api\"], self.assignment[\"job\"][\"id\"], task[\"id\"])\n+        data = {\"progress\": progress}\n+\n+        updated = False\n+        num_retry_errors = 0\n+        while not updated:\n+            try:\n+                response = yield post_direct(url, data=data)\n+                response_data = yield treq.json_content(response)\n+                if response.code == OK:\n+                    logger.info(\"Set progress of task %s to %s on master\",\n+                                task [\"id\"], progress)\n+                    updated = True\n+                    returnValue(None)\n+\n+                elif response.code >= INTERNAL_SERVER_ERROR:\n+                    delay = http_retry_delay()\n+                    logger.warning(\n+                        \"Could not post progress update for task %s to the \"\n+                        \"master server, internal server error: %s.  Retrying \"\n+                        \"in %s seconds.\", task[\"id\"], response_data, delay)\n+\n+                    deferred = Deferred()\n+                    reactor.callLater(delay, deferred.callback, None)\n+                    yield deferred\n+\n+                elif response.code == NOT_FOUND:\n+                    message = (\"Got 404 NOT FOUND error on updating progress \"\n+                               \"for task %s\" % task[\"id\"])\n+                    logger.error(message)\n+                    raise Exception(message)\n+\n+                elif response.code >= BAD_REQUEST:\n+                    message = (\n+                        \"Failed to post progress update for task %s to the \"\n+                        \"master, bad request: %s. Server.  This request will \"\n+                        \"not be retried.\" % (task[\"id\"], response_data))\n+                    logger.error(message)\n+                    raise Exception(message)\n+\n+                else:\n+                    message = (\n+                        \"Unhandled error when posting progress update for task \"\n+                        \"%s to the master: %s (code: %s).  This request will \"\n+                        \"not be retried.\" % (response_data, response.code))\n+                    logger.error(message)","path":"pyfarm/jobtypes/core/jobtype.py","position":103,"original_position":102,"commit_id":"00d59eeaf558e64efd438c31a9a31c5efb943add","original_commit_id":"32726d4943d0e859fb105aae8532bc9a316c4ef2","user":{"login":"guidow","id":6033185,"avatar_url":"https://avatars.githubusercontent.com/u/6033185?v=3","gravatar_id":"","url":"https://api.github.com/users/guidow","html_url":"https://github.com/guidow","followers_url":"https://api.github.com/users/guidow/followers","following_url":"https://api.github.com/users/guidow/following{/other_user}","gists_url":"https://api.github.com/users/guidow/gists{/gist_id}","starred_url":"https://api.github.com/users/guidow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidow/subscriptions","organizations_url":"https://api.github.com/users/guidow/orgs","repos_url":"https://api.github.com/users/guidow/repos","events_url":"https://api.github.com/users/guidow/events{/privacy}","received_events_url":"https://api.github.com/users/guidow/received_events","type":"User","site_admin":false},"body":"Yes, but I am using message twice, so I'm constructing it once beforehand.","created_at":"2015-05-07T12:54:55Z","updated_at":"2015-05-07T12:54:55Z","html_url":"https://github.com/pyfarm/pyfarm-agent/pull/272#discussion_r29848493","pull_request_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272","_links":{"self":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/comments/29848493"},"html":{"href":"https://github.com/pyfarm/pyfarm-agent/pull/272#discussion_r29848493"},"pull_request":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272"}}},"pull_request":{"url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272","id":33889027,"html_url":"https://github.com/pyfarm/pyfarm-agent/pull/272","diff_url":"https://github.com/pyfarm/pyfarm-agent/pull/272.diff","patch_url":"https://github.com/pyfarm/pyfarm-agent/pull/272.patch","issue_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues/272","number":272,"state":"open","locked":false,"title":"Allow jobtype implementors to set task progress","user":{"login":"guidow","id":6033185,"avatar_url":"https://avatars.githubusercontent.com/u/6033185?v=3","gravatar_id":"","url":"https://api.github.com/users/guidow","html_url":"https://github.com/guidow","followers_url":"https://api.github.com/users/guidow/followers","following_url":"https://api.github.com/users/guidow/following{/other_user}","gists_url":"https://api.github.com/users/guidow/gists{/gist_id}","starred_url":"https://api.github.com/users/guidow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidow/subscriptions","organizations_url":"https://api.github.com/users/guidow/orgs","repos_url":"https://api.github.com/users/guidow/repos","events_url":"https://api.github.com/users/guidow/events{/privacy}","received_events_url":"https://api.github.com/users/guidow/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-22T18:51:22Z","updated_at":"2015-05-07T12:54:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee8f4b9f80411c8c00dbc13f78edfaca4ba754ad","assignee":{"login":"guidow","id":6033185,"avatar_url":"https://avatars.githubusercontent.com/u/6033185?v=3","gravatar_id":"","url":"https://api.github.com/users/guidow","html_url":"https://github.com/guidow","followers_url":"https://api.github.com/users/guidow/followers","following_url":"https://api.github.com/users/guidow/following{/other_user}","gists_url":"https://api.github.com/users/guidow/gists{/gist_id}","starred_url":"https://api.github.com/users/guidow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidow/subscriptions","organizations_url":"https://api.github.com/users/guidow/orgs","repos_url":"https://api.github.com/users/guidow/repos","events_url":"https://api.github.com/users/guidow/events{/privacy}","received_events_url":"https://api.github.com/users/guidow/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/pyfarm/pyfarm-agent/milestones/6","html_url":"https://github.com/pyfarm/pyfarm-agent/milestones/0.8.4","labels_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/milestones/6/labels","id":1019764,"number":6,"title":"0.8.4","description":"","creator":{"login":"opalmer","id":255117,"avatar_url":"https://avatars.githubusercontent.com/u/255117?v=3","gravatar_id":"","url":"https://api.github.com/users/opalmer","html_url":"https://github.com/opalmer","followers_url":"https://api.github.com/users/opalmer/followers","following_url":"https://api.github.com/users/opalmer/following{/other_user}","gists_url":"https://api.github.com/users/opalmer/gists{/gist_id}","starred_url":"https://api.github.com/users/opalmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opalmer/subscriptions","organizations_url":"https://api.github.com/users/opalmer/orgs","repos_url":"https://api.github.com/users/opalmer/repos","events_url":"https://api.github.com/users/opalmer/events{/privacy}","received_events_url":"https://api.github.com/users/opalmer/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":31,"state":"open","created_at":"2015-03-13T03:27:23Z","updated_at":"2015-05-07T02:53:21Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272/commits","review_comments_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272/comments","review_comment_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues/272/comments","statuses_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/statuses/00d59eeaf558e64efd438c31a9a31c5efb943add","head":{"label":"guidow:set_task_progress","ref":"set_task_progress","sha":"00d59eeaf558e64efd438c31a9a31c5efb943add","user":{"login":"guidow","id":6033185,"avatar_url":"https://avatars.githubusercontent.com/u/6033185?v=3","gravatar_id":"","url":"https://api.github.com/users/guidow","html_url":"https://github.com/guidow","followers_url":"https://api.github.com/users/guidow/followers","following_url":"https://api.github.com/users/guidow/following{/other_user}","gists_url":"https://api.github.com/users/guidow/gists{/gist_id}","starred_url":"https://api.github.com/users/guidow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidow/subscriptions","organizations_url":"https://api.github.com/users/guidow/orgs","repos_url":"https://api.github.com/users/guidow/repos","events_url":"https://api.github.com/users/guidow/events{/privacy}","received_events_url":"https://api.github.com/users/guidow/received_events","type":"User","site_admin":false},"repo":{"id":14711845,"name":"pyfarm-agent","full_name":"guidow/pyfarm-agent","owner":{"login":"guidow","id":6033185,"avatar_url":"https://avatars.githubusercontent.com/u/6033185?v=3","gravatar_id":"","url":"https://api.github.com/users/guidow","html_url":"https://github.com/guidow","followers_url":"https://api.github.com/users/guidow/followers","following_url":"https://api.github.com/users/guidow/following{/other_user}","gists_url":"https://api.github.com/users/guidow/gists{/gist_id}","starred_url":"https://api.github.com/users/guidow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidow/subscriptions","organizations_url":"https://api.github.com/users/guidow/orgs","repos_url":"https://api.github.com/users/guidow/repos","events_url":"https://api.github.com/users/guidow/events{/privacy}","received_events_url":"https://api.github.com/users/guidow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/guidow/pyfarm-agent","description":"Core module containing code to run PyFarm's agent.","fork":true,"url":"https://api.github.com/repos/guidow/pyfarm-agent","forks_url":"https://api.github.com/repos/guidow/pyfarm-agent/forks","keys_url":"https://api.github.com/repos/guidow/pyfarm-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guidow/pyfarm-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guidow/pyfarm-agent/teams","hooks_url":"https://api.github.com/repos/guidow/pyfarm-agent/hooks","issue_events_url":"https://api.github.com/repos/guidow/pyfarm-agent/issues/events{/number}","events_url":"https://api.github.com/repos/guidow/pyfarm-agent/events","assignees_url":"https://api.github.com/repos/guidow/pyfarm-agent/assignees{/user}","branches_url":"https://api.github.com/repos/guidow/pyfarm-agent/branches{/branch}","tags_url":"https://api.github.com/repos/guidow/pyfarm-agent/tags","blobs_url":"https://api.github.com/repos/guidow/pyfarm-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guidow/pyfarm-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guidow/pyfarm-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/guidow/pyfarm-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guidow/pyfarm-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/guidow/pyfarm-agent/languages","stargazers_url":"https://api.github.com/repos/guidow/pyfarm-agent/stargazers","contributors_url":"https://api.github.com/repos/guidow/pyfarm-agent/contributors","subscribers_url":"https://api.github.com/repos/guidow/pyfarm-agent/subscribers","subscription_url":"https://api.github.com/repos/guidow/pyfarm-agent/subscription","commits_url":"https://api.github.com/repos/guidow/pyfarm-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/guidow/pyfarm-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/guidow/pyfarm-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/guidow/pyfarm-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/guidow/pyfarm-agent/contents/{+path}","compare_url":"https://api.github.com/repos/guidow/pyfarm-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guidow/pyfarm-agent/merges","archive_url":"https://api.github.com/repos/guidow/pyfarm-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guidow/pyfarm-agent/downloads","issues_url":"https://api.github.com/repos/guidow/pyfarm-agent/issues{/number}","pulls_url":"https://api.github.com/repos/guidow/pyfarm-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/guidow/pyfarm-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/guidow/pyfarm-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guidow/pyfarm-agent/labels{/name}","releases_url":"https://api.github.com/repos/guidow/pyfarm-agent/releases{/id}","created_at":"2013-11-26T09:05:01Z","updated_at":"2015-04-30T17:28:03Z","pushed_at":"2015-05-06T18:44:57Z","git_url":"git://github.com/guidow/pyfarm-agent.git","ssh_url":"git@github.com:guidow/pyfarm-agent.git","clone_url":"https://github.com/guidow/pyfarm-agent.git","svn_url":"https://github.com/guidow/pyfarm-agent","homepage":"","size":4083,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"pyfarm:master","ref":"master","sha":"aed8c88b34dfa561c542c6cbc4325cdcd1c6c0b3","user":{"login":"pyfarm","id":5248007,"avatar_url":"https://avatars.githubusercontent.com/u/5248007?v=3","gravatar_id":"","url":"https://api.github.com/users/pyfarm","html_url":"https://github.com/pyfarm","followers_url":"https://api.github.com/users/pyfarm/followers","following_url":"https://api.github.com/users/pyfarm/following{/other_user}","gists_url":"https://api.github.com/users/pyfarm/gists{/gist_id}","starred_url":"https://api.github.com/users/pyfarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyfarm/subscriptions","organizations_url":"https://api.github.com/users/pyfarm/orgs","repos_url":"https://api.github.com/users/pyfarm/repos","events_url":"https://api.github.com/users/pyfarm/events{/privacy}","received_events_url":"https://api.github.com/users/pyfarm/received_events","type":"Organization","site_admin":false},"repo":{"id":13667312,"name":"pyfarm-agent","full_name":"pyfarm/pyfarm-agent","owner":{"login":"pyfarm","id":5248007,"avatar_url":"https://avatars.githubusercontent.com/u/5248007?v=3","gravatar_id":"","url":"https://api.github.com/users/pyfarm","html_url":"https://github.com/pyfarm","followers_url":"https://api.github.com/users/pyfarm/followers","following_url":"https://api.github.com/users/pyfarm/following{/other_user}","gists_url":"https://api.github.com/users/pyfarm/gists{/gist_id}","starred_url":"https://api.github.com/users/pyfarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyfarm/subscriptions","organizations_url":"https://api.github.com/users/pyfarm/orgs","repos_url":"https://api.github.com/users/pyfarm/repos","events_url":"https://api.github.com/users/pyfarm/events{/privacy}","received_events_url":"https://api.github.com/users/pyfarm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pyfarm/pyfarm-agent","description":"Core module containing code to run PyFarm's agent.","fork":false,"url":"https://api.github.com/repos/pyfarm/pyfarm-agent","forks_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/forks","keys_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/teams","hooks_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/hooks","issue_events_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues/events{/number}","events_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/events","assignees_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/assignees{/user}","branches_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/branches{/branch}","tags_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/tags","blobs_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/languages","stargazers_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/stargazers","contributors_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/contributors","subscribers_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/subscribers","subscription_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/subscription","commits_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/contents/{+path}","compare_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/merges","archive_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/downloads","issues_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues{/number}","pulls_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/labels{/name}","releases_url":"https://api.github.com/repos/pyfarm/pyfarm-agent/releases{/id}","created_at":"2013-10-18T02:41:17Z","updated_at":"2015-05-07T02:49:42Z","pushed_at":"2015-05-07T02:49:40Z","git_url":"git://github.com/pyfarm/pyfarm-agent.git","ssh_url":"git@github.com:pyfarm/pyfarm-agent.git","clone_url":"https://github.com/pyfarm/pyfarm-agent.git","svn_url":"https://github.com/pyfarm/pyfarm-agent","homepage":"","size":8005,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":25,"forks":1,"open_issues":25,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272"},"html":{"href":"https://github.com/pyfarm/pyfarm-agent/pull/272"},"issue":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues/272"},"comments":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/issues/272/comments"},"review_comments":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272/comments"},"review_comment":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/pulls/272/commits"},"statuses":{"href":"https://api.github.com/repos/pyfarm/pyfarm-agent/statuses/00d59eeaf558e64efd438c31a9a31c5efb943add"}}}}