{"action":"created","comment":{"url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/comments/74637371","id":74637371,"diff_hunk":"@@ -57,6 +59,78 @@ var WorksheetItemList = React.createClass({\n         }.bind(this), 'keydown');\n     },\n \n+    // Automatically update run bundle until it is ready or failed\n+    updateRunBundle: function(worksheetUuid, updatingBundleUuids) {\n+      var bundleUuids = updatingBundleUuids ? updatingBundleUuids : this.state.updatingBundleUuids;\n+      var startTime = new Date().getTime();\n+      var self = this;\n+      var queryParams = Object.keys(bundleUuids).map(function(bundle_uuid) {\n+        return 'bundle_uuid=' + bundle_uuid;\n+      }).join('&');\n+      $.ajax({\n+        type: \"GET\",\n+        url: \"/rest/api/worksheets/\" + worksheetUuid + \"/?\" + queryParams,\n+        dataType: 'json',\n+        cache: false,\n+        success: function(worksheet_content) {\n+          if (this.state.isUpdatingBundles) {\n+            if (worksheet_content.items) {\n+              self.props.refreshWorksheet(worksheet_content.items);\n+            }\n+            var endTime = new Date().getTime();\n+            var delayTime = Math.max(3000, (endTime - startTime) * 5);\n+            // delayTime is at least five times the amount of time it takes for the last request to complete\n+            setTimeout(function() {\n+              self.updateRunBundle(worksheetUuid);\n+            }, delayTime);\n+            startTime = endTime;\n+          }\n+        }.bind(this),\n+        error: function(xhr, status, err) {\n+          $(\"#worksheet-message\").html(xhr.responseText).addClass('alert-danger alert');\n+          $('#worksheet_container').hide();\n+        }.bind(this)\n+      });\n+    },\n+\n+    // Check for unfinished run bundles (not ready or failed), and call updateRunBundle to constantly update them\n+    checkRunBundle: function(nextProps) {\n+      var info = nextProps.ws.info;\n+      var updatingBundleUuids = _.clone(this.state.updatingBundleUuids);\n+      if (info && info.items.length > 0) {\n+        var items = info.items;\n+        for (var i = 0; i < items.length; i++) {\n+          var bundle_info = items[i].bundle_info;\n+          if (bundle_info) {\n+            if (!Array.isArray(bundle_info)) bundle_info = [bundle_info];\n+            for (var j = 0; j < bundle_info.length; j++) {\n+              var bundle = bundle_info[j];\n+              if (bundle.bundle_type === 'run') {\n+                if (bundle.state !== 'ready' && bundle.state !== 'failed') {\n+                  updatingBundleUuids[bundle.uuid] = true;\n+                } else {\n+                  if (bundle.uuid in updatingBundleUuids)\n+                    delete updatingBundleUuids[bundle.uuid];\n+                }\n+              }\n+            }\n+          }\n+        }\n+        if (Object.keys(updatingBundleUuids).length > 0 && !this.state.isUpdatingBundles) {\n+          this.setState({isUpdatingBundles: true});\n+          this.updateRunBundle(info.uuid, updatingBundleUuids);\n+        }\n+        if (Object.keys(updatingBundleUuids).length === 0 && this.state.isUpdatingBundles) {\n+          this.setState({isUpdatingBundles: false});\n+        }\n+        this.setState({updatingBundleUuids: updatingBundleUuids});","path":"codalab/apps/web/static/js/worksheet/worksheet_items.jsx","position":82,"original_position":82,"commit_id":"d28de3320c56ac8467ca8d7972fb682ee9858f19","original_commit_id":"d28de3320c56ac8467ca8d7972fb682ee9858f19","user":{"login":"ChengshuLi","id":6732996,"avatar_url":"https://avatars.githubusercontent.com/u/6732996?v=3","gravatar_id":"","url":"https://api.github.com/users/ChengshuLi","html_url":"https://github.com/ChengshuLi","followers_url":"https://api.github.com/users/ChengshuLi/followers","following_url":"https://api.github.com/users/ChengshuLi/following{/other_user}","gists_url":"https://api.github.com/users/ChengshuLi/gists{/gist_id}","starred_url":"https://api.github.com/users/ChengshuLi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChengshuLi/subscriptions","organizations_url":"https://api.github.com/users/ChengshuLi/orgs","repos_url":"https://api.github.com/users/ChengshuLi/repos","events_url":"https://api.github.com/users/ChengshuLi/events{/privacy}","received_events_url":"https://api.github.com/users/ChengshuLi/received_events","type":"User","site_admin":false},"body":"We will update \"updatingBundleUuids\" no matter what. \r\nSay we have 5 running bundles, and we already have started our constant fetching. \r\nSay 2 of them finish, 3 remaning to run. Now Object.keys(updatingBundleUuids).length == 3. isUpdatingBundles === true. It does not fall into either of the cases above, we still need to update \"updatingBundleUuids\" to 3 bundles ","created_at":"2016-08-12T18:21:38Z","updated_at":"2016-08-12T18:21:38Z","html_url":"https://github.com/codalab/codalab-worksheets/pull/169#discussion_r74637371","pull_request_url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169","_links":{"self":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/comments/74637371"},"html":{"href":"https://github.com/codalab/codalab-worksheets/pull/169#discussion_r74637371"},"pull_request":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169"}}},"pull_request":{"url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169","id":70658944,"html_url":"https://github.com/codalab/codalab-worksheets/pull/169","diff_url":"https://github.com/codalab/codalab-worksheets/pull/169.diff","patch_url":"https://github.com/codalab/codalab-worksheets/pull/169.patch","issue_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues/169","number":169,"state":"open","locked":false,"title":"issue#104: Refresh individual bundle","user":{"login":"ChengshuLi","id":6732996,"avatar_url":"https://avatars.githubusercontent.com/u/6732996?v=3","gravatar_id":"","url":"https://api.github.com/users/ChengshuLi","html_url":"https://github.com/ChengshuLi","followers_url":"https://api.github.com/users/ChengshuLi/followers","following_url":"https://api.github.com/users/ChengshuLi/following{/other_user}","gists_url":"https://api.github.com/users/ChengshuLi/gists{/gist_id}","starred_url":"https://api.github.com/users/ChengshuLi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChengshuLi/subscriptions","organizations_url":"https://api.github.com/users/ChengshuLi/orgs","repos_url":"https://api.github.com/users/ChengshuLi/repos","events_url":"https://api.github.com/users/ChengshuLi/events{/privacy}","received_events_url":"https://api.github.com/users/ChengshuLi/received_events","type":"User","site_admin":false},"body":"Fixes #104 \r\n\r\n@percyliang \r\n\r\nCheck out my cli PR as well. \r\nRequires a little bit change from the server side. ","created_at":"2016-05-19T09:07:22Z","updated_at":"2016-08-12T18:21:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bda6a3e022a2c382638c98ea3930c0aa2b7b2a6d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169/commits","review_comments_url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169/comments","review_comment_url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues/169/comments","statuses_url":"https://api.github.com/repos/codalab/codalab-worksheets/statuses/d28de3320c56ac8467ca8d7972fb682ee9858f19","head":{"label":"codalab:104","ref":"104","sha":"d28de3320c56ac8467ca8d7972fb682ee9858f19","user":{"login":"codalab","id":4633552,"avatar_url":"https://avatars.githubusercontent.com/u/4633552?v=3","gravatar_id":"","url":"https://api.github.com/users/codalab","html_url":"https://github.com/codalab","followers_url":"https://api.github.com/users/codalab/followers","following_url":"https://api.github.com/users/codalab/following{/other_user}","gists_url":"https://api.github.com/users/codalab/gists{/gist_id}","starred_url":"https://api.github.com/users/codalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codalab/subscriptions","organizations_url":"https://api.github.com/users/codalab/orgs","repos_url":"https://api.github.com/users/codalab/repos","events_url":"https://api.github.com/users/codalab/events{/privacy}","received_events_url":"https://api.github.com/users/codalab/received_events","type":"User","site_admin":false},"repo":{"id":48640313,"name":"codalab-worksheets","full_name":"codalab/codalab-worksheets","owner":{"login":"codalab","id":4633552,"avatar_url":"https://avatars.githubusercontent.com/u/4633552?v=3","gravatar_id":"","url":"https://api.github.com/users/codalab","html_url":"https://github.com/codalab","followers_url":"https://api.github.com/users/codalab/followers","following_url":"https://api.github.com/users/codalab/following{/other_user}","gists_url":"https://api.github.com/users/codalab/gists{/gist_id}","starred_url":"https://api.github.com/users/codalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codalab/subscriptions","organizations_url":"https://api.github.com/users/codalab/orgs","repos_url":"https://api.github.com/users/codalab/repos","events_url":"https://api.github.com/users/codalab/events{/privacy}","received_events_url":"https://api.github.com/users/codalab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/codalab/codalab-worksheets","description":"CodaLab Worksheets","fork":false,"url":"https://api.github.com/repos/codalab/codalab-worksheets","forks_url":"https://api.github.com/repos/codalab/codalab-worksheets/forks","keys_url":"https://api.github.com/repos/codalab/codalab-worksheets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codalab/codalab-worksheets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codalab/codalab-worksheets/teams","hooks_url":"https://api.github.com/repos/codalab/codalab-worksheets/hooks","issue_events_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues/events{/number}","events_url":"https://api.github.com/repos/codalab/codalab-worksheets/events","assignees_url":"https://api.github.com/repos/codalab/codalab-worksheets/assignees{/user}","branches_url":"https://api.github.com/repos/codalab/codalab-worksheets/branches{/branch}","tags_url":"https://api.github.com/repos/codalab/codalab-worksheets/tags","blobs_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/refs{/sha}","trees_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codalab/codalab-worksheets/statuses/{sha}","languages_url":"https://api.github.com/repos/codalab/codalab-worksheets/languages","stargazers_url":"https://api.github.com/repos/codalab/codalab-worksheets/stargazers","contributors_url":"https://api.github.com/repos/codalab/codalab-worksheets/contributors","subscribers_url":"https://api.github.com/repos/codalab/codalab-worksheets/subscribers","subscription_url":"https://api.github.com/repos/codalab/codalab-worksheets/subscription","commits_url":"https://api.github.com/repos/codalab/codalab-worksheets/commits{/sha}","git_commits_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/commits{/sha}","comments_url":"https://api.github.com/repos/codalab/codalab-worksheets/comments{/number}","issue_comment_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues/comments{/number}","contents_url":"https://api.github.com/repos/codalab/codalab-worksheets/contents/{+path}","compare_url":"https://api.github.com/repos/codalab/codalab-worksheets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codalab/codalab-worksheets/merges","archive_url":"https://api.github.com/repos/codalab/codalab-worksheets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codalab/codalab-worksheets/downloads","issues_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues{/number}","pulls_url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls{/number}","milestones_url":"https://api.github.com/repos/codalab/codalab-worksheets/milestones{/number}","notifications_url":"https://api.github.com/repos/codalab/codalab-worksheets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codalab/codalab-worksheets/labels{/name}","releases_url":"https://api.github.com/repos/codalab/codalab-worksheets/releases{/id}","deployments_url":"https://api.github.com/repos/codalab/codalab-worksheets/deployments","created_at":"2015-12-27T09:51:16Z","updated_at":"2016-07-25T19:57:12Z","pushed_at":"2016-08-12T09:10:30Z","git_url":"git://github.com/codalab/codalab-worksheets.git","ssh_url":"git@github.com:codalab/codalab-worksheets.git","clone_url":"https://github.com/codalab/codalab-worksheets.git","svn_url":"https://github.com/codalab/codalab-worksheets","homepage":null,"size":25716,"stargazers_count":14,"watchers_count":14,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":42,"forks":6,"open_issues":42,"watchers":14,"default_branch":"master"}},"base":{"label":"codalab:develop","ref":"develop","sha":"420a091de95bc5d581e8ce1c75492b5379fd6710","user":{"login":"codalab","id":4633552,"avatar_url":"https://avatars.githubusercontent.com/u/4633552?v=3","gravatar_id":"","url":"https://api.github.com/users/codalab","html_url":"https://github.com/codalab","followers_url":"https://api.github.com/users/codalab/followers","following_url":"https://api.github.com/users/codalab/following{/other_user}","gists_url":"https://api.github.com/users/codalab/gists{/gist_id}","starred_url":"https://api.github.com/users/codalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codalab/subscriptions","organizations_url":"https://api.github.com/users/codalab/orgs","repos_url":"https://api.github.com/users/codalab/repos","events_url":"https://api.github.com/users/codalab/events{/privacy}","received_events_url":"https://api.github.com/users/codalab/received_events","type":"User","site_admin":false},"repo":{"id":48640313,"name":"codalab-worksheets","full_name":"codalab/codalab-worksheets","owner":{"login":"codalab","id":4633552,"avatar_url":"https://avatars.githubusercontent.com/u/4633552?v=3","gravatar_id":"","url":"https://api.github.com/users/codalab","html_url":"https://github.com/codalab","followers_url":"https://api.github.com/users/codalab/followers","following_url":"https://api.github.com/users/codalab/following{/other_user}","gists_url":"https://api.github.com/users/codalab/gists{/gist_id}","starred_url":"https://api.github.com/users/codalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codalab/subscriptions","organizations_url":"https://api.github.com/users/codalab/orgs","repos_url":"https://api.github.com/users/codalab/repos","events_url":"https://api.github.com/users/codalab/events{/privacy}","received_events_url":"https://api.github.com/users/codalab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/codalab/codalab-worksheets","description":"CodaLab Worksheets","fork":false,"url":"https://api.github.com/repos/codalab/codalab-worksheets","forks_url":"https://api.github.com/repos/codalab/codalab-worksheets/forks","keys_url":"https://api.github.com/repos/codalab/codalab-worksheets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codalab/codalab-worksheets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codalab/codalab-worksheets/teams","hooks_url":"https://api.github.com/repos/codalab/codalab-worksheets/hooks","issue_events_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues/events{/number}","events_url":"https://api.github.com/repos/codalab/codalab-worksheets/events","assignees_url":"https://api.github.com/repos/codalab/codalab-worksheets/assignees{/user}","branches_url":"https://api.github.com/repos/codalab/codalab-worksheets/branches{/branch}","tags_url":"https://api.github.com/repos/codalab/codalab-worksheets/tags","blobs_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/refs{/sha}","trees_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codalab/codalab-worksheets/statuses/{sha}","languages_url":"https://api.github.com/repos/codalab/codalab-worksheets/languages","stargazers_url":"https://api.github.com/repos/codalab/codalab-worksheets/stargazers","contributors_url":"https://api.github.com/repos/codalab/codalab-worksheets/contributors","subscribers_url":"https://api.github.com/repos/codalab/codalab-worksheets/subscribers","subscription_url":"https://api.github.com/repos/codalab/codalab-worksheets/subscription","commits_url":"https://api.github.com/repos/codalab/codalab-worksheets/commits{/sha}","git_commits_url":"https://api.github.com/repos/codalab/codalab-worksheets/git/commits{/sha}","comments_url":"https://api.github.com/repos/codalab/codalab-worksheets/comments{/number}","issue_comment_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues/comments{/number}","contents_url":"https://api.github.com/repos/codalab/codalab-worksheets/contents/{+path}","compare_url":"https://api.github.com/repos/codalab/codalab-worksheets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codalab/codalab-worksheets/merges","archive_url":"https://api.github.com/repos/codalab/codalab-worksheets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codalab/codalab-worksheets/downloads","issues_url":"https://api.github.com/repos/codalab/codalab-worksheets/issues{/number}","pulls_url":"https://api.github.com/repos/codalab/codalab-worksheets/pulls{/number}","milestones_url":"https://api.github.com/repos/codalab/codalab-worksheets/milestones{/number}","notifications_url":"https://api.github.com/repos/codalab/codalab-worksheets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codalab/codalab-worksheets/labels{/name}","releases_url":"https://api.github.com/repos/codalab/codalab-worksheets/releases{/id}","deployments_url":"https://api.github.com/repos/codalab/codalab-worksheets/deployments","created_at":"2015-12-27T09:51:16Z","updated_at":"2016-07-25T19:57:12Z","pushed_at":"2016-08-12T09:10:30Z","git_url":"git://github.com/codalab/codalab-worksheets.git","ssh_url":"git@github.com:codalab/codalab-worksheets.git","clone_url":"https://github.com/codalab/codalab-worksheets.git","svn_url":"https://github.com/codalab/codalab-worksheets","homepage":null,"size":25716,"stargazers_count":14,"watchers_count":14,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":42,"forks":6,"open_issues":42,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169"},"html":{"href":"https://github.com/codalab/codalab-worksheets/pull/169"},"issue":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/issues/169"},"comments":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/issues/169/comments"},"review_comments":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169/comments"},"review_comment":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/pulls/169/commits"},"statuses":{"href":"https://api.github.com/repos/codalab/codalab-worksheets/statuses/d28de3320c56ac8467ca8d7972fb682ee9858f19"}}}}
{"actor":{"display_login":"ChengshuLi"}}