"""Config for Spotify Workflow.""" import os feed_name = 'spotify' secrets_path = 'spotify' feed_version = '3.1' s3_feed_name = 'SpotifyV2' storeid = 286 feedid = 1 # SELECT feedid FROM dim_feed WHERE feedname = 'Spotify Streams' # just for historical records: FIRST_USE_OF_PARTITIONED_ENDPOIUNT = '2024-01-22' # environment to run in environment = os.environ.get('Environment', 'dev') # bucket for archived data data_bucket = os.environ.get('FEED_INGESTION_DATA_BUCKET', 'dev-cucumbers') # bucket for dropped data drop_bucket = os.environ.get('FEED_INGESTION_DROP_BUCKET', 'dev-feed-drop') # Multiprocessing pool size for report downloader. pool_size = os.environ.get('SPOTIFY_POOL_SIZE', 5) # S3 location for archived files s3 = { 'archive_path': ( '{s3_feed_name}/archives/{{date:%Y-%m-%d}}/{{report_name}}/' '{{licensor}}/'.format(s3_feed_name=s3_feed_name) ), 'drop_path': ( 'feed-drop/{s3_feed_name}/{{date:%Y-%m-%d}}/{{report_name}}/' '{{licensor}}/'.format(s3_feed_name=s3_feed_name)) } reports = { 'streams': { 'staging_raw': 'staging_raw_spotify_v2', 'use_countries': True, 'separate_query_for_cleaning_staging_raw': True, }, 'sub_30_sec_streams': { # we can re-enable this and backfill data if needed # for backfill use context parameter:'{ # "context_date": "backfilled-date", # "reports": "sub_30_sec_streams"}' # 'staging_raw': 'staging_raw_spotify_sub30', 'use_countries': True, }, 'aggregated_streams': { 'staging_raw': 'staging_raw_spotify_aggregated_streams', # it is needed to load filename in staging raw table 'filename': True, 'separate_query_for_cleaning_staging_raw': True, }, 'users': {}, 'tracks': { 'staging_raw': 'spotify_tracks'} } common_reports = ['users', 'tracks'] # DS-6220 Due to sub_30_sec_streams is not used, it will be only downloaded, # in case it will be used in the future download_only_reports = ['sub_30_sec_streams'] fact_analytics_report = 'streams' # report for load_aggregated_skips_and_saves aggregated_report = 'aggregated_streams' temp_staging_raw_table = ( 'temp_staging_raw_spotify_{report}_{date}_{licensor}') transitional_temp_table = 'transitional_temp_table_{report}_{date}_{licensor}' file_pattern = '{report_name}_{date:%Y-%m-%d}{country_code}_{licensor}.gz' # The maximum allowed number of errors in the file snowflake_error_limit = 10000 # list of licensors which data should be ingested spotify_api_licensors = ['theorchard', 'sme', 'smejp', 'smejpintl', 'smecharity', 'altafonte'] # Retention policy for Spotify API spotify_api_retention_days = 30 columbia_labelid = 32551 consumer_sf = { 'db': os.environ.get('CONSUMER_DB', 'CONSUMER_REPORTING'), 'schema': os.environ.get('CONSUMER_SCHEMA', 'SPOTIFY'), } def _get_environ(variable, licensor): licensor_specific_name = '{variable}_{licensor}'.format( variable=variable, licensor=licensor.upper()) return os.environ.get(licensor_specific_name, os.environ.get(variable)) spotify_api_credentials = {} for licensor in spotify_api_licensors: spotify_api_credentials[licensor] = { 'client_id': _get_environ('SPOTIFY_API_CLIENT_ID', licensor), 'client_secret': _get_environ('SPOTIFY_API_CLIENT_SECRET', licensor), 'licensor': _get_environ('SPOTIFY_API_LICENSOR', licensor), 'version': os.environ.get('SPOTIFY_API_VERSION', 'v1') } countries = [ 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CS', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'XK', 'YE', 'YT', 'ZA', 'ZM', 'ZW', 'ZZ'] expected_countries = [ 'AD', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'GT', 'HK', 'HN', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'MY', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'SE', 'SG', 'SK', 'SV', 'TR', 'TW', 'US', 'UY' ] # config for the update_dim_tables task dimension_tables = { 'tables_to_update': [ 'dim_sourcetype', 'dim_subscriptiontype', 'dim_subscriptionpaytier', 'dim_playlist', 'dim_user', ], 'include_to_report': [ 'dim_sourcetype', 'dim_subscriptiontype', 'dim_subscriptionpaytier' ], 'sns_topic': os.environ.get( 'FEED_INGESTION_SNS_TOPIC', 'arn:aws:sns:us-east-1:437795906767:dev-swf-feed-ingestion:' 'e17576f8-b905-45a9-b863-0eaceca54f4d') } DBT_REQUIRED_REPORTS = [ 'streams', 'aggregated_streams', ] jenkins_config = { 'feeds_required_for_jenkins_build': [ f'spotify_{licensor}_{report}' for licensor in ['theorchard', 'sme'] for report in DBT_REQUIRED_REPORTS ], 'jenkins_username': os.environ.get('JENKINS_USER', 'jenkinsjobrunner'), 'jenkins_secrets_path': 'swf-shared-jenkins', 'jenkins_url': 'https://scheduler.theorchard.io', 'jenkins_job': 'dbt-scheduler-analytics-pipeline', 'jenkins_job_params': {'TRIGGERED_BY': feed_name}, } SMART_DOWNLOADER_TASKS_DYNAMODB_TABLE = os.environ.get( 'SMART_DOWNLOADER_TASKS_DYNAMODB_TABLE', default=f'{environment}_smart_downloader_tasks' ) # how long wait completion of download tasks # it has no sense to wait longer than # ttl for partition link from SpotifyAPI (which is 15 minutes) SMART_DOWNLOADER_TIMEOUT_SECONDS = 900 # How long we want to keep tasks in DynamoDB SMART_DOWNLOADER_TASKS_TTL_SECONDS = 60 * 60 * 24 * 7 # How many partition files go to smart_downloader task SMART_DOWNLOADER_BATCH_SIZE = 20