def register(self): """Register the Workflow on SWF. To work, SWF needs to have pre-registered the domain, the workflow, and the different activities, this method takes care of this part. """ registerables = [] registerables.append(swf.Domain(name=self.domain)) registerables.append( swf.WorkflowType(domain=self.domain, name=self.task_list, version=self.version, task_list=self.task_list)) for current_activity in self.activities: registerables.append( swf.ActivityType(domain=self.domain, name=current_activity.name, version=self.version, task_list=current_activity.task_list)) for swf_entity in registerables: try: swf_entity.register() except (SWFDomainAlreadyExistsError, SWFTypeAlreadyExistsError): print(swf_entity.__class__.__name__, swf_entity.name, 'already exists')
def register(self): """Registers the workflow type and task types with SWF It is necessary to do this each time a new task is added to a workflow. It is safest to run this before each call to :meth:`execute` if you are just launching a workflow from a cron. However, if you are launching many workflows and calling :meth:`execute` many times, you may want to consider calling this method only when necessary because it can contribute to an SWF API throttling issue. """ tasks = get_task_configurations(self.workflow_task) registerables = [] registerables.append(swf.Domain(name=self.domain)) task_dats = set((t['task_family'], t['task_list']) for (t_id, t) in iteritems(tasks)) for task_dat in task_dats: registerables.append( swf.ActivityType(domain=self.domain, version=self.version, name=task_dat[0], task_list=task_dat[1])) wf_name = self.workflow_task.task_family wf_task_list = getattr(self.workflow_task, 'swf_task_list', 'default') registerables.append( swf.WorkflowType(domain=self.domain, version=self.version, name=wf_name, task_list=wf_task_list)) for swf_entity in registerables: try: swf_entity.register() print_(swf_entity.name, 'registered successfully') except (SWFDomainAlreadyExistsError, SWFTypeAlreadyExistsError): print_(swf_entity.__class__.__name__, swf_entity.name, 'already exists')
task_list='WFHandsOff')) registerables.append( swf.WorkflowType(domain=DOMAIN, name='CombineObjects', version='CopySource', task_list='WFCopySource')) registerables.append( swf.WorkflowType(domain=DOMAIN, name='CombineObjects', version='CopyAndDeleteSource', task_list='WFCopyAndDelete')) # workflow tasks registerables.append( swf.ActivityType(domain=DOMAIN, name="CreateCombineList", version="0.1", task_list='CreateList')) registerables.append( swf.ActivityType(domain=DOMAIN, name="CombineSourceObjects", version="0.1", task_list='CombineObjects')) registerables.append( swf.ActivityType(domain=DOMAIN, name="DeleteSourceObjects", version="0.1", task_list='DeleteSourceObjects')) registerables.append( swf.ActivityType(domain=DOMAIN, name="CopySourceObjects", version="0.1",
#! /usr/bin/env python import ConfigParser import boto.swf.layer2 as swf cf = ConfigParser.ConfigParser() cf.read('swf.conf') domain = cf.get('SWF', 'DOMAIN') activities = cf.get('SWF', 'ACTIVITIES').split(',') version = cf.get('SWF', 'VERSION') workflow = cf.get('SWF', 'WORKFLOW') swf.Domain(name=domain).register() for activity in activities: activity = activity.strip() task_list = activity+'TaskList' swf.ActivityType(domain=domain, name=activity, version=version,task_list=task_list).register() swf.WorkflowType(domain=domain, name=workflow, version=version, task_list='default_tasks').register()
#! /usr/bin/env python import boto.swf.layer2 as swf DOMAIN = 'HelloWorld' ACTIVITY = 'HelloWorldActivity' VERSION = '1.0' TASK_LIST = 'HelloWorldTaskList' WORKFLOW = 'HelloWorldWorkflow' swf.Domain(name=DOMAIN).register() swf.ActivityType(domain=DOMAIN, name=ACTIVITY, version=VERSION, task_list=TASK_LIST).register() swf.WorkflowType(domain=DOMAIN, name=WORKFLOW, version=VERSION, task_list='default_tasks').register()