"""Spotify Marketshare Week Ending Garcon tasks. Tasks to ingest Spotify Marketshare data. """ from datetime import datetime from garcon import task from feed_ingestion.flows.spotify_marketshare_week_ending import config from feed_ingestion.tasks import bootstrap as reload STOP_RESPONSE = {'stop': True} @task.decorate(timeout=1000) @reload.reset_dynamodb_status_on_reload(config.feed_name) def bootstrap(activity, date, dw_config=None): """Bootstrap workflow by injecting intial context from config. Args: activity (ActivityWorker): The Garcon activity worker. date (str): Reporting date (YYYY-MM-DD). Returns: dict: Initial context for the workflow. """ date_obj = datetime.strptime(date, '%Y-%m-%d') report = config.file_pattern.format(date=date_obj) temp_staging_raw_table = config.snowflake_table_names[ 'temp_staging_raw'].format(date=date_obj) return { 'feed_name': config.feed_name, 'secrets_path': config.secrets_path, 'date': date, 's3_archive_path': config.s3['archive'].format(date=date_obj), 's3_download_path': config.s3['drop_path'], 'report': report, 'temp_staging_raw_table': temp_staging_raw_table, 'staging_raw_table': config.snowflake_table_names['staging_raw'], 'source_files_dict': { 'files': [ {'file_name': report} ]} }