{"action":"created","comment":{"url":"https://api.github.com/repos/ulysseB/telamon/pulls/comments/200293496","pull_request_review_id":134578455,"id":200293496,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDI5MzQ5Ng==","diff_hunk":"@@ -5,61 +5,102 @@\n tuning_path = os.path.realpath(\".\")\n setting_path = tuning_path + \"/settings/\"\n \n+spec = {\n+    \"log_file\": str,\n+    \"num_workers\": int,\n+    \"stop_bound\": float,\n+    \"timeout\": float,\n+    \"distance_to_best\": float,\n+    \"algorithm\": {\n+        \"type\": (\"bandit\", ),\n+        \"new_nodes_order\": (\"api\", \"random\", \"bound\", \"weighted_random\"),\n+        \"old_nodes_order\": (\"bound\", \"bandit\", \"weighted_random\"),\n+        \"threshold\": int,\n+        \"delta\": float,\n+        \"monte_carlo\": bool,\n+    },\n+}\n \n-key_list = [\"num_worker\", \"log_file\",  \"algorithm\", \"stop_bound\",\n-        \"timeout\", \"delta\", \"distance_to_best\", \"monte_carlo\",\"threshold\",\n-        \"new_nodes_order\", \"old_nodes_order\"]\n-search_list = [\"bound_order\", \"bandit\"]\n-new_order_list = [\"api\", \"random\", \"bound\", \"weighted_random\"]\n-old_order_list = [\"bound\", \"bandit\", \"weighted_random\"]\n-bool_list = [\"true\", \"false\"]\n+def check(value, *, path=(), spec=spec):\n+    \"\"\"Check that a value adheres to a specification.\n \n+    Entries in the specification can be:\n+      - A tuple of allowed values: the provided `value` must be one of these\n+      - A type: the provided `value` must have that type\n+      - A dict: the provided `value` must be a dict which has only keys defined\n+        in the `spec` (some of the `spec` keys may be missing from the `value`\n+        dict). Each provided value in the dict will be checked recursively with\n+        the corresponding entry in the spec.\n \n+    All entries in `value` are optional (i.e. can be `None`), unless the\n+    corresponding entry in the specification is a `dict`.\n+    \"\"\"\n \n-def create_setting_file(options_dict, filename):\n-    if not check_dict(options_dict):\n-        print(\"Invalid Options dict\")\n-        return\n-    formatted_opts = add_quotes(options_dict)\n-    with open(filename, 'w+') as f:\n-        for key, value in formatted_opts.items():\n-            f.write(\"{} = {}\\n\".format(key, value))\n-\n-def check_tuple(key, val):\n-    if key in [\"num_worker\", \"threshold\", \"timeout\"]:\n-        try:\n-            t = int(val)\n-            return True\n-        except:\n-            print(\"Key {} should get an int, got {}\".format(key, val))\n+    if isinstance(spec, dict):\n+        if not isinstance(value, dict):\n+            print(\"Key {} should be a dict; got {}\".format(\n+                \".\".join(path), value))\n             return False\n-    if key in [\"delta\", \"stop_bound\", \"distance_to_best\"]:\n-        try:\n-            t = float(val)\n+        unknown = set(value.keys()) - set(spec.keys())\n+        if unknown:\n+            print(\"Keys {} are missing\".format(\n+                \", \".join(\".\".join(path + (key, )) for key in unknown)))","path":"tools/tune_bandit/generate_setting_files.py","position":null,"original_position":69,"commit_id":"bacf5dafb426894a0c0ca403f76fc9bd107f1db5","original_commit_id":"ff63ae6fa44c1cc15419e9b000622c576d8bdc0d","user":{"login":"Elarnon","id":146210,"node_id":"MDQ6VXNlcjE0NjIxMA==","avatar_url":"https://avatars2.githubusercontent.com/u/146210?v=4","gravatar_id":"","url":"https://api.github.com/users/Elarnon","html_url":"https://github.com/Elarnon","followers_url":"https://api.github.com/users/Elarnon/followers","following_url":"https://api.github.com/users/Elarnon/following{/other_user}","gists_url":"https://api.github.com/users/Elarnon/gists{/gist_id}","starred_url":"https://api.github.com/users/Elarnon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Elarnon/subscriptions","organizations_url":"https://api.github.com/users/Elarnon/orgs","repos_url":"https://api.github.com/users/Elarnon/repos","events_url":"https://api.github.com/users/Elarnon/events{/privacy}","received_events_url":"https://api.github.com/users/Elarnon/received_events","type":"User","site_admin":false},"body":"Changed to use exceptions instead to avoid this type of mistakes.","created_at":"2018-07-05T09:46:05Z","updated_at":"2018-07-05T09:46:05Z","html_url":"https://github.com/ulysseB/telamon/pull/43#discussion_r200293496","pull_request_url":"https://api.github.com/repos/ulysseB/telamon/pulls/43","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ulysseB/telamon/pulls/comments/200293496"},"html":{"href":"https://github.com/ulysseB/telamon/pull/43#discussion_r200293496"},"pull_request":{"href":"https://api.github.com/repos/ulysseB/telamon/pulls/43"}},"in_reply_to_id":200278289},"pull_request":{"url":"https://api.github.com/repos/ulysseB/telamon/pulls/43","id":199387504,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5Mzg3NTA0","html_url":"https://github.com/ulysseB/telamon/pull/43","diff_url":"https://github.com/ulysseB/telamon/pull/43.diff","patch_url":"https://github.com/ulysseB/telamon/pull/43.patch","issue_url":"https://api.github.com/repos/ulysseB/telamon/issues/43","number":43,"state":"open","locked":false,"title":"Implement serde support for explorer::config::Config","user":{"login":"Elarnon","id":146210,"node_id":"MDQ6VXNlcjE0NjIxMA==","avatar_url":"https://avatars2.githubusercontent.com/u/146210?v=4","gravatar_id":"","url":"https://api.github.com/users/Elarnon","html_url":"https://github.com/Elarnon","followers_url":"https://api.github.com/users/Elarnon/followers","following_url":"https://api.github.com/users/Elarnon/following{/other_user}","gists_url":"https://api.github.com/users/Elarnon/gists{/gist_id}","starred_url":"https://api.github.com/users/Elarnon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Elarnon/subscriptions","organizations_url":"https://api.github.com/users/Elarnon/orgs","repos_url":"https://api.github.com/users/Elarnon/repos","events_url":"https://api.github.com/users/Elarnon/events{/privacy}","received_events_url":"https://api.github.com/users/Elarnon/received_events","type":"User","site_admin":false},"body":"Previously explorer::config::Config serialization and deserialization\r\nfrom the Settings.toml configuration file were implemented by\r\nhand. This makes it tedious and error-prone to add new configuration\r\nfields, especially when they require new structures or enums as will\r\nprobably be the case for future statistics and logging options.\r\n\r\nThis PR implements serialization and deserialization support for\r\nexplorer::config::Config and related inner\r\nstructures (explorer::config::SearchAlgorithm, etc.). The syntax of\r\nthe configuration file is identical as before, except that the\r\nalgorithm-related options are now under the [algorithm] key. This is\r\nrequired because serde doesn't support de-serializing \"flat\" enums\r\nwith a default value for missing entries. The `generate_settings_file`\r\nPython script is also updated to generate config files compatible with\r\nthe new format.\r\n\r\nThis means that sections such as:\r\n\r\n```\r\nalgorithm = \"bound_order\"\r\n```\r\n\r\nmust be replaced with:\r\n\r\n```\r\n[algorithm]\r\ntype = \"bound_order\"\r\n```\r\n\r\nand sections such as:\r\n\r\n```\r\nalgorithm = \"bandit\"\r\nmonte_carlo = false\r\nthreshold = 7\r\n```\r\n\r\nshould now be:\r\n\r\n```\r\n[algorithm]\r\ntype = \"bandit\"\r\nmonte_carlo = false\r\nthreshold = 7\r\n```\r\n\r\nArguably, this provides a better structure and separation\r\nof the config file.","created_at":"2018-07-05T08:01:06Z","updated_at":"2018-07-05T09:46:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f1cc60d87f5eef8de470cc5778819643c790294","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ulysseB","id":1461855,"node_id":"MDQ6VXNlcjE0NjE4NTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1461855?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysseB","html_url":"https://github.com/ulysseB","followers_url":"https://api.github.com/users/ulysseB/followers","following_url":"https://api.github.com/users/ulysseB/following{/other_user}","gists_url":"https://api.github.com/users/ulysseB/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysseB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysseB/subscriptions","organizations_url":"https://api.github.com/users/ulysseB/orgs","repos_url":"https://api.github.com/users/ulysseB/repos","events_url":"https://api.github.com/users/ulysseB/events{/privacy}","received_events_url":"https://api.github.com/users/ulysseB/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ulysseB/telamon/pulls/43/commits","review_comments_url":"https://api.github.com/repos/ulysseB/telamon/pulls/43/comments","review_comment_url":"https://api.github.com/repos/ulysseB/telamon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ulysseB/telamon/issues/43/comments","statuses_url":"https://api.github.com/repos/ulysseB/telamon/statuses/bacf5dafb426894a0c0ca403f76fc9bd107f1db5","head":{"label":"ulysseB:elarnon/serde_config","ref":"elarnon/serde_config","sha":"bacf5dafb426894a0c0ca403f76fc9bd107f1db5","user":{"login":"ulysseB","id":1461855,"node_id":"MDQ6VXNlcjE0NjE4NTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1461855?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysseB","html_url":"https://github.com/ulysseB","followers_url":"https://api.github.com/users/ulysseB/followers","following_url":"https://api.github.com/users/ulysseB/following{/other_user}","gists_url":"https://api.github.com/users/ulysseB/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysseB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysseB/subscriptions","organizations_url":"https://api.github.com/users/ulysseB/orgs","repos_url":"https://api.github.com/users/ulysseB/repos","events_url":"https://api.github.com/users/ulysseB/events{/privacy}","received_events_url":"https://api.github.com/users/ulysseB/received_events","type":"User","site_admin":false},"repo":{"id":125530367,"node_id":"MDEwOlJlcG9zaXRvcnkxMjU1MzAzNjc=","name":"telamon","full_name":"ulysseB/telamon","owner":{"login":"ulysseB","id":1461855,"node_id":"MDQ6VXNlcjE0NjE4NTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1461855?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysseB","html_url":"https://github.com/ulysseB","followers_url":"https://api.github.com/users/ulysseB/followers","following_url":"https://api.github.com/users/ulysseB/following{/other_user}","gists_url":"https://api.github.com/users/ulysseB/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysseB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysseB/subscriptions","organizations_url":"https://api.github.com/users/ulysseB/orgs","repos_url":"https://api.github.com/users/ulysseB/repos","events_url":"https://api.github.com/users/ulysseB/events{/privacy}","received_events_url":"https://api.github.com/users/ulysseB/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ulysseB/telamon","description":"A framework to find good combinations of optimizations for computational kernels on GPUs.","fork":false,"url":"https://api.github.com/repos/ulysseB/telamon","forks_url":"https://api.github.com/repos/ulysseB/telamon/forks","keys_url":"https://api.github.com/repos/ulysseB/telamon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ulysseB/telamon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ulysseB/telamon/teams","hooks_url":"https://api.github.com/repos/ulysseB/telamon/hooks","issue_events_url":"https://api.github.com/repos/ulysseB/telamon/issues/events{/number}","events_url":"https://api.github.com/repos/ulysseB/telamon/events","assignees_url":"https://api.github.com/repos/ulysseB/telamon/assignees{/user}","branches_url":"https://api.github.com/repos/ulysseB/telamon/branches{/branch}","tags_url":"https://api.github.com/repos/ulysseB/telamon/tags","blobs_url":"https://api.github.com/repos/ulysseB/telamon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ulysseB/telamon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ulysseB/telamon/git/refs{/sha}","trees_url":"https://api.github.com/repos/ulysseB/telamon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ulysseB/telamon/statuses/{sha}","languages_url":"https://api.github.com/repos/ulysseB/telamon/languages","stargazers_url":"https://api.github.com/repos/ulysseB/telamon/stargazers","contributors_url":"https://api.github.com/repos/ulysseB/telamon/contributors","subscribers_url":"https://api.github.com/repos/ulysseB/telamon/subscribers","subscription_url":"https://api.github.com/repos/ulysseB/telamon/subscription","commits_url":"https://api.github.com/repos/ulysseB/telamon/commits{/sha}","git_commits_url":"https://api.github.com/repos/ulysseB/telamon/git/commits{/sha}","comments_url":"https://api.github.com/repos/ulysseB/telamon/comments{/number}","issue_comment_url":"https://api.github.com/repos/ulysseB/telamon/issues/comments{/number}","contents_url":"https://api.github.com/repos/ulysseB/telamon/contents/{+path}","compare_url":"https://api.github.com/repos/ulysseB/telamon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ulysseB/telamon/merges","archive_url":"https://api.github.com/repos/ulysseB/telamon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ulysseB/telamon/downloads","issues_url":"https://api.github.com/repos/ulysseB/telamon/issues{/number}","pulls_url":"https://api.github.com/repos/ulysseB/telamon/pulls{/number}","milestones_url":"https://api.github.com/repos/ulysseB/telamon/milestones{/number}","notifications_url":"https://api.github.com/repos/ulysseB/telamon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ulysseB/telamon/labels{/name}","releases_url":"https://api.github.com/repos/ulysseB/telamon/releases{/id}","deployments_url":"https://api.github.com/repos/ulysseB/telamon/deployments","created_at":"2018-03-16T14:52:10Z","updated_at":"2018-07-05T09:41:45Z","pushed_at":"2018-07-05T09:45:12Z","git_url":"git://github.com/ulysseB/telamon.git","ssh_url":"git@github.com:ulysseB/telamon.git","clone_url":"https://github.com/ulysseB/telamon.git","svn_url":"https://github.com/ulysseB/telamon","homepage":"https://ulysseb.github.io/telamon/telamon","size":33028,"stargazers_count":5,"watchers_count":5,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":1,"open_issues":14,"watchers":5,"default_branch":"master"}},"base":{"label":"ulysseB:master","ref":"master","sha":"86d90fbbcf5595a500f28963f701f43a4e223e3d","user":{"login":"ulysseB","id":1461855,"node_id":"MDQ6VXNlcjE0NjE4NTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1461855?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysseB","html_url":"https://github.com/ulysseB","followers_url":"https://api.github.com/users/ulysseB/followers","following_url":"https://api.github.com/users/ulysseB/following{/other_user}","gists_url":"https://api.github.com/users/ulysseB/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysseB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysseB/subscriptions","organizations_url":"https://api.github.com/users/ulysseB/orgs","repos_url":"https://api.github.com/users/ulysseB/repos","events_url":"https://api.github.com/users/ulysseB/events{/privacy}","received_events_url":"https://api.github.com/users/ulysseB/received_events","type":"User","site_admin":false},"repo":{"id":125530367,"node_id":"MDEwOlJlcG9zaXRvcnkxMjU1MzAzNjc=","name":"telamon","full_name":"ulysseB/telamon","owner":{"login":"ulysseB","id":1461855,"node_id":"MDQ6VXNlcjE0NjE4NTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1461855?v=4","gravatar_id":"","url":"https://api.github.com/users/ulysseB","html_url":"https://github.com/ulysseB","followers_url":"https://api.github.com/users/ulysseB/followers","following_url":"https://api.github.com/users/ulysseB/following{/other_user}","gists_url":"https://api.github.com/users/ulysseB/gists{/gist_id}","starred_url":"https://api.github.com/users/ulysseB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulysseB/subscriptions","organizations_url":"https://api.github.com/users/ulysseB/orgs","repos_url":"https://api.github.com/users/ulysseB/repos","events_url":"https://api.github.com/users/ulysseB/events{/privacy}","received_events_url":"https://api.github.com/users/ulysseB/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ulysseB/telamon","description":"A framework to find good combinations of optimizations for computational kernels on GPUs.","fork":false,"url":"https://api.github.com/repos/ulysseB/telamon","forks_url":"https://api.github.com/repos/ulysseB/telamon/forks","keys_url":"https://api.github.com/repos/ulysseB/telamon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ulysseB/telamon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ulysseB/telamon/teams","hooks_url":"https://api.github.com/repos/ulysseB/telamon/hooks","issue_events_url":"https://api.github.com/repos/ulysseB/telamon/issues/events{/number}","events_url":"https://api.github.com/repos/ulysseB/telamon/events","assignees_url":"https://api.github.com/repos/ulysseB/telamon/assignees{/user}","branches_url":"https://api.github.com/repos/ulysseB/telamon/branches{/branch}","tags_url":"https://api.github.com/repos/ulysseB/telamon/tags","blobs_url":"https://api.github.com/repos/ulysseB/telamon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ulysseB/telamon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ulysseB/telamon/git/refs{/sha}","trees_url":"https://api.github.com/repos/ulysseB/telamon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ulysseB/telamon/statuses/{sha}","languages_url":"https://api.github.com/repos/ulysseB/telamon/languages","stargazers_url":"https://api.github.com/repos/ulysseB/telamon/stargazers","contributors_url":"https://api.github.com/repos/ulysseB/telamon/contributors","subscribers_url":"https://api.github.com/repos/ulysseB/telamon/subscribers","subscription_url":"https://api.github.com/repos/ulysseB/telamon/subscription","commits_url":"https://api.github.com/repos/ulysseB/telamon/commits{/sha}","git_commits_url":"https://api.github.com/repos/ulysseB/telamon/git/commits{/sha}","comments_url":"https://api.github.com/repos/ulysseB/telamon/comments{/number}","issue_comment_url":"https://api.github.com/repos/ulysseB/telamon/issues/comments{/number}","contents_url":"https://api.github.com/repos/ulysseB/telamon/contents/{+path}","compare_url":"https://api.github.com/repos/ulysseB/telamon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ulysseB/telamon/merges","archive_url":"https://api.github.com/repos/ulysseB/telamon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ulysseB/telamon/downloads","issues_url":"https://api.github.com/repos/ulysseB/telamon/issues{/number}","pulls_url":"https://api.github.com/repos/ulysseB/telamon/pulls{/number}","milestones_url":"https://api.github.com/repos/ulysseB/telamon/milestones{/number}","notifications_url":"https://api.github.com/repos/ulysseB/telamon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ulysseB/telamon/labels{/name}","releases_url":"https://api.github.com/repos/ulysseB/telamon/releases{/id}","deployments_url":"https://api.github.com/repos/ulysseB/telamon/deployments","created_at":"2018-03-16T14:52:10Z","updated_at":"2018-07-05T09:41:45Z","pushed_at":"2018-07-05T09:45:12Z","git_url":"git://github.com/ulysseB/telamon.git","ssh_url":"git@github.com:ulysseB/telamon.git","clone_url":"https://github.com/ulysseB/telamon.git","svn_url":"https://github.com/ulysseB/telamon","homepage":"https://ulysseb.github.io/telamon/telamon","size":33028,"stargazers_count":5,"watchers_count":5,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":1,"open_issues":14,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ulysseB/telamon/pulls/43"},"html":{"href":"https://github.com/ulysseB/telamon/pull/43"},"issue":{"href":"https://api.github.com/repos/ulysseB/telamon/issues/43"},"comments":{"href":"https://api.github.com/repos/ulysseB/telamon/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/ulysseB/telamon/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/ulysseB/telamon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ulysseB/telamon/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/ulysseB/telamon/statuses/bacf5dafb426894a0c0ca403f76fc9bd107f1db5"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Elarnon"}}