John Horn
06/15/2023, 6:21 PMdeployment = Deployment.build_from_flow(
...
parameters={"foo_tasks": [FooTask]}
Object of type 'Task' is not JSON serializable
Nate
06/15/2023, 6:28 PMJohn Horn
06/15/2023, 6:31 PMparameters = {"orders": [{"order_number": "2", "api_request": GrubhubTask}, {"order_number": "3", "api_request": "PostmatesTask}] }
John Horn
06/15/2023, 6:32 PMJohn Horn
06/15/2023, 6:33 PMNate
06/15/2023, 6:33 PMNate
06/15/2023, 6:34 PMJohn Horn
06/15/2023, 6:35 PMfutures = []
for order in orders:
futures.append(order.api_request.submit())
John Horn
06/15/2023, 6:36 PMJohn Horn
06/15/2023, 6:37 PMJohn Horn
06/15/2023, 6:39 PMfutures = []
for order in orders:
if order_type == 'grubhub'
futures.append(grubhub_task.submit(**order.params))
elif order_type == 'postmates'
futures.append(postmates_task.submit(**order.params))
John Horn
06/15/2023, 6:39 PMNate
06/15/2023, 6:40 PMIn [10]: from prefect import flow, task
...:
...: @task
...: def call_grubhub_api():
...: print("calling grubhub")
...:
...: @task
...: def call_postmates_api():
...: print("calling postmates")
...:
...:
...: api_request_tasks = {
...: "grubhub": call_grubhub_api,
...: "postmates": call_postmates_api
...: }
and then
parameters = {"orders": [{"order_number": "2", "api_request": "grubhub"}, {"order_number": "3", "api_request": "postmates"}] }
Nate
06/15/2023, 6:40 PMJohn Horn
06/15/2023, 6:41 PMJohn Horn
06/15/2023, 6:41 PMNate
06/15/2023, 6:42 PM