Skip to content

Instantly share code, notes, and snippets.

@jasonjho
Created February 10, 2016 15:23
Show Gist options
  • Save jasonjho/a01e66fe99734452c47b to your computer and use it in GitHub Desktop.
Save jasonjho/a01e66fe99734452c47b to your computer and use it in GitHub Desktop.
Variable and Connection settings
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
Variables = {
# emails
'email_recipients': {
'airflow_admins': [],
'pagerduty_airflow': [],
'convertro-spend': [],
'demand_forecast_counts': [],
'demand-forecast_first-shipped-box': [],
'twonil-dma-report': [],
'potential-vip': [],
'white_glove': []
},
# google sheets
'google_sheets': {
'forecast_app_dashboard': '',
'forecast_app_prod_dashboard': '',
'daily_marketing_spend_by_channel': '',
'marketing_dashboard': '',
'spree_dashboard': '',
'vip_dashboard': ''
},
# pg_restore_num_jobs
'pg_restore_num_jobs': {
'nightly-refresh': 16
},
# start times for TimeSensor
'start_time': {
'nightly-refresh': 5
},
# sla
'sla': {
'nightly-refresh': {}
}
}
"""
A connection is defined by it's environment (e.g. prod, dev) and a logical key.
"""
Connections = {
'prod': {
'postgres': {
'admin': 'postgres_admin',
'data_warehouse': 'postgres_warehouse',
'data_warehouse_staging': 'postgres_staging',
'spree': 'postgres_spree'
},
'ftp': {
'twonil_dma': 'ftp_twonil_dma',
'responsys': 'responsys_ftp'
},
's3': {
'blueapron': 's3_default'
}
},
'dev': {}
}
AIRFLOW_ENV = "dev"
def get_conn(section, key):
"""
Retrieves a connection id based on the configured environment,
which is discovered by an ENV variable
"""
airflow_env = os.environ.get(AIRFLOW_ENV)
# default to dev, if not specified
if airflow_env is None:
airflow_env = 'airflow_dev'
return Connections[airflow_env][section][key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment