{"action":"closed","number":451,"pull_request":{"url":"https://api.github.com/repos/airbnb/airflow/pulls/451","id":45725041,"html_url":"https://github.com/airbnb/airflow/pull/451","diff_url":"https://github.com/airbnb/airflow/pull/451.diff","patch_url":"https://github.com/airbnb/airflow/pull/451.patch","issue_url":"https://api.github.com/repos/airbnb/airflow/issues/451","number":451,"state":"closed","locked":false,"title":"ContentEmailOperator: rich HTML emails with Matplotlib graphs as images","user":{"login":"patrickleotardif","id":787256,"avatar_url":"https://avatars.githubusercontent.com/u/787256?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickleotardif","html_url":"https://github.com/patrickleotardif","followers_url":"https://api.github.com/users/patrickleotardif/followers","following_url":"https://api.github.com/users/patrickleotardif/following{/other_user}","gists_url":"https://api.github.com/users/patrickleotardif/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickleotardif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickleotardif/subscriptions","organizations_url":"https://api.github.com/users/patrickleotardif/orgs","repos_url":"https://api.github.com/users/patrickleotardif/repos","events_url":"https://api.github.com/users/patrickleotardif/events{/privacy}","received_events_url":"https://api.github.com/users/patrickleotardif/received_events","type":"User","site_admin":false},"body":"(Intended as an initial draft since the current approach is pretty hacky <- @mistercrunch )\r\n\r\nUsage in a DAG:\r\n```\r\nemail = ContentEmailOperator(\r\n        task_id='email',\r\n        to=[\r\n            'plt@rdif.me'\r\n        ],\r\n        subject='Report for {{ ds }}',\r\n        template=os.path.join(cur_dir, 'email.html'),\r\n        data={\r\n            'by_type' : 'sql/by_type.sql',\r\n            'all' : 'sql/all.sql'\r\n        },\r\n        variables={\r\n            'ds' : '{{ ds }}'\r\n        },\r\n        default_args=args)\r\n```\r\n\r\nIn this case email.html is a Jinja template with specific macros to generate the matplotlib images. The data dict is simply Presto queries now (but could be generalized).\r\n\r\ne.g. email.html\r\n\r\n```\r\n<table>\r\n\t<tr bgcolor=\"ff5a5f\" height=\"50px\" width=\"775px\">\r\n\t\t<td align=\"center\" style=\"font-family: Tahoma, Arial, Verdana, sans-serif;font-size:18px;\">\r\n\t\t\t<font color=\"white\">\r\n\t\t\t\tDaily Report for {{ variables['ds'] }}\r\n\t\t\t</font>\r\n\t\t</td>\r\n\t</tr>\r\n\r\n\t<tr height=\"5px\" ></tr>\r\n\r\n\t<tr> \r\n\t\t<td>\r\n\t\t\t{{ lib.line_graph(data['events'], 'event_count','linechartnew','Events Per Day') }}\r\n\t\t</td>\r\n\t</tr>\r\n\r\n    <tr height=\"10px\" bgcolor=\"#ccc\" align=\"right\" style=\"font-family: Tahoma, Arial, Verdana, sans-serif;font-size:12px;\">\r\n    \t<td>\r\n    \t\t<font color=\"white\">\r\n    \t\t\tbrought to you by #data-engineering\r\n    \t\t</font>\r\n    \t</td>\r\n    </tr>\r\n</table>\r\n```\r\n\r\n","created_at":"2015-09-22T22:25:40Z","updated_at":"2016-03-21T23:08:27Z","closed_at":"2016-03-21T23:08:27Z","merged_at":null,"merge_commit_sha":"2c4c5945cfe9acea45fb8ab7ad48f73b83b3fa32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/airbnb/airflow/pulls/451/commits","review_comments_url":"https://api.github.com/repos/airbnb/airflow/pulls/451/comments","review_comment_url":"https://api.github.com/repos/airbnb/airflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airbnb/airflow/issues/451/comments","statuses_url":"https://api.github.com/repos/airbnb/airflow/statuses/b0cf5f5ebc54260d02af97229001c0ed21364bea","head":{"label":"patrickleotardif:content-email-operator","ref":"content-email-operator","sha":"b0cf5f5ebc54260d02af97229001c0ed21364bea","user":{"login":"patrickleotardif","id":787256,"avatar_url":"https://avatars.githubusercontent.com/u/787256?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickleotardif","html_url":"https://github.com/patrickleotardif","followers_url":"https://api.github.com/users/patrickleotardif/followers","following_url":"https://api.github.com/users/patrickleotardif/following{/other_user}","gists_url":"https://api.github.com/users/patrickleotardif/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickleotardif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickleotardif/subscriptions","organizations_url":"https://api.github.com/users/patrickleotardif/orgs","repos_url":"https://api.github.com/users/patrickleotardif/repos","events_url":"https://api.github.com/users/patrickleotardif/events{/privacy}","received_events_url":"https://api.github.com/users/patrickleotardif/received_events","type":"User","site_admin":false},"repo":{"id":38338191,"name":"airflow","full_name":"patrickleotardif/airflow","owner":{"login":"patrickleotardif","id":787256,"avatar_url":"https://avatars.githubusercontent.com/u/787256?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickleotardif","html_url":"https://github.com/patrickleotardif","followers_url":"https://api.github.com/users/patrickleotardif/followers","following_url":"https://api.github.com/users/patrickleotardif/following{/other_user}","gists_url":"https://api.github.com/users/patrickleotardif/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickleotardif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickleotardif/subscriptions","organizations_url":"https://api.github.com/users/patrickleotardif/orgs","repos_url":"https://api.github.com/users/patrickleotardif/repos","events_url":"https://api.github.com/users/patrickleotardif/events{/privacy}","received_events_url":"https://api.github.com/users/patrickleotardif/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/patrickleotardif/airflow","description":"AirFlow is a system to programmatically author, schedule and monitor data pipelines.","fork":true,"url":"https://api.github.com/repos/patrickleotardif/airflow","forks_url":"https://api.github.com/repos/patrickleotardif/airflow/forks","keys_url":"https://api.github.com/repos/patrickleotardif/airflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/patrickleotardif/airflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/patrickleotardif/airflow/teams","hooks_url":"https://api.github.com/repos/patrickleotardif/airflow/hooks","issue_events_url":"https://api.github.com/repos/patrickleotardif/airflow/issues/events{/number}","events_url":"https://api.github.com/repos/patrickleotardif/airflow/events","assignees_url":"https://api.github.com/repos/patrickleotardif/airflow/assignees{/user}","branches_url":"https://api.github.com/repos/patrickleotardif/airflow/branches{/branch}","tags_url":"https://api.github.com/repos/patrickleotardif/airflow/tags","blobs_url":"https://api.github.com/repos/patrickleotardif/airflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/patrickleotardif/airflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/patrickleotardif/airflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/patrickleotardif/airflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/patrickleotardif/airflow/statuses/{sha}","languages_url":"https://api.github.com/repos/patrickleotardif/airflow/languages","stargazers_url":"https://api.github.com/repos/patrickleotardif/airflow/stargazers","contributors_url":"https://api.github.com/repos/patrickleotardif/airflow/contributors","subscribers_url":"https://api.github.com/repos/patrickleotardif/airflow/subscribers","subscription_url":"https://api.github.com/repos/patrickleotardif/airflow/subscription","commits_url":"https://api.github.com/repos/patrickleotardif/airflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/patrickleotardif/airflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/patrickleotardif/airflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/patrickleotardif/airflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/patrickleotardif/airflow/contents/{+path}","compare_url":"https://api.github.com/repos/patrickleotardif/airflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/patrickleotardif/airflow/merges","archive_url":"https://api.github.com/repos/patrickleotardif/airflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/patrickleotardif/airflow/downloads","issues_url":"https://api.github.com/repos/patrickleotardif/airflow/issues{/number}","pulls_url":"https://api.github.com/repos/patrickleotardif/airflow/pulls{/number}","milestones_url":"https://api.github.com/repos/patrickleotardif/airflow/milestones{/number}","notifications_url":"https://api.github.com/repos/patrickleotardif/airflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/patrickleotardif/airflow/labels{/name}","releases_url":"https://api.github.com/repos/patrickleotardif/airflow/releases{/id}","deployments_url":"https://api.github.com/repos/patrickleotardif/airflow/deployments","created_at":"2015-06-30T23:22:31Z","updated_at":"2015-06-30T23:22:31Z","pushed_at":"2015-11-24T17:25:51Z","git_url":"git://github.com/patrickleotardif/airflow.git","ssh_url":"git@github.com:patrickleotardif/airflow.git","clone_url":"https://github.com/patrickleotardif/airflow.git","svn_url":"https://github.com/patrickleotardif/airflow","homepage":null,"size":6706,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"airbnb:master","ref":"master","sha":"dcad5c6c93e1d2b820707bb0a16576b2fc13acb2","user":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"repo":{"id":33884891,"name":"airflow","full_name":"airbnb/airflow","owner":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airbnb/airflow","description":"Airflow is a system to programmatically author, schedule and monitor data pipelines.","fork":false,"url":"https://api.github.com/repos/airbnb/airflow","forks_url":"https://api.github.com/repos/airbnb/airflow/forks","keys_url":"https://api.github.com/repos/airbnb/airflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airbnb/airflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airbnb/airflow/teams","hooks_url":"https://api.github.com/repos/airbnb/airflow/hooks","issue_events_url":"https://api.github.com/repos/airbnb/airflow/issues/events{/number}","events_url":"https://api.github.com/repos/airbnb/airflow/events","assignees_url":"https://api.github.com/repos/airbnb/airflow/assignees{/user}","branches_url":"https://api.github.com/repos/airbnb/airflow/branches{/branch}","tags_url":"https://api.github.com/repos/airbnb/airflow/tags","blobs_url":"https://api.github.com/repos/airbnb/airflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airbnb/airflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airbnb/airflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/airbnb/airflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airbnb/airflow/statuses/{sha}","languages_url":"https://api.github.com/repos/airbnb/airflow/languages","stargazers_url":"https://api.github.com/repos/airbnb/airflow/stargazers","contributors_url":"https://api.github.com/repos/airbnb/airflow/contributors","subscribers_url":"https://api.github.com/repos/airbnb/airflow/subscribers","subscription_url":"https://api.github.com/repos/airbnb/airflow/subscription","commits_url":"https://api.github.com/repos/airbnb/airflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/airbnb/airflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/airbnb/airflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/airbnb/airflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/airbnb/airflow/contents/{+path}","compare_url":"https://api.github.com/repos/airbnb/airflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airbnb/airflow/merges","archive_url":"https://api.github.com/repos/airbnb/airflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airbnb/airflow/downloads","issues_url":"https://api.github.com/repos/airbnb/airflow/issues{/number}","pulls_url":"https://api.github.com/repos/airbnb/airflow/pulls{/number}","milestones_url":"https://api.github.com/repos/airbnb/airflow/milestones{/number}","notifications_url":"https://api.github.com/repos/airbnb/airflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airbnb/airflow/labels{/name}","releases_url":"https://api.github.com/repos/airbnb/airflow/releases{/id}","deployments_url":"https://api.github.com/repos/airbnb/airflow/deployments","created_at":"2015-04-13T18:04:58Z","updated_at":"2016-03-21T18:43:58Z","pushed_at":"2016-03-21T22:55:53Z","git_url":"git://github.com/airbnb/airflow.git","ssh_url":"git@github.com:airbnb/airflow.git","clone_url":"https://github.com/airbnb/airflow.git","svn_url":"https://github.com/airbnb/airflow","homepage":"","size":10021,"stargazers_count":2177,"watchers_count":2177,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":437,"mirror_url":null,"open_issues_count":191,"forks":437,"open_issues":191,"watchers":2177,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airbnb/airflow/pulls/451"},"html":{"href":"https://github.com/airbnb/airflow/pull/451"},"issue":{"href":"https://api.github.com/repos/airbnb/airflow/issues/451"},"comments":{"href":"https://api.github.com/repos/airbnb/airflow/issues/451/comments"},"review_comments":{"href":"https://api.github.com/repos/airbnb/airflow/pulls/451/comments"},"review_comment":{"href":"https://api.github.com/repos/airbnb/airflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airbnb/airflow/pulls/451/commits"},"statuses":{"href":"https://api.github.com/repos/airbnb/airflow/statuses/b0cf5f5ebc54260d02af97229001c0ed21364bea"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":1,"review_comments":7,"commits":1,"additions":179,"deletions":0,"changed_files":2}}