"""Store Specific Itunes Priority Workflow.""" from garcon.param import StaticParam from feed_ingestion import conf from feed_ingestion.flows import base from feed_ingestion.flows.itunes_priority import config from feed_ingestion.flows.itunes_priority 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', priority_sheet_id='bootstrap.priority_sheet_id', priority_table='bootstrap.priority_table', s3_path='bootstrap.s3_path', 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', priority_table='bootstrap.priority_table', priority_email_list='bootstrap.priority_email_list', rows_added='process_files.rows_added')))