Exemplo n.º 1
0
    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')
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
# register.py
import boto.swf.layer2 as swf
import settings
from boto.swf.exceptions import SWFTypeAlreadyExistsError, SWFDomainAlreadyExistsError

DOMAIN = settings.DOMAIN

registerables = []
registerables.append(swf.Domain(name=DOMAIN))

# register workflow types, these all do the same thing
# but allow for different deciders
registerables.append(
    swf.WorkflowType(domain=DOMAIN,
                     name='CombineObjects',
                     version='NoSourceModify',
                     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,
Exemplo n.º 4
0
#! /usr/bin/env python

import ConfigParser
import time
import boto.swf.layer2 as swf

cf = ConfigParser.ConfigParser()
cf.read('swf.conf')
domain = cf.get('SWF', 'DOMAIN')
workflow = cf.get('SWF', 'WORKFLOW')

workflows = swf.Domain(name=domain).workflows(name=workflow)
input_data = '%s init_data' % time.ctime()
execution = workflows[0].start(task_list='default_tasks', input=input_data)
Exemplo n.º 5
0
#! /usr/bin/env python

import boto.swf.layer2 as swf

DOMAIN = 'HelloWorld'
ACTIVITY = 'HelloWorldActivity'
VERSION = '1.0'
TASK_LIST = 'HelloWorldTaskList'
WORKFLOW = 'HelloWorldWorkflow'

workflows = swf.Domain(name=DOMAIN).workflows()
execution = workflows[0].start(task_list='default_tasks')
Exemplo n.º 6
0
#! /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).deprecate()
Exemplo n.º 7
0
#! /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()
Exemplo n.º 8
0
#! /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()