"""New workflow.""" from garcon import runner from garcon_boilerplate.flows.base_flow import FlowBase from garcon_boilerplate.flows.new_flow import config from garcon_boilerplate.flows.new_flow import tasks class Flow(FlowBase): """Class representing the workflow.""" timeout = 12 * 60 def __init__(self): """Initialize flow object.""" super(Flow, self).__init__( swf_domain=config.SWF_DOMAIN, flow_name=config.SWF_FLOW_NAME, version=config.SWF_FLOW_VERSION) def decider(self, schedule, context): """Activity decider. Args: schedule (callable): The scheduler method. """ bootstrap = schedule('bootstrap', self.bootstrap) if bootstrap.result.get('bootstrap.optional'): schedule( 'optional', self.optional, requires=[bootstrap]) @property def bootstrap(self): """Bootstrap initial configuration.""" return self.create( name='bootstrap', tasks=runner.Sync( tasks.bootstrap.fill( namespace='bootstrap', date='date', optional='optional',))) @property def optional(self): """Bootstrap initial configuration.""" return self.create( name='optional', tasks=runner.Sync( tasks.optional_taks.fill( namespace='optional')))