{"action":"created","comment":{"url":"https://api.github.com/repos/mitdbg/modeldb/pulls/comments/114161188","pull_request_review_id":35605006,"id":114161188,"diff_hunk":"@@ -0,0 +1,94 @@\n+import dpath.util\n+import os\n+import json\n+import sys\n+\n+def create_config():\n+    file_dir = os.path.dirname(__file__)\n+    filename = file_dir + '/syncer.json'\n+    old_config = json.load(file(filename, 'r'))\n+    new_config = json.load(file(filename, 'r'))\n+\n+    raw_input(\n+        'This utility helps you create a modeldb configuration file.\\n'\n+        'The file is used by the modeldb python and/or scala clients to '\n+        'connect to the modeldb server.\\n\\n'\n+        'Pressing <ENTER> enters the default values')\n+\n+    print('\\n== Output Filename ==')\n+    prompt = 'output filename (default=custom_syncer.json): '\n+    output_filename = str(raw_input(prompt))\n+    if output_filename == '':\n+        output_filename = 'custom_syncer.json'\n+\n+    print('\\n== Config Values ==')\n+    prompt_for_keys(new_config, old_config, True)\n+\n+    # create file in the current directory\n+    new_file = open(output_filename, 'w')\n+    new_file.write(str(json.dumps(new_config, sort_keys=True, indent=4)))\n+    new_file.close()\n+\n+    print('\\n== RESULT ==')\n+    print(\n+        'New syncer file, %s, created at %s') % (output_filename, os.getcwd())\n+\n+\n+def prompt_for_keys(new_config, d, top_level, path=''):\n+    for k, v in d.iteritems():\n+        if isinstance(v, dict):\n+            print('\\n-- %s --') % k\n+            path = '/%s' % k\n+            prompt_for_keys(new_config, v, False, path)\n+        else:\n+            # necessary because not all leaves are nested\n+            if top_level is True:\n+                print('\\n-- %s --') % k\n+                path = ''\n+\n+            leaf_path = '%s/%s' % (path, k)\n+            prompt = \"{0} (default={1}): \".format(leaf_path[1:], v)\n+            user_input = raw_input(prompt)\n+\n+            user_input = to_int_bool_none_or_return(user_input)\n+            if user_input == '':\n+                user_input = v\n+\n+            dpath.util.set(new_config, leaf_path, user_input)\n+\n+\n+def to_int_bool_none_or_return(value):\n+    bools = {'true': True, 't': True,\n+             'false': False, 'f': False,\n+             }\n+\n+    nones = ['none', 'null']\n+\n+    if isinstance(value, int):\n+        return value\n+\n+    if isinstance(value, bool):\n+        return value\n+\n+    lower_value = value.lower()\n+    if lower_value in bools:\n+        return bools[lower_value]\n+    elif represents_int(lower_value):\n+        return int(lower_value)\n+    elif lower_value in nones:\n+        return None\n+    else:\n+        return value\n+\n+\n+def represents_int(s):\n+    try:\n+        int(s)\n+        return True\n+    except ValueError:\n+        return False\n+\n+\n+if __name__ == '__main__':\n+    if sys.argv[1] == 'create_config':\n+        create_config()","path":"client/python/modeldb/__main__.py","position":94,"original_position":94,"commit_id":"ac8afde7a03c030b2c056cfb707d271827c50522","original_commit_id":"ac8afde7a03c030b2c056cfb707d271827c50522","user":{"login":"justinanderson","id":244952,"avatar_url":"https://avatars3.githubusercontent.com/u/244952?v=3","gravatar_id":"","url":"https://api.github.com/users/justinanderson","html_url":"https://github.com/justinanderson","followers_url":"https://api.github.com/users/justinanderson/followers","following_url":"https://api.github.com/users/justinanderson/following{/other_user}","gists_url":"https://api.github.com/users/justinanderson/gists{/gist_id}","starred_url":"https://api.github.com/users/justinanderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinanderson/subscriptions","organizations_url":"https://api.github.com/users/justinanderson/orgs","repos_url":"https://api.github.com/users/justinanderson/repos","events_url":"https://api.github.com/users/justinanderson/events{/privacy}","received_events_url":"https://api.github.com/users/justinanderson/received_events","type":"User","site_admin":false},"body":"If you wrap this in a try-except block, users can exit gracefully with ctrl-c:\r\n\r\n```py\r\ntry:\r\n    create_config()\r\nexcept KeyboardInterrupt:\r\n    pass\r\n```","created_at":"2017-05-01T17:34:29Z","updated_at":"2017-05-01T17:36:12Z","html_url":"https://github.com/mitdbg/modeldb/pull/245#discussion_r114161188","pull_request_url":"https://api.github.com/repos/mitdbg/modeldb/pulls/245","_links":{"self":{"href":"https://api.github.com/repos/mitdbg/modeldb/pulls/comments/114161188"},"html":{"href":"https://github.com/mitdbg/modeldb/pull/245#discussion_r114161188"},"pull_request":{"href":"https://api.github.com/repos/mitdbg/modeldb/pulls/245"}}},"pull_request":{"url":"https://api.github.com/repos/mitdbg/modeldb/pulls/245","id":117031836,"html_url":"https://github.com/mitdbg/modeldb/pull/245","diff_url":"https://github.com/mitdbg/modeldb/pull/245.diff","patch_url":"https://github.com/mitdbg/modeldb/pull/245.patch","issue_url":"https://api.github.com/repos/mitdbg/modeldb/issues/245","number":245,"state":"open","locked":false,"title":"[MRG] Create PyPI package for modeldb","user":{"login":"RogerTangos","id":1609475,"avatar_url":"https://avatars3.githubusercontent.com/u/1609475?v=3","gravatar_id":"","url":"https://api.github.com/users/RogerTangos","html_url":"https://github.com/RogerTangos","followers_url":"https://api.github.com/users/RogerTangos/followers","following_url":"https://api.github.com/users/RogerTangos/following{/other_user}","gists_url":"https://api.github.com/users/RogerTangos/gists{/gist_id}","starred_url":"https://api.github.com/users/RogerTangos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RogerTangos/subscriptions","organizations_url":"https://api.github.com/users/RogerTangos/orgs","repos_url":"https://api.github.com/users/RogerTangos/repos","events_url":"https://api.github.com/users/RogerTangos/events{/privacy}","received_events_url":"https://api.github.com/users/RogerTangos/received_events","type":"User","site_admin":false},"body":"Relates to #244. Pip installable modeldb python package.","created_at":"2017-04-21T17:27:06Z","updated_at":"2017-05-01T17:36:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13c6d059aa91bd9bb7006fbd28d5642506a5db78","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mitdbg/modeldb/pulls/245/commits","review_comments_url":"https://api.github.com/repos/mitdbg/modeldb/pulls/245/comments","review_comment_url":"https://api.github.com/repos/mitdbg/modeldb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitdbg/modeldb/issues/245/comments","statuses_url":"https://api.github.com/repos/mitdbg/modeldb/statuses/ac8afde7a03c030b2c056cfb707d271827c50522","head":{"label":"mitdbg:RogerTangos/PyPI","ref":"RogerTangos/PyPI","sha":"ac8afde7a03c030b2c056cfb707d271827c50522","user":{"login":"mitdbg","id":649583,"avatar_url":"https://avatars2.githubusercontent.com/u/649583?v=3","gravatar_id":"","url":"https://api.github.com/users/mitdbg","html_url":"https://github.com/mitdbg","followers_url":"https://api.github.com/users/mitdbg/followers","following_url":"https://api.github.com/users/mitdbg/following{/other_user}","gists_url":"https://api.github.com/users/mitdbg/gists{/gist_id}","starred_url":"https://api.github.com/users/mitdbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitdbg/subscriptions","organizations_url":"https://api.github.com/users/mitdbg/orgs","repos_url":"https://api.github.com/users/mitdbg/repos","events_url":"https://api.github.com/users/mitdbg/events{/privacy}","received_events_url":"https://api.github.com/users/mitdbg/received_events","type":"Organization","site_admin":false},"repo":{"id":71305435,"name":"modeldb","full_name":"mitdbg/modeldb","owner":{"login":"mitdbg","id":649583,"avatar_url":"https://avatars2.githubusercontent.com/u/649583?v=3","gravatar_id":"","url":"https://api.github.com/users/mitdbg","html_url":"https://github.com/mitdbg","followers_url":"https://api.github.com/users/mitdbg/followers","following_url":"https://api.github.com/users/mitdbg/following{/other_user}","gists_url":"https://api.github.com/users/mitdbg/gists{/gist_id}","starred_url":"https://api.github.com/users/mitdbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitdbg/subscriptions","organizations_url":"https://api.github.com/users/mitdbg/orgs","repos_url":"https://api.github.com/users/mitdbg/repos","events_url":"https://api.github.com/users/mitdbg/events{/privacy}","received_events_url":"https://api.github.com/users/mitdbg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitdbg/modeldb","description":"A system to manage machine learning models","fork":false,"url":"https://api.github.com/repos/mitdbg/modeldb","forks_url":"https://api.github.com/repos/mitdbg/modeldb/forks","keys_url":"https://api.github.com/repos/mitdbg/modeldb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitdbg/modeldb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitdbg/modeldb/teams","hooks_url":"https://api.github.com/repos/mitdbg/modeldb/hooks","issue_events_url":"https://api.github.com/repos/mitdbg/modeldb/issues/events{/number}","events_url":"https://api.github.com/repos/mitdbg/modeldb/events","assignees_url":"https://api.github.com/repos/mitdbg/modeldb/assignees{/user}","branches_url":"https://api.github.com/repos/mitdbg/modeldb/branches{/branch}","tags_url":"https://api.github.com/repos/mitdbg/modeldb/tags","blobs_url":"https://api.github.com/repos/mitdbg/modeldb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitdbg/modeldb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitdbg/modeldb/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitdbg/modeldb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitdbg/modeldb/statuses/{sha}","languages_url":"https://api.github.com/repos/mitdbg/modeldb/languages","stargazers_url":"https://api.github.com/repos/mitdbg/modeldb/stargazers","contributors_url":"https://api.github.com/repos/mitdbg/modeldb/contributors","subscribers_url":"https://api.github.com/repos/mitdbg/modeldb/subscribers","subscription_url":"https://api.github.com/repos/mitdbg/modeldb/subscription","commits_url":"https://api.github.com/repos/mitdbg/modeldb/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitdbg/modeldb/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitdbg/modeldb/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitdbg/modeldb/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitdbg/modeldb/contents/{+path}","compare_url":"https://api.github.com/repos/mitdbg/modeldb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitdbg/modeldb/merges","archive_url":"https://api.github.com/repos/mitdbg/modeldb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitdbg/modeldb/downloads","issues_url":"https://api.github.com/repos/mitdbg/modeldb/issues{/number}","pulls_url":"https://api.github.com/repos/mitdbg/modeldb/pulls{/number}","milestones_url":"https://api.github.com/repos/mitdbg/modeldb/milestones{/number}","notifications_url":"https://api.github.com/repos/mitdbg/modeldb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitdbg/modeldb/labels{/name}","releases_url":"https://api.github.com/repos/mitdbg/modeldb/releases{/id}","deployments_url":"https://api.github.com/repos/mitdbg/modeldb/deployments","created_at":"2016-10-19T01:07:26Z","updated_at":"2017-05-01T17:26:15Z","pushed_at":"2017-05-01T16:57:29Z","git_url":"git://github.com/mitdbg/modeldb.git","ssh_url":"git@github.com:mitdbg/modeldb.git","clone_url":"https://github.com/mitdbg/modeldb.git","svn_url":"https://github.com/mitdbg/modeldb","homepage":"http://modeldb.csail.mit.edu/","size":9049,"stargazers_count":73,"watchers_count":73,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":19,"forks":14,"open_issues":19,"watchers":73,"default_branch":"master"}},"base":{"label":"mitdbg:master","ref":"master","sha":"e9a27b0323c1a4f3b0af18dcca31e0218cb81b01","user":{"login":"mitdbg","id":649583,"avatar_url":"https://avatars2.githubusercontent.com/u/649583?v=3","gravatar_id":"","url":"https://api.github.com/users/mitdbg","html_url":"https://github.com/mitdbg","followers_url":"https://api.github.com/users/mitdbg/followers","following_url":"https://api.github.com/users/mitdbg/following{/other_user}","gists_url":"https://api.github.com/users/mitdbg/gists{/gist_id}","starred_url":"https://api.github.com/users/mitdbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitdbg/subscriptions","organizations_url":"https://api.github.com/users/mitdbg/orgs","repos_url":"https://api.github.com/users/mitdbg/repos","events_url":"https://api.github.com/users/mitdbg/events{/privacy}","received_events_url":"https://api.github.com/users/mitdbg/received_events","type":"Organization","site_admin":false},"repo":{"id":71305435,"name":"modeldb","full_name":"mitdbg/modeldb","owner":{"login":"mitdbg","id":649583,"avatar_url":"https://avatars2.githubusercontent.com/u/649583?v=3","gravatar_id":"","url":"https://api.github.com/users/mitdbg","html_url":"https://github.com/mitdbg","followers_url":"https://api.github.com/users/mitdbg/followers","following_url":"https://api.github.com/users/mitdbg/following{/other_user}","gists_url":"https://api.github.com/users/mitdbg/gists{/gist_id}","starred_url":"https://api.github.com/users/mitdbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitdbg/subscriptions","organizations_url":"https://api.github.com/users/mitdbg/orgs","repos_url":"https://api.github.com/users/mitdbg/repos","events_url":"https://api.github.com/users/mitdbg/events{/privacy}","received_events_url":"https://api.github.com/users/mitdbg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitdbg/modeldb","description":"A system to manage machine learning models","fork":false,"url":"https://api.github.com/repos/mitdbg/modeldb","forks_url":"https://api.github.com/repos/mitdbg/modeldb/forks","keys_url":"https://api.github.com/repos/mitdbg/modeldb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitdbg/modeldb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitdbg/modeldb/teams","hooks_url":"https://api.github.com/repos/mitdbg/modeldb/hooks","issue_events_url":"https://api.github.com/repos/mitdbg/modeldb/issues/events{/number}","events_url":"https://api.github.com/repos/mitdbg/modeldb/events","assignees_url":"https://api.github.com/repos/mitdbg/modeldb/assignees{/user}","branches_url":"https://api.github.com/repos/mitdbg/modeldb/branches{/branch}","tags_url":"https://api.github.com/repos/mitdbg/modeldb/tags","blobs_url":"https://api.github.com/repos/mitdbg/modeldb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitdbg/modeldb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitdbg/modeldb/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitdbg/modeldb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitdbg/modeldb/statuses/{sha}","languages_url":"https://api.github.com/repos/mitdbg/modeldb/languages","stargazers_url":"https://api.github.com/repos/mitdbg/modeldb/stargazers","contributors_url":"https://api.github.com/repos/mitdbg/modeldb/contributors","subscribers_url":"https://api.github.com/repos/mitdbg/modeldb/subscribers","subscription_url":"https://api.github.com/repos/mitdbg/modeldb/subscription","commits_url":"https://api.github.com/repos/mitdbg/modeldb/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitdbg/modeldb/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitdbg/modeldb/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitdbg/modeldb/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitdbg/modeldb/contents/{+path}","compare_url":"https://api.github.com/repos/mitdbg/modeldb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitdbg/modeldb/merges","archive_url":"https://api.github.com/repos/mitdbg/modeldb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitdbg/modeldb/downloads","issues_url":"https://api.github.com/repos/mitdbg/modeldb/issues{/number}","pulls_url":"https://api.github.com/repos/mitdbg/modeldb/pulls{/number}","milestones_url":"https://api.github.com/repos/mitdbg/modeldb/milestones{/number}","notifications_url":"https://api.github.com/repos/mitdbg/modeldb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitdbg/modeldb/labels{/name}","releases_url":"https://api.github.com/repos/mitdbg/modeldb/releases{/id}","deployments_url":"https://api.github.com/repos/mitdbg/modeldb/deployments","created_at":"2016-10-19T01:07:26Z","updated_at":"2017-05-01T17:26:15Z","pushed_at":"2017-05-01T16:57:29Z","git_url":"git://github.com/mitdbg/modeldb.git","ssh_url":"git@github.com:mitdbg/modeldb.git","clone_url":"https://github.com/mitdbg/modeldb.git","svn_url":"https://github.com/mitdbg/modeldb","homepage":"http://modeldb.csail.mit.edu/","size":9049,"stargazers_count":73,"watchers_count":73,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":19,"forks":14,"open_issues":19,"watchers":73,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitdbg/modeldb/pulls/245"},"html":{"href":"https://github.com/mitdbg/modeldb/pull/245"},"issue":{"href":"https://api.github.com/repos/mitdbg/modeldb/issues/245"},"comments":{"href":"https://api.github.com/repos/mitdbg/modeldb/issues/245/comments"},"review_comments":{"href":"https://api.github.com/repos/mitdbg/modeldb/pulls/245/comments"},"review_comment":{"href":"https://api.github.com/repos/mitdbg/modeldb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitdbg/modeldb/pulls/245/commits"},"statuses":{"href":"https://api.github.com/repos/mitdbg/modeldb/statuses/ac8afde7a03c030b2c056cfb707d271827c50522"}}}}
{"actor":{"display_login":"justinanderson"}}