{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/carto-python/pulls/comments/211969530","pull_request_review_id":148501062,"id":211969530,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTk2OTUzMA==","diff_hunk":"@@ -0,0 +1,160 @@\n+import logging\n+from datetime import datetime, timedelta\n+import os\n+import sys\n+import argparse\n+\n+from carto.auth import APIKeyAuthClient\n+from carto.sql import SQLClient\n+from carto.sql import CopySQLClient\n+\n+import numpy as np\n+from siphon.radarserver import RadarServer\n+from siphon.cdmr import Dataset\n+\n+# Example of CopySQLClient usage to stream data from NEXRAD Level 2\n+# data to CARTO.\n+#\n+# For more information see the following URL's:\n+#   - https://carto.com/blog/mapping-nexrad-radar-data/\n+#   - https://gist.github.com/stuartlynn/a7868cf8ca02931a6408\n+#   - http://nbviewer.jupyter.org/gist/dopplershift/356f2e14832e9b676207\n+\n+# Set up our own logger after cleaning up siphon's one\n+logger = logging.getLogger()\n+list(map(logger.removeHandler, logger.handlers[:]))\n+ch = logging.StreamHandler()\n+formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')\n+ch.setFormatter(formatter)\n+logger.addHandler(ch)\n+logger.setLevel(logging.INFO)\n+\n+# Parse input arguments\n+parser = argparse.ArgumentParser(description=(\n+    'Example of CopySQLClient usage to stream data from NEXRAD Level 2'\n+    ' data to CARTO.'\n+))\n+\n+parser.add_argument('--base_url', type=str, dest='CARTO_BASE_URL',\n+                    default=os.environ.get('CARTO_API_URL', ''),\n+                    help=('Set the base URL. For example:'\n+                          ' https://username.carto.com/'\n+                          ' (defaults to env variable CARTO_API_URL)'))\n+\n+parser.add_argument('--api_key', dest='CARTO_API_KEY',\n+                    default=os.environ.get('CARTO_API_KEY', ''),\n+                    help=('Api key of the account'\n+                          ' (defaults to env variable CARTO_API_KEY)'))\n+\n+args = parser.parse_args()\n+\n+if not args.CARTO_BASE_URL or not args.CARTO_API_KEY:\n+    sys.exit(parser.print_usage())\n+\n+auth_client = APIKeyAuthClient(args.CARTO_BASE_URL, args.CARTO_API_KEY)\n+sql_client = SQLClient(auth_client)\n+copy_client = CopySQLClient(auth_client)\n+\n+# Create a table suitable to receive the data\n+logger.info('Creating table nexrad_copy_example...')\n+sql_client.send(\"\"\"CREATE TABLE IF NOT EXISTS nexrad_copy_example (\n+  the_geom geometry(Geometry,4326),\n+  reflectivity numeric\n+)\"\"\")\n+sql_client.send(\n+    \"SELECT CDB_CartodbfyTable(current_schema, 'nexrad_copy_example')\")\n+logger.info('Done')\n+\n+logger.info('Trying to connect to the THREDDS radar query service')\n+rs = RadarServer(\n+    'http://thredds.ucar.edu/thredds/radarServer/nexrad/level2/IDD/')\n+\n+logger.info('Quering data from the station')\n+query = rs.query()\n+query.stations('KLVX').time(datetime.utcnow())","path":"examples/nexrad/nexrad_copy.py","position":74,"original_position":74,"commit_id":"43b13111220c628602706bd969b32f5502e08821","original_commit_id":"43b13111220c628602706bd969b32f5502e08821","user":{"login":"jgoizueta","id":5909,"node_id":"MDQ6VXNlcjU5MDk=","avatar_url":"https://avatars3.githubusercontent.com/u/5909?v=4","gravatar_id":"","url":"https://api.github.com/users/jgoizueta","html_url":"https://github.com/jgoizueta","followers_url":"https://api.github.com/users/jgoizueta/followers","following_url":"https://api.github.com/users/jgoizueta/following{/other_user}","gists_url":"https://api.github.com/users/jgoizueta/gists{/gist_id}","starred_url":"https://api.github.com/users/jgoizueta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgoizueta/subscriptions","organizations_url":"https://api.github.com/users/jgoizueta/orgs","repos_url":"https://api.github.com/users/jgoizueta/repos","events_url":"https://api.github.com/users/jgoizueta/events{/privacy}","received_events_url":"https://api.github.com/users/jgoizueta/received_events","type":"User","site_admin":false},"body":"Maybe a brief comment in the README pointing to here (so that users can play with different stations/times easily) would be nice","created_at":"2018-08-22T14:12:38Z","updated_at":"2018-08-22T14:12:38Z","html_url":"https://github.com/CartoDB/carto-python/pull/93#discussion_r211969530","pull_request_url":"https://api.github.com/repos/CartoDB/carto-python/pulls/93","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/carto-python/pulls/comments/211969530"},"html":{"href":"https://github.com/CartoDB/carto-python/pull/93#discussion_r211969530"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/carto-python/pulls/93"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/carto-python/pulls/93","id":210058840,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwMDU4ODQw","html_url":"https://github.com/CartoDB/carto-python/pull/93","diff_url":"https://github.com/CartoDB/carto-python/pull/93.diff","patch_url":"https://github.com/CartoDB/carto-python/pull/93.patch","issue_url":"https://api.github.com/repos/CartoDB/carto-python/issues/93","number":93,"state":"open","locked":false,"title":"Add NEXRAD COPY example","user":{"login":"rafatower","id":1914276,"node_id":"MDQ6VXNlcjE5MTQyNzY=","avatar_url":"https://avatars1.githubusercontent.com/u/1914276?v=4","gravatar_id":"","url":"https://api.github.com/users/rafatower","html_url":"https://github.com/rafatower","followers_url":"https://api.github.com/users/rafatower/followers","following_url":"https://api.github.com/users/rafatower/following{/other_user}","gists_url":"https://api.github.com/users/rafatower/gists{/gist_id}","starred_url":"https://api.github.com/users/rafatower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafatower/subscriptions","organizations_url":"https://api.github.com/users/rafatower/orgs","repos_url":"https://api.github.com/users/rafatower/repos","events_url":"https://api.github.com/users/rafatower/events{/privacy}","received_events_url":"https://api.github.com/users/rafatower/received_events","type":"User","site_admin":false},"body":"This is an example about how to use the `CopySQLClient` to stream data from an external service, in this case NEXRAD Level 2 radar data, to a CARTO table.\r\n\r\nI created it in a separate directory, in order not to pollute the dependencies of the other examples, cause it requires `numpy` and `siphon` (which in turns requires `pandas`) and those packages need native dependencies that might be tricky to get installed.","created_at":"2018-08-22T08:40:15Z","updated_at":"2018-08-22T14:12:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10777248aaf179ed439b5388230e2fa05252295a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"alrocar","id":623650,"node_id":"MDQ6VXNlcjYyMzY1MA==","avatar_url":"https://avatars0.githubusercontent.com/u/623650?v=4","gravatar_id":"","url":"https://api.github.com/users/alrocar","html_url":"https://github.com/alrocar","followers_url":"https://api.github.com/users/alrocar/followers","following_url":"https://api.github.com/users/alrocar/following{/other_user}","gists_url":"https://api.github.com/users/alrocar/gists{/gist_id}","starred_url":"https://api.github.com/users/alrocar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alrocar/subscriptions","organizations_url":"https://api.github.com/users/alrocar/orgs","repos_url":"https://api.github.com/users/alrocar/repos","events_url":"https://api.github.com/users/alrocar/events{/privacy}","received_events_url":"https://api.github.com/users/alrocar/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":922786997,"node_id":"MDU6TGFiZWw5MjI3ODY5OTc=","url":"https://api.github.com/repos/CartoDB/carto-python/labels/enhancement","name":"enhancement","color":"79fcdd","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/carto-python/pulls/93/commits","review_comments_url":"https://api.github.com/repos/CartoDB/carto-python/pulls/93/comments","review_comment_url":"https://api.github.com/repos/CartoDB/carto-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CartoDB/carto-python/issues/93/comments","statuses_url":"https://api.github.com/repos/CartoDB/carto-python/statuses/43b13111220c628602706bd969b32f5502e08821","head":{"label":"CartoDB:nexrad-example","ref":"nexrad-example","sha":"43b13111220c628602706bd969b32f5502e08821","user":{"login":"CartoDB","id":1799254,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTkyNTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1799254?v=4","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":1631632,"node_id":"MDEwOlJlcG9zaXRvcnkxNjMxNjMy","name":"carto-python","full_name":"CartoDB/carto-python","owner":{"login":"CartoDB","id":1799254,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTkyNTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1799254?v=4","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/carto-python","description":"CARTO Python client","fork":false,"url":"https://api.github.com/repos/CartoDB/carto-python","forks_url":"https://api.github.com/repos/CartoDB/carto-python/forks","keys_url":"https://api.github.com/repos/CartoDB/carto-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/carto-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/carto-python/teams","hooks_url":"https://api.github.com/repos/CartoDB/carto-python/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/carto-python/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/carto-python/events","assignees_url":"https://api.github.com/repos/CartoDB/carto-python/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/carto-python/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/carto-python/tags","blobs_url":"https://api.github.com/repos/CartoDB/carto-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/carto-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/carto-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/carto-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/carto-python/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/carto-python/languages","stargazers_url":"https://api.github.com/repos/CartoDB/carto-python/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/carto-python/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/carto-python/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/carto-python/subscription","commits_url":"https://api.github.com/repos/CartoDB/carto-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/carto-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/carto-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/carto-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/carto-python/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/carto-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/carto-python/merges","archive_url":"https://api.github.com/repos/CartoDB/carto-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/carto-python/downloads","issues_url":"https://api.github.com/repos/CartoDB/carto-python/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/carto-python/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/carto-python/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/carto-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/carto-python/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/carto-python/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/carto-python/deployments","created_at":"2011-04-18T17:20:01Z","updated_at":"2018-08-21T08:49:06Z","pushed_at":"2018-08-22T10:07:22Z","git_url":"git://github.com/CartoDB/carto-python.git","ssh_url":"git@github.com:CartoDB/carto-python.git","clone_url":"https://github.com/CartoDB/carto-python.git","svn_url":"https://github.com/CartoDB/carto-python","homepage":"https://carto.com","size":1324,"stargazers_count":112,"watchers_count":112,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":49,"open_issues":7,"watchers":112,"default_branch":"master"}},"base":{"label":"CartoDB:master","ref":"master","sha":"bf8506a8fe0cb93eac54ada0f23a5270395204d2","user":{"login":"CartoDB","id":1799254,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTkyNTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1799254?v=4","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":1631632,"node_id":"MDEwOlJlcG9zaXRvcnkxNjMxNjMy","name":"carto-python","full_name":"CartoDB/carto-python","owner":{"login":"CartoDB","id":1799254,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTkyNTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1799254?v=4","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/carto-python","description":"CARTO Python client","fork":false,"url":"https://api.github.com/repos/CartoDB/carto-python","forks_url":"https://api.github.com/repos/CartoDB/carto-python/forks","keys_url":"https://api.github.com/repos/CartoDB/carto-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/carto-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/carto-python/teams","hooks_url":"https://api.github.com/repos/CartoDB/carto-python/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/carto-python/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/carto-python/events","assignees_url":"https://api.github.com/repos/CartoDB/carto-python/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/carto-python/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/carto-python/tags","blobs_url":"https://api.github.com/repos/CartoDB/carto-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/carto-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/carto-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/carto-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/carto-python/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/carto-python/languages","stargazers_url":"https://api.github.com/repos/CartoDB/carto-python/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/carto-python/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/carto-python/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/carto-python/subscription","commits_url":"https://api.github.com/repos/CartoDB/carto-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/carto-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/carto-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/carto-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/carto-python/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/carto-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/carto-python/merges","archive_url":"https://api.github.com/repos/CartoDB/carto-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/carto-python/downloads","issues_url":"https://api.github.com/repos/CartoDB/carto-python/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/carto-python/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/carto-python/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/carto-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/carto-python/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/carto-python/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/carto-python/deployments","created_at":"2011-04-18T17:20:01Z","updated_at":"2018-08-21T08:49:06Z","pushed_at":"2018-08-22T10:07:22Z","git_url":"git://github.com/CartoDB/carto-python.git","ssh_url":"git@github.com:CartoDB/carto-python.git","clone_url":"https://github.com/CartoDB/carto-python.git","svn_url":"https://github.com/CartoDB/carto-python","homepage":"https://carto.com","size":1324,"stargazers_count":112,"watchers_count":112,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":49,"open_issues":7,"watchers":112,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/carto-python/pulls/93"},"html":{"href":"https://github.com/CartoDB/carto-python/pull/93"},"issue":{"href":"https://api.github.com/repos/CartoDB/carto-python/issues/93"},"comments":{"href":"https://api.github.com/repos/CartoDB/carto-python/issues/93/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/carto-python/pulls/93/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/carto-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/carto-python/pulls/93/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/carto-python/statuses/43b13111220c628602706bd969b32f5502e08821"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jgoizueta"}}