"""Store Specific Spotify Strikes Workflow.""" from garcon.param import StaticParam from feed_ingestion import conf from feed_ingestion.flows import base from feed_ingestion.flows.spotify_strikes import config from feed_ingestion.flows.spotify_strikes import tasks class Flow(base.FlowBase, base.FlowConfigMixin): """Class representing the workflow.""" def __init__(self): """Initialize flow object.""" super(Flow, self).__init__(config.feed_name, config.feed_version) def decider(self, schedule): """Activity decider. Args: schedule (callable): The scheduler method. """ bootstrap = schedule( 'bootstrap', self.bootstrap) process_files = schedule( 'process_files', self.process_files, requires=[bootstrap]) if process_files.result.get('process_files.stop') is True: return schedule( 'send_emails', self.send_emails, requires=[process_files]) @property def bootstrap(self): """Bootstrap initial configuration.""" return self.create( name='bootstrap', tasks=base.SyncRunner( tasks.bootstrap.fill( namespace='bootstrap'))) @property def process_files(self): """Process files.""" return self.create( name='process_files', tasks=base.SyncRunner( tasks.process_files.fill( namespace='process_files', strikes_sheet_id='bootstrap.strikes_sheet_id', s3_path='bootstrap.s3_path', file_format_tsv='bootstrap.snowflake_file_format_tsv', strikes_table='bootstrap.strikes_table', aws=StaticParam(conf.getconf('aws')['aws'])))) @property def send_emails(self): """Send emails that Spotify Label Strikes Updated.""" return self.create( name='send_emails', tasks=base.SyncRunner( tasks.send_emails.fill( namespace='send_emails', email_list='bootstrap.email_list', googledoc_id='googledoc_id')))