{"action":"created","comment":{"url":"https://api.github.com/repos/tensorflow/minigo/pulls/comments/226400763","pull_request_review_id":166210940,"id":226400763,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjQwMDc2Mw==","diff_hunk":"@@ -0,0 +1,91 @@\n+\"\"\"Read Minigo game examples from a Bigtable.\n+\"\"\"\n+\n+from google.cloud import bigtable\n+from google.cloud.bigtable import row_filters\n+import logging\n+import os\n+import struct\n+import tensorflow as tf\n+\n+\n+_project_name = os.environ['PROJECT']\n+_instance_name = os.environ['CBT_INSTANCE']\n+_table_name = os.environ['CBT_TABLE']\n+\n+_bt_table = bigtable.Client(\n+    _project_name).instance(\n+        _instance_name).table(\n+            _table_name)\n+\n+_tf_table = tf.contrib.cloud.BigtableClient(\n+    _project_name,\n+    _instance_name).table(\n+        _table_name)\n+\n+\n+_features = {\n+    'x': tf.FixedLenFeature((), tf.string, ''),\n+    'pi': tf.FixedLenFeature((), tf.string, ''),\n+    'outcome': tf.VarLenFeature(dtype=tf.float32)\n+    }\n+\n+\n+def get_latest_game_number():\n+  \"\"\"Return the number of the next game to be stored.\n+  \"\"\"\n+  table_state = _bt_table.read_row('table_state')\n+  value = table_state.cells['metadata'][b'game_counter'][0].value\n+  return struct.unpack('>q', value)[0]\n+\n+\n+def get_game_range_row_names(game_begin, game_end):\n+  \"\"\"Get the row range containing the given games.\n+\n+  Sample row name:\n+    g_0000000001_m000001\n+\n+  To capture the range of all moves in the two given games,\n+  the end row will Need to go up to g_00..(N+1).\n+  \"\"\"\n+  row_fmt = 'g_{:0>10}_'\n+  return row_fmt.format(game_begin), row_fmt.format(game_end + 1)\n+\n+\n+def get_unparsed_moves_from_last_n_games(n, probability,\n+                                         column_family='tfexample',\n+                                         column='example'):\n+  latest_game = int(get_latest_game_number())\n+  logging.info(\"Latest game: %s\", latest_game)\n+  if latest_game == 0:\n+    return 0","path":"bigtable_input.py","position":61,"original_position":61,"commit_id":"79bc8ca200aafb43bb556e48b29aab3f4115cace","original_commit_id":"79bc8ca200aafb43bb556e48b29aab3f4115cace","user":{"login":"sethtroisi","id":10172976,"node_id":"MDQ6VXNlcjEwMTcyOTc2","avatar_url":"https://avatars2.githubusercontent.com/u/10172976?v=4","gravatar_id":"","url":"https://api.github.com/users/sethtroisi","html_url":"https://github.com/sethtroisi","followers_url":"https://api.github.com/users/sethtroisi/followers","following_url":"https://api.github.com/users/sethtroisi/following{/other_user}","gists_url":"https://api.github.com/users/sethtroisi/gists{/gist_id}","starred_url":"https://api.github.com/users/sethtroisi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethtroisi/subscriptions","organizations_url":"https://api.github.com/users/sethtroisi/orgs","repos_url":"https://api.github.com/users/sethtroisi/repos","events_url":"https://api.github.com/users/sethtroisi/events{/privacy}","received_events_url":"https://api.github.com/users/sethtroisi/received_events","type":"User","site_admin":false},"body":"probably more useful to throw an exception","created_at":"2018-10-18T17:42:10Z","updated_at":"2018-10-18T17:45:42Z","html_url":"https://github.com/tensorflow/minigo/pull/515#discussion_r226400763","pull_request_url":"https://api.github.com/repos/tensorflow/minigo/pulls/515","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/comments/226400763"},"html":{"href":"https://github.com/tensorflow/minigo/pull/515#discussion_r226400763"},"pull_request":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/515"}}},"pull_request":{"url":"https://api.github.com/repos/tensorflow/minigo/pulls/515","id":224028734,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0MDI4NzM0","html_url":"https://github.com/tensorflow/minigo/pull/515","diff_url":"https://github.com/tensorflow/minigo/pull/515.diff","patch_url":"https://github.com/tensorflow/minigo/pull/515.patch","issue_url":"https://api.github.com/repos/tensorflow/minigo/issues/515","number":515,"state":"open","locked":false,"title":"Bigtable input available for training","user":{"login":"gitosaurus","id":6794831,"node_id":"MDQ6VXNlcjY3OTQ4MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/6794831?v=4","gravatar_id":"","url":"https://api.github.com/users/gitosaurus","html_url":"https://github.com/gitosaurus","followers_url":"https://api.github.com/users/gitosaurus/followers","following_url":"https://api.github.com/users/gitosaurus/following{/other_user}","gists_url":"https://api.github.com/users/gitosaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/gitosaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitosaurus/subscriptions","organizations_url":"https://api.github.com/users/gitosaurus/orgs","repos_url":"https://api.github.com/users/gitosaurus/repos","events_url":"https://api.github.com/users/gitosaurus/events{/privacy}","received_events_url":"https://api.github.com/users/gitosaurus/received_events","type":"User","site_admin":false},"body":"Ability to sample moves from last N games in table.\r\nThis is a preview, for discussion and for experimenting;\r\nright now it fixes N=500k, and the probability; these\r\nshould be parameters.\r\n\r\nGoogle Cloud Bigtable package now required.","created_at":"2018-10-18T16:56:05Z","updated_at":"2018-10-18T17:45:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"75a6ea70990983017734e8289ea3e04d6ec737c2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":832833043,"node_id":"MDU6TGFiZWw4MzI4MzMwNDM=","url":"https://api.github.com/repos/tensorflow/minigo/labels/size/L","name":"size/L","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/minigo/pulls/515/commits","review_comments_url":"https://api.github.com/repos/tensorflow/minigo/pulls/515/comments","review_comment_url":"https://api.github.com/repos/tensorflow/minigo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/minigo/issues/515/comments","statuses_url":"https://api.github.com/repos/tensorflow/minigo/statuses/79bc8ca200aafb43bb556e48b29aab3f4115cace","head":{"label":"gitosaurus:bigtable-input-prev","ref":"bigtable-input-prev","sha":"79bc8ca200aafb43bb556e48b29aab3f4115cace","user":{"login":"gitosaurus","id":6794831,"node_id":"MDQ6VXNlcjY3OTQ4MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/6794831?v=4","gravatar_id":"","url":"https://api.github.com/users/gitosaurus","html_url":"https://github.com/gitosaurus","followers_url":"https://api.github.com/users/gitosaurus/followers","following_url":"https://api.github.com/users/gitosaurus/following{/other_user}","gists_url":"https://api.github.com/users/gitosaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/gitosaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitosaurus/subscriptions","organizations_url":"https://api.github.com/users/gitosaurus/orgs","repos_url":"https://api.github.com/users/gitosaurus/repos","events_url":"https://api.github.com/users/gitosaurus/events{/privacy}","received_events_url":"https://api.github.com/users/gitosaurus/received_events","type":"User","site_admin":false},"repo":{"id":149795707,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk3OTU3MDc=","name":"minigo","full_name":"gitosaurus/minigo","private":false,"owner":{"login":"gitosaurus","id":6794831,"node_id":"MDQ6VXNlcjY3OTQ4MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/6794831?v=4","gravatar_id":"","url":"https://api.github.com/users/gitosaurus","html_url":"https://github.com/gitosaurus","followers_url":"https://api.github.com/users/gitosaurus/followers","following_url":"https://api.github.com/users/gitosaurus/following{/other_user}","gists_url":"https://api.github.com/users/gitosaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/gitosaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitosaurus/subscriptions","organizations_url":"https://api.github.com/users/gitosaurus/orgs","repos_url":"https://api.github.com/users/gitosaurus/repos","events_url":"https://api.github.com/users/gitosaurus/events{/privacy}","received_events_url":"https://api.github.com/users/gitosaurus/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gitosaurus/minigo","description":"An open-source implementation of the AlphaGoZero algorithm","fork":true,"url":"https://api.github.com/repos/gitosaurus/minigo","forks_url":"https://api.github.com/repos/gitosaurus/minigo/forks","keys_url":"https://api.github.com/repos/gitosaurus/minigo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitosaurus/minigo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitosaurus/minigo/teams","hooks_url":"https://api.github.com/repos/gitosaurus/minigo/hooks","issue_events_url":"https://api.github.com/repos/gitosaurus/minigo/issues/events{/number}","events_url":"https://api.github.com/repos/gitosaurus/minigo/events","assignees_url":"https://api.github.com/repos/gitosaurus/minigo/assignees{/user}","branches_url":"https://api.github.com/repos/gitosaurus/minigo/branches{/branch}","tags_url":"https://api.github.com/repos/gitosaurus/minigo/tags","blobs_url":"https://api.github.com/repos/gitosaurus/minigo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitosaurus/minigo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitosaurus/minigo/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitosaurus/minigo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitosaurus/minigo/statuses/{sha}","languages_url":"https://api.github.com/repos/gitosaurus/minigo/languages","stargazers_url":"https://api.github.com/repos/gitosaurus/minigo/stargazers","contributors_url":"https://api.github.com/repos/gitosaurus/minigo/contributors","subscribers_url":"https://api.github.com/repos/gitosaurus/minigo/subscribers","subscription_url":"https://api.github.com/repos/gitosaurus/minigo/subscription","commits_url":"https://api.github.com/repos/gitosaurus/minigo/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitosaurus/minigo/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitosaurus/minigo/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitosaurus/minigo/issues/comments{/number}","contents_url":"https://api.github.com/repos/gitosaurus/minigo/contents/{+path}","compare_url":"https://api.github.com/repos/gitosaurus/minigo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitosaurus/minigo/merges","archive_url":"https://api.github.com/repos/gitosaurus/minigo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitosaurus/minigo/downloads","issues_url":"https://api.github.com/repos/gitosaurus/minigo/issues{/number}","pulls_url":"https://api.github.com/repos/gitosaurus/minigo/pulls{/number}","milestones_url":"https://api.github.com/repos/gitosaurus/minigo/milestones{/number}","notifications_url":"https://api.github.com/repos/gitosaurus/minigo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitosaurus/minigo/labels{/name}","releases_url":"https://api.github.com/repos/gitosaurus/minigo/releases{/id}","deployments_url":"https://api.github.com/repos/gitosaurus/minigo/deployments","created_at":"2018-09-21T17:26:04Z","updated_at":"2018-10-17T18:28:12Z","pushed_at":"2018-10-18T16:55:39Z","git_url":"git://github.com/gitosaurus/minigo.git","ssh_url":"git@github.com:gitosaurus/minigo.git","clone_url":"https://github.com/gitosaurus/minigo.git","svn_url":"https://github.com/gitosaurus/minigo","homepage":"","size":3009,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tensorflow:master","ref":"master","sha":"c5e311540f8a809383316b8d4494e751f38a2061","user":{"login":"tensorflow","id":15658638,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjU4NjM4","avatar_url":"https://avatars1.githubusercontent.com/u/15658638?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"repo":{"id":119455332,"node_id":"MDEwOlJlcG9zaXRvcnkxMTk0NTUzMzI=","name":"minigo","full_name":"tensorflow/minigo","private":false,"owner":{"login":"tensorflow","id":15658638,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjU4NjM4","avatar_url":"https://avatars1.githubusercontent.com/u/15658638?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/tensorflow/minigo","description":"An open-source implementation of the AlphaGoZero algorithm","fork":false,"url":"https://api.github.com/repos/tensorflow/minigo","forks_url":"https://api.github.com/repos/tensorflow/minigo/forks","keys_url":"https://api.github.com/repos/tensorflow/minigo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/minigo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/minigo/teams","hooks_url":"https://api.github.com/repos/tensorflow/minigo/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/minigo/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/minigo/events","assignees_url":"https://api.github.com/repos/tensorflow/minigo/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/minigo/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/minigo/tags","blobs_url":"https://api.github.com/repos/tensorflow/minigo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/minigo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/minigo/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/minigo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/minigo/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/minigo/languages","stargazers_url":"https://api.github.com/repos/tensorflow/minigo/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/minigo/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/minigo/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/minigo/subscription","commits_url":"https://api.github.com/repos/tensorflow/minigo/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/minigo/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/minigo/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/minigo/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/minigo/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/minigo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/minigo/merges","archive_url":"https://api.github.com/repos/tensorflow/minigo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/minigo/downloads","issues_url":"https://api.github.com/repos/tensorflow/minigo/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/minigo/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/minigo/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/minigo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/minigo/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/minigo/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/minigo/deployments","created_at":"2018-01-29T23:29:07Z","updated_at":"2018-10-18T17:41:11Z","pushed_at":"2018-10-18T17:41:08Z","git_url":"git://github.com/tensorflow/minigo.git","ssh_url":"git@github.com:tensorflow/minigo.git","clone_url":"https://github.com/tensorflow/minigo.git","svn_url":"https://github.com/tensorflow/minigo","homepage":"","size":3030,"stargazers_count":2424,"watchers_count":2424,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":342,"mirror_url":null,"archived":false,"open_issues_count":54,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":342,"open_issues":54,"watchers":2424,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/515"},"html":{"href":"https://github.com/tensorflow/minigo/pull/515"},"issue":{"href":"https://api.github.com/repos/tensorflow/minigo/issues/515"},"comments":{"href":"https://api.github.com/repos/tensorflow/minigo/issues/515/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/515/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/515/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/minigo/statuses/79bc8ca200aafb43bb556e48b29aab3f4115cace"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sethtroisi"}}