def replace_func_flow(a, b): first_job = simple_job(str(a + b)) second_job = simple_job(first_job.output) flow = Flow( [first_job, second_job], { "first": first_job.output, "second": second_job.output }, ) return Response(output=a + b, replace=flow)
def fibonacci(smaller, larger, stop_point=1000): """Calculate the next number in the Fibonacci sequence. If the number is larger than stop_point, the job will stop the workflow execution, otherwise, a new job will be submitted to calculate the next number. """ total = smaller + larger if total > stop_point: return total new_job = fibonacci(larger, total, stop_point=stop_point) return Response(output=total, addition=new_job)
def detour_func(a, b): return Response(output=a + b, detour=simple_job(str(a + b)))
def addition_func(a, b): return Response(output=a + b, addition=simple_job(str(a + b)))
def replace_and_detour_func(a, b): return Response(output=a + b, replace=simple_job(str(a + b)), detour=simple_job("xyz"))
def detour_stop_func(a, b): return Response(output=a + b, detour=stop_jobflow_job())
def stored_data_func(message): return Response(output=message + "_end", stored_data={"a": "message"})
def stop_children_func(): return Response(output="1234", stop_children=True)
def stop_jobflow_func(): return Response(output="1234", stop_jobflow=True)
def replace_func(a, b): return Response(output=a + b, replace=simple_job(str(a + b)))