def test_09(): domain = 'floto_test' rs = InstantRetry(retries=10) rs_2 = InstantRetry(retries=2) task_1 = ActivityTask(domain=domain, name='activity1', version='v5', retry_strategy=rs_2) task_failes_3 = ActivityTask(domain=domain, name='activity_fails_3', version='v2', retry_strategy=rs) timer_a = Timer(id_='TimerA', delay_in_seconds=15) timer_b = Timer(id_='TimerB', delay_in_seconds=3, requires=[task_1.id_]) task_2 = ActivityTask(domain=domain, name='activity2', version='v4', requires=[timer_b.id_], retry_strategy=rs_2) task_4 = ActivityTask(domain=domain, name='activity4', version='v2', requires=[task_1.id_, task_2.id_], retry_strategy=rs_2) tasks = [task_1, task_failes_3, timer_a, timer_b, task_2, task_4] decider_spec = DeciderSpec(domain=domain, task_list=str(uuid.uuid4()), activity_tasks=tasks, default_activity_task_list='floto_activities', repeat_workflow=True) decider = DeciderEarlyExit(repetitions=2, decider_spec=decider_spec) workflow_args = { 'domain': decider_spec.domain, 'workflow_type_name': 'my_workflow_type', 'workflow_type_version': 'v1', 'task_list': decider_spec.task_list, 'input': { 'foo': 'bar' } } response = floto.api.Swf().start_workflow_execution(**workflow_args) print(30 * '-' + ' Running Test 09 ' + 30 * '-') decider.run() print(30 * '-' + ' Done Test 09 ' + 30 * '-') return get_result(decider.domain, response['runId'], 'my_workflow_type_v1')
def get_tasks(date): rs = floto.specs.retry_strategy.InstantRetry(retries=3) copy_file = ActivityTask(domain=domain, name='copyFile', version='1', input=date.isoformat(), retry_strategy=rs) length = ActivityTask(domain=domain, name='fileLength', version='1', requires=[copy_file.id_], retry_strategy=rs) return [copy_file, length]
def test_13(): domain = 'floto_test' rs = InstantRetry(retries=10) rs_2 = InstantRetry(retries=2) task_1 = ActivityTask(domain=domain, name='activity1', version='v5', retry_strategy=rs_2) task_failes_3 = ActivityTask(domain=domain, name='activity_fails_3', version='v2', retry_strategy=rs) timer_a = Timer(id_='TimerA', delay_in_seconds=15) timer_b = Timer(id_='TimerB', delay_in_seconds=3, requires=[task_1.id_]) task_2 = ActivityTask(domain=domain, name='activity2', version='v4', requires=[timer_b.id_], retry_strategy=rs_2) task_4 = ActivityTask(domain=domain, name='activity4', version='v2', requires=[task_1.id_, task_2.id_], retry_strategy=rs_2) tasks = [task_1, task_failes_3, timer_a, timer_b, task_2, task_4] decider_spec = DeciderSpec(domain=domain, task_list=str(uuid.uuid4()), activity_tasks=tasks, default_activity_task_list='floto_activities', terminate_decider_after_completion=True) decider_1 = floto.decider.Decider(decider_spec=decider_spec) decider_2 = SlowDecider(decider_spec=decider_spec, timeout=20, num_timeouts=3) workflow_args = {'domain': decider_spec.domain, 'workflow_type_name': 'decider_timeout_workflow', 'workflow_type_version': 'v2', 'task_list': decider_spec.task_list, 'input': {'foo': 'bar'}} response = floto.api.Swf().start_workflow_execution(**workflow_args) print(30 * '-' + ' Running Test 13 ' + 30 * '-') decider_1.run(separate_process=True) decider_2.run(separate_process=True) result = None while True: time.sleep(5) result = is_workflow_completed(decider_1.domain, response['runId'], 'decider_timeout_workflow_v2') if result: decider_1._separate_process.terminate() decider_2._separate_process.terminate() break print(30 * '-' + ' Done Test 13 ' + 30 * '-') return result
def test_01(): domain = 'floto_test' rs = floto.specs.retry_strategy.InstantRetry(retries=2) activity_task_1 = ActivityTask(domain=domain, name='activity1', version='v5', retry_strategy=rs) decider_spec = DeciderSpec(domain=domain, task_list=str(uuid.uuid4()), activity_tasks=[activity_task_1], default_activity_task_list='floto_activities', terminate_decider_after_completion=True) decider = floto.decider.Decider(decider_spec=decider_spec) response = floto.api.Swf().start_workflow_execution( domain='floto_test', workflow_type_name='my_workflow_type', workflow_type_version='v1', task_list=decider_spec.task_list, input={'foo': 'bar'}) run_id = response['runId'] workflow_id = 'my_workflow_type_v1' print(30 * '-' + ' Running Test 01 ' + 30 * '-') decider.run() print(30 * '-' + ' Done Test 01 ' + 30 * '-') return get_result('floto_test', run_id, workflow_id)
def test_06(): domain = 'floto_test' rs = floto.specs.retry_strategy.InstantRetry(retries=2) activity_task = ActivityTask(domain=domain, name='activity_fails_2', version='v2', retry_strategy=rs) decider_spec = DeciderSpec(domain=domain, task_list=str(uuid.uuid4()), activity_tasks=[activity_task], default_activity_task_list='floto_activities', terminate_decider_after_completion=True) decider = floto.decider.Decider(decider_spec=decider_spec) workflow_args = { 'domain': decider_spec.domain, 'workflow_type_name': 'my_workflow_type', 'workflow_type_version': 'v1', 'task_list': decider_spec.task_list, 'input': { 'foo': 'bar' } } response = floto.api.Swf().start_workflow_execution(**workflow_args) print(30 * '-' + ' Running Test 06 ' + 30 * '-') decider.run() print(30 * '-' + ' Done Test 06 ' + 30 * '-') return get_fail_workflow_execution(decider.domain, response['runId'], 'my_workflow_type_v1')
def decider_spec_child_workflow(): rs = InstantRetry(retries=1) task_1 = ActivityTask(domain='floto_test', name='activity1', version='v5', retry_strategy=rs) decider_spec = DeciderSpec(domain='floto_test', task_list='child_workflow_task_list', activity_tasks=[task_1], default_activity_task_list='floto_activities', terminate_decider_after_completion=True) return decider_spec
def decider_spec_child_workflow(): task_1 = ActivityTask(domain='floto_test', name='activity_fails_2', version='v2') decider_spec = DeciderSpec(domain='floto_test', task_list='child_workflow_task_list', activity_tasks=[task_1], default_activity_task_list='floto_activities', repeat_workflow=False) return decider_spec
def decider_spec_workflow(): rs = InstantRetry(retries=1) task_1 = ActivityTask(domain='floto_test', name='activity1', version='v5', retry_strategy=rs) child_workflow = ChildWorkflow(domain='floto_test', workflow_type_name='test_child_workflow', workflow_type_version='v2', retry_strategy=rs, task_list='child_workflow_task_list', requires=[task_1.id_]) decider_spec = DeciderSpec(domain='floto_test', task_list=str(uuid.uuid4()), activity_tasks=[task_1, child_workflow], default_activity_task_list='floto_activities', terminate_decider_after_completion=True) return decider_spec
def test_17(): domain = 'floto_test' rs = floto.specs.retry_strategy.InstantRetry(retries=2) generator_task_1 = Generator(domain=domain, name='generator1', version='v1', retry_strategy=rs) task_2 = ActivityTask(domain=domain, name='activity6', version='v1', requires=[generator_task_1.id_]) decider_spec = DeciderSpec(domain='floto_test', task_list=str(uuid.uuid4()), activity_tasks=[generator_task_1, task_2], default_activity_task_list='floto_activities', terminate_decider_after_completion=True) decider_1 = floto.decider.Decider(decider_spec=decider_spec) decider_2 = SlowDecider(decider_spec=decider_spec, timeout=20, num_timeouts=2) response = floto.api.Swf().start_workflow_execution(domain='floto_test', workflow_type_name='decider_timeout_workflow', workflow_type_version='v2', task_list=decider_spec.task_list, input={'foo':'bar'}) run_id = response['runId'] workflow_id = 'decider_timeout_workflow_v2' print(30*'-'+' Running Test 17 '+30*'-') decider_1.run(separate_process=True) decider_2.run(separate_process=True) result = None while True: time.sleep(5) result = is_workflow_completed(decider_1.domain, response['runId'], workflow_id) if result: decider_1._separate_process.terminate() decider_2._separate_process.terminate() break print(30*'-'+' Done Test 17 '+30*'-') return result
def task_2(task_1): return ActivityTask(domain='d', name='activity2', version='v1', requires=[task_1.id_])
def task_1(): return ActivityTask(domain='d', name='activity1', version='v1', input={'date': 1})
import floto import logging from floto.specs.task import ActivityTask, ChildWorkflow from floto.specs import DeciderSpec import floto.decider logger = logging.getLogger(__name__) rs = floto.specs.retry_strategy.InstantRetry(retries=3) domain = 'floto_test' #Define tasks and decider of the workflow copy_files = ActivityTask(domain=domain, name='copyFiles', version='1', retry_strategy=rs) child_workflow = ChildWorkflow(domain=domain, workflow_type_name='s3_files_example', workflow_type_version='1', requires=[copy_files.id_], task_list='file_length_task_list', retry_strategy=rs) decider_spec = DeciderSpec(domain=domain, task_list='copy_files_task_list', default_activity_task_list='s3_files_worker', activity_tasks=[copy_files, child_workflow], terminate_decider_after_completion=True) decider = floto.decider.Decider(decider_spec=decider_spec)
def task(): return ActivityTask(domain='d', name='activity2', version='v1')
import datetime as dt # ---------------------------------- # # Start the workflow execution # ---------------------------------- # rs = InstantRetry(retries=3) domain = 'floto_test' input_copy_files = { 'from_date': dt.date(2016, 3, 6).isoformat(), 'to_date': dt.date(2016, 3, 11).isoformat() } copy_files = ActivityTask(domain=domain, name='copyFiles', version='1', retry_strategy=rs, input=input_copy_files) file_length = ActivityTask(domain=domain, name='fileLength', version='1', retry_strategy=rs) child_workflow = ChildWorkflow( workflow_type_name='read_file_lengths', domain=domain, workflow_type_version='1', requires=[copy_files.id_], retry_strategy=rs, task_list='s3_files',
from floto.specs.retry_strategy import InstantRetry from floto.specs.task import ActivityTask, ChildWorkflow import datetime as dt # ---------------------------------- # # Start the workflow execution # ---------------------------------- # rs = InstantRetry(retries=3) domain = 'floto_test' input_copy_files = {'from_date':dt.date(2016,3,6).isoformat(), 'to_date':dt.date(2016,3,11).isoformat()} copy_files = ActivityTask(domain=domain, name='copyFiles', version='1', retry_strategy=rs, input=input_copy_files) file_length = ActivityTask(domain=domain, name='fileLength', version='1', retry_strategy=rs) child_workflow = ChildWorkflow(workflow_type_name='read_file_lengths', domain=domain, workflow_type_version='1', requires=[copy_files.id_], retry_strategy=rs, task_list='s3_files', input={'activity_tasks':[file_length.serializable()]}) activity_tasks = [copy_files.serializable(), child_workflow.serializable()] workflow_args = {'domain': 'floto_test',