{"action":"created","comment":{"url":"https://api.github.com/repos/uwsampl/relay-bench/pulls/comments/353484844","pull_request_review_id":326526338,"id":353484844,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM1MzQ4NDg0NA==","diff_hunk":"@@ -0,0 +1,97 @@\n+import subprocess\n+import threading\n+import argparse\n+import datetime\n+import sys\n+import os\n+\n+\n+def parse_cpu_stat(info:list) -> dict:\n+    '''\n+    Takes data returned by sensors, which contains temperature / voltage data.\n+    Returns a dict, whose keys are (group) name of the sensors and values are pairs of (label x data).\n+    '''\n+    current_group = 'ungrouped'\n+    result = dict({ current_group : [] })\n+    for line in info:\n+        # omit empty lines and `N/A` data\n+        if line and not 'N/A' in line:\n+            # Adapter names does not contain spaces\n+            if ' ' not in line:\n+                current_group = line\n+                result.update({ line : [] })\n+            else:\n+                label, data = ' '.join(line.split()).split()[:2]\n+                result[current_group].append((label.replace(':', ''), ''.join(data)))\n+    # return with empty entries removed\n+    return dict(filter(lambda x: len(x[1]), result.items()))\n+\n+def parse_gpu_stat(info:list) -> list:\n+    '''\n+    Takes data returned by `nvidia-smi`, which contains a string with two lines, returns\n+    the last line, which is the data we need to monitor during an experiment.\n+    '''\n+    filtered = list(filter(lambda x: x, info))\n+    # ensure the list is not empty\n+    assert filtered\n+    return filtered[-1].split(', ')\n+\n+def start_job(fp_dir, nvidia_fields, time_span, time_run) -> None:\n+    '''\n+    A chornological job, runs every `time_span` seconds.\n+    Fetches data from `nvidia-smi` and `sensors`, then parse it\n+    and write to corresponding files. Data will not be processed\n+    during monitoring in order to minimize the influence to the running experiments.\n+\n+    Note: The process will be halted by `dashboard.py` when an experiment ends. \n+    '''\n+    threading.Timer(time_span, start_job, args=[fp_dir, nvidia_fields, time_span, time_run + 1]).start()\n+    nvidia_smi = subprocess.run(['nvidia-smi', '--format=csv', '--query-gpu={}'.format(','.join(nvidia_fields))],\n+                            stdout=subprocess.PIPE, timeout=10)\n+    parsed_data = parse_gpu_stat(nvidia_smi.stdout.decode().split('\\n'))\n+    # The length of lists of data should be the same\n+    # since we are using `nvidia_fields` to call the command\n+    assert len(parsed_data) == len(nvidia_fields)\n+    # timestamp = parsed_data[0]\n+    time_after = time_span * time_run\n+    for filename, data in zip(nvidia_fields[1:], parsed_data[1:]):\n+        with open(os.path.join(fp_dir, 'gpu', filename), 'a+') as fp:\n+            # fp.write(f'{timestamp[:-4]} {data}\\n')\n+            fp.write(f'{time_after} {data}\\n')\n+\n+    sensors = subprocess.run(['sensors'], stdout=subprocess.PIPE)\n+    cpu_stat = parse_cpu_stat(sensors.stdout.decode().split('\\n'))\n+    # timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n+    for (fname, entries) in cpu_stat.items():\n+        if entries[1:]:\n+            with open(os.path.join(fp_dir, 'cpu', fname), 'a+') as fp:\n+                for (label, data) in entries[1:]:\n+                    # fp.write(f'{timestamp} {label} {data}\\n')\n+                    fp.write(f'{time_after} {label} {data}\\n')\n+\n+def main(args):","path":"telemetry/run.py","position":72,"original_position":72,"commit_id":"5e28a0bc5df387fa2a73a2a71606402ee828ee64","original_commit_id":"5e28a0bc5df387fa2a73a2a71606402ee828ee64","user":{"login":"slyubomirsky","id":5624871,"node_id":"MDQ6VXNlcjU2MjQ4NzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5624871?v=4","gravatar_id":"","url":"https://api.github.com/users/slyubomirsky","html_url":"https://github.com/slyubomirsky","followers_url":"https://api.github.com/users/slyubomirsky/followers","following_url":"https://api.github.com/users/slyubomirsky/following{/other_user}","gists_url":"https://api.github.com/users/slyubomirsky/gists{/gist_id}","starred_url":"https://api.github.com/users/slyubomirsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slyubomirsky/subscriptions","organizations_url":"https://api.github.com/users/slyubomirsky/orgs","repos_url":"https://api.github.com/users/slyubomirsky/repos","events_url":"https://api.github.com/users/slyubomirsky/events{/privacy}","received_events_url":"https://api.github.com/users/slyubomirsky/received_events","type":"User","site_admin":false},"body":"Something you could do to make your life easier would be to make use of some of the functions in `shared`, such as `invoke_main` and the `DashboardInfo` class. This way, you could reduce the boilerplate and centralize the logic that has to do with figuring out directories (very error-prone)","created_at":"2019-12-03T23:54:09Z","updated_at":"2019-12-03T23:54:09Z","html_url":"https://github.com/uwsampl/relay-bench/pull/48#discussion_r353484844","pull_request_url":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/uwsampl/relay-bench/pulls/comments/353484844"},"html":{"href":"https://github.com/uwsampl/relay-bench/pull/48#discussion_r353484844"},"pull_request":{"href":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48","id":342903672,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQyOTAzNjcy","html_url":"https://github.com/uwsampl/relay-bench/pull/48","diff_url":"https://github.com/uwsampl/relay-bench/pull/48.diff","patch_url":"https://github.com/uwsampl/relay-bench/pull/48.patch","issue_url":"https://api.github.com/repos/uwsampl/relay-bench/issues/48","number":48,"state":"open","locked":false,"title":"[ add ] telemetry for CPU/GPU #42 & Pin processes for experiments use CPU","user":{"login":"AD1024","id":12641212,"node_id":"MDQ6VXNlcjEyNjQxMjEy","avatar_url":"https://avatars3.githubusercontent.com/u/12641212?v=4","gravatar_id":"","url":"https://api.github.com/users/AD1024","html_url":"https://github.com/AD1024","followers_url":"https://api.github.com/users/AD1024/followers","following_url":"https://api.github.com/users/AD1024/following{/other_user}","gists_url":"https://api.github.com/users/AD1024/gists{/gist_id}","starred_url":"https://api.github.com/users/AD1024/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AD1024/subscriptions","organizations_url":"https://api.github.com/users/AD1024/orgs","repos_url":"https://api.github.com/users/AD1024/repos","events_url":"https://api.github.com/users/AD1024/events{/privacy}","received_events_url":"https://api.github.com/users/AD1024/received_events","type":"User","site_admin":false},"body":"Changes:\r\nImplemented issue #42 (Thank you for the information Bill)\r\n- A standalone telemetry process\r\n- A new subsystem for generating graphs using data collected by the telemetry process\r\n- Pinning processes to a single core complex (attempt to improve reproducibility)\r\n\r\nChange details:\r\n1. The telemetry process will only grab data to temporary directory. The data is **unprocessed** and not formatted. After each experiment ends, the data will be parsed into json file and stored in the `results` folder. \r\n2. The graph generator will first save the graphs into `results/telemetry`, where all historical graphs are held, and then copy and **overwrite** those in `graphs` folder, where graphs that will be included in the generated webpage.\r\n\r\nNote: Add a new field to top-level `config.json` (noted in README)","created_at":"2019-11-19T21:35:56Z","updated_at":"2019-12-03T23:54:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"974bd3b60dba0140d0bfd75fef8dea8cf8808bf2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48/commits","review_comments_url":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48/comments","review_comment_url":"https://api.github.com/repos/uwsampl/relay-bench/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uwsampl/relay-bench/issues/48/comments","statuses_url":"https://api.github.com/repos/uwsampl/relay-bench/statuses/5e28a0bc5df387fa2a73a2a71606402ee828ee64","head":{"label":"AD1024:master","ref":"master","sha":"5e28a0bc5df387fa2a73a2a71606402ee828ee64","user":{"login":"AD1024","id":12641212,"node_id":"MDQ6VXNlcjEyNjQxMjEy","avatar_url":"https://avatars3.githubusercontent.com/u/12641212?v=4","gravatar_id":"","url":"https://api.github.com/users/AD1024","html_url":"https://github.com/AD1024","followers_url":"https://api.github.com/users/AD1024/followers","following_url":"https://api.github.com/users/AD1024/following{/other_user}","gists_url":"https://api.github.com/users/AD1024/gists{/gist_id}","starred_url":"https://api.github.com/users/AD1024/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AD1024/subscriptions","organizations_url":"https://api.github.com/users/AD1024/orgs","repos_url":"https://api.github.com/users/AD1024/repos","events_url":"https://api.github.com/users/AD1024/events{/privacy}","received_events_url":"https://api.github.com/users/AD1024/received_events","type":"User","site_admin":false},"repo":{"id":215464827,"node_id":"MDEwOlJlcG9zaXRvcnkyMTU0NjQ4Mjc=","name":"relay-bench","full_name":"AD1024/relay-bench","private":false,"owner":{"login":"AD1024","id":12641212,"node_id":"MDQ6VXNlcjEyNjQxMjEy","avatar_url":"https://avatars3.githubusercontent.com/u/12641212?v=4","gravatar_id":"","url":"https://api.github.com/users/AD1024","html_url":"https://github.com/AD1024","followers_url":"https://api.github.com/users/AD1024/followers","following_url":"https://api.github.com/users/AD1024/following{/other_user}","gists_url":"https://api.github.com/users/AD1024/gists{/gist_id}","starred_url":"https://api.github.com/users/AD1024/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AD1024/subscriptions","organizations_url":"https://api.github.com/users/AD1024/orgs","repos_url":"https://api.github.com/users/AD1024/repos","events_url":"https://api.github.com/users/AD1024/events{/privacy}","received_events_url":"https://api.github.com/users/AD1024/received_events","type":"User","site_admin":false},"html_url":"https://github.com/AD1024/relay-bench","description":"A repository containing examples and benchmarks for Relay.","fork":true,"url":"https://api.github.com/repos/AD1024/relay-bench","forks_url":"https://api.github.com/repos/AD1024/relay-bench/forks","keys_url":"https://api.github.com/repos/AD1024/relay-bench/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AD1024/relay-bench/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AD1024/relay-bench/teams","hooks_url":"https://api.github.com/repos/AD1024/relay-bench/hooks","issue_events_url":"https://api.github.com/repos/AD1024/relay-bench/issues/events{/number}","events_url":"https://api.github.com/repos/AD1024/relay-bench/events","assignees_url":"https://api.github.com/repos/AD1024/relay-bench/assignees{/user}","branches_url":"https://api.github.com/repos/AD1024/relay-bench/branches{/branch}","tags_url":"https://api.github.com/repos/AD1024/relay-bench/tags","blobs_url":"https://api.github.com/repos/AD1024/relay-bench/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AD1024/relay-bench/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AD1024/relay-bench/git/refs{/sha}","trees_url":"https://api.github.com/repos/AD1024/relay-bench/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AD1024/relay-bench/statuses/{sha}","languages_url":"https://api.github.com/repos/AD1024/relay-bench/languages","stargazers_url":"https://api.github.com/repos/AD1024/relay-bench/stargazers","contributors_url":"https://api.github.com/repos/AD1024/relay-bench/contributors","subscribers_url":"https://api.github.com/repos/AD1024/relay-bench/subscribers","subscription_url":"https://api.github.com/repos/AD1024/relay-bench/subscription","commits_url":"https://api.github.com/repos/AD1024/relay-bench/commits{/sha}","git_commits_url":"https://api.github.com/repos/AD1024/relay-bench/git/commits{/sha}","comments_url":"https://api.github.com/repos/AD1024/relay-bench/comments{/number}","issue_comment_url":"https://api.github.com/repos/AD1024/relay-bench/issues/comments{/number}","contents_url":"https://api.github.com/repos/AD1024/relay-bench/contents/{+path}","compare_url":"https://api.github.com/repos/AD1024/relay-bench/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AD1024/relay-bench/merges","archive_url":"https://api.github.com/repos/AD1024/relay-bench/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AD1024/relay-bench/downloads","issues_url":"https://api.github.com/repos/AD1024/relay-bench/issues{/number}","pulls_url":"https://api.github.com/repos/AD1024/relay-bench/pulls{/number}","milestones_url":"https://api.github.com/repos/AD1024/relay-bench/milestones{/number}","notifications_url":"https://api.github.com/repos/AD1024/relay-bench/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AD1024/relay-bench/labels{/name}","releases_url":"https://api.github.com/repos/AD1024/relay-bench/releases{/id}","deployments_url":"https://api.github.com/repos/AD1024/relay-bench/deployments","created_at":"2019-10-16T05:32:59Z","updated_at":"2019-11-29T00:49:21Z","pushed_at":"2019-11-29T00:49:19Z","git_url":"git://github.com/AD1024/relay-bench.git","ssh_url":"git@github.com:AD1024/relay-bench.git","clone_url":"https://github.com/AD1024/relay-bench.git","svn_url":"https://github.com/AD1024/relay-bench","homepage":null,"size":80167,"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,"disabled":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":"uwsampl:master","ref":"master","sha":"af279a3f8b5d5ef9dad1ef68e319ca62b3183a1a","user":{"login":"uwsampl","id":36750547,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NzUwNTQ3","avatar_url":"https://avatars0.githubusercontent.com/u/36750547?v=4","gravatar_id":"","url":"https://api.github.com/users/uwsampl","html_url":"https://github.com/uwsampl","followers_url":"https://api.github.com/users/uwsampl/followers","following_url":"https://api.github.com/users/uwsampl/following{/other_user}","gists_url":"https://api.github.com/users/uwsampl/gists{/gist_id}","starred_url":"https://api.github.com/users/uwsampl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwsampl/subscriptions","organizations_url":"https://api.github.com/users/uwsampl/orgs","repos_url":"https://api.github.com/users/uwsampl/repos","events_url":"https://api.github.com/users/uwsampl/events{/privacy}","received_events_url":"https://api.github.com/users/uwsampl/received_events","type":"Organization","site_admin":false},"repo":{"id":137016402,"node_id":"MDEwOlJlcG9zaXRvcnkxMzcwMTY0MDI=","name":"relay-bench","full_name":"uwsampl/relay-bench","private":false,"owner":{"login":"uwsampl","id":36750547,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NzUwNTQ3","avatar_url":"https://avatars0.githubusercontent.com/u/36750547?v=4","gravatar_id":"","url":"https://api.github.com/users/uwsampl","html_url":"https://github.com/uwsampl","followers_url":"https://api.github.com/users/uwsampl/followers","following_url":"https://api.github.com/users/uwsampl/following{/other_user}","gists_url":"https://api.github.com/users/uwsampl/gists{/gist_id}","starred_url":"https://api.github.com/users/uwsampl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uwsampl/subscriptions","organizations_url":"https://api.github.com/users/uwsampl/orgs","repos_url":"https://api.github.com/users/uwsampl/repos","events_url":"https://api.github.com/users/uwsampl/events{/privacy}","received_events_url":"https://api.github.com/users/uwsampl/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/uwsampl/relay-bench","description":"A repository containing examples and benchmarks for Relay.","fork":false,"url":"https://api.github.com/repos/uwsampl/relay-bench","forks_url":"https://api.github.com/repos/uwsampl/relay-bench/forks","keys_url":"https://api.github.com/repos/uwsampl/relay-bench/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uwsampl/relay-bench/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uwsampl/relay-bench/teams","hooks_url":"https://api.github.com/repos/uwsampl/relay-bench/hooks","issue_events_url":"https://api.github.com/repos/uwsampl/relay-bench/issues/events{/number}","events_url":"https://api.github.com/repos/uwsampl/relay-bench/events","assignees_url":"https://api.github.com/repos/uwsampl/relay-bench/assignees{/user}","branches_url":"https://api.github.com/repos/uwsampl/relay-bench/branches{/branch}","tags_url":"https://api.github.com/repos/uwsampl/relay-bench/tags","blobs_url":"https://api.github.com/repos/uwsampl/relay-bench/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uwsampl/relay-bench/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uwsampl/relay-bench/git/refs{/sha}","trees_url":"https://api.github.com/repos/uwsampl/relay-bench/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uwsampl/relay-bench/statuses/{sha}","languages_url":"https://api.github.com/repos/uwsampl/relay-bench/languages","stargazers_url":"https://api.github.com/repos/uwsampl/relay-bench/stargazers","contributors_url":"https://api.github.com/repos/uwsampl/relay-bench/contributors","subscribers_url":"https://api.github.com/repos/uwsampl/relay-bench/subscribers","subscription_url":"https://api.github.com/repos/uwsampl/relay-bench/subscription","commits_url":"https://api.github.com/repos/uwsampl/relay-bench/commits{/sha}","git_commits_url":"https://api.github.com/repos/uwsampl/relay-bench/git/commits{/sha}","comments_url":"https://api.github.com/repos/uwsampl/relay-bench/comments{/number}","issue_comment_url":"https://api.github.com/repos/uwsampl/relay-bench/issues/comments{/number}","contents_url":"https://api.github.com/repos/uwsampl/relay-bench/contents/{+path}","compare_url":"https://api.github.com/repos/uwsampl/relay-bench/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uwsampl/relay-bench/merges","archive_url":"https://api.github.com/repos/uwsampl/relay-bench/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uwsampl/relay-bench/downloads","issues_url":"https://api.github.com/repos/uwsampl/relay-bench/issues{/number}","pulls_url":"https://api.github.com/repos/uwsampl/relay-bench/pulls{/number}","milestones_url":"https://api.github.com/repos/uwsampl/relay-bench/milestones{/number}","notifications_url":"https://api.github.com/repos/uwsampl/relay-bench/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uwsampl/relay-bench/labels{/name}","releases_url":"https://api.github.com/repos/uwsampl/relay-bench/releases{/id}","deployments_url":"https://api.github.com/repos/uwsampl/relay-bench/deployments","created_at":"2018-06-12T04:20:45Z","updated_at":"2019-11-19T07:04:56Z","pushed_at":"2019-11-29T00:49:21Z","git_url":"git://github.com/uwsampl/relay-bench.git","ssh_url":"git@github.com:uwsampl/relay-bench.git","clone_url":"https://github.com/uwsampl/relay-bench.git","svn_url":"https://github.com/uwsampl/relay-bench","homepage":null,"size":80059,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":5,"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":3,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48"},"html":{"href":"https://github.com/uwsampl/relay-bench/pull/48"},"issue":{"href":"https://api.github.com/repos/uwsampl/relay-bench/issues/48"},"comments":{"href":"https://api.github.com/repos/uwsampl/relay-bench/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/uwsampl/relay-bench/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uwsampl/relay-bench/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/uwsampl/relay-bench/statuses/5e28a0bc5df387fa2a73a2a71606402ee828ee64"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"slyubomirsky"}}