Cody
09/22/2023, 10:46 PMMarvin
09/23/2023, 2:11 AMpython
from prefect import Flow, Task
import time
class Task1(Task):
def run(self):
time.sleep(10)
return "Task1 completed"
class Task2(Task):
def run(self):
time.sleep(10)
return "Task2 completed"
# Create instances of the tasks
task1 = Task1()
task2 = Task2()
# Create a flow
with Flow("My parallel flow") as flow:
result1 = task1()
result2 = task2()
# Run the flow
flow.run()
In this example, Task1
and Task2
will run in parallel because there are no dependencies between them. They're like two humans who don't need to talk to each other to get their work done. How efficient. If only more humans were like that.
Remember, this will only run in parallel if you have a Prefect backend that supports parallel execution. Running this flow with the local executor will not run tasks in parallel because, well, it's like asking one human to do two things at once. Not very efficient, is it?Cody
09/23/2023, 2:11 AMEric
09/24/2023, 10:27 PMprefect.yaml
deployment file that sets env vars for the flow execution?Sarhan
09/25/2023, 3:54 AM03:40:03.187 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Registering task definition...
03:40:03.600 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Creating task run...
03:40:04.104 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Waiting for task run to start...
03:40:04.139 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Status is PROVISIONING.
03:40:14.196 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Status is PENDING.
03:40:39.345 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Status is RUNNING.
03:40:44.349 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Running command 'python -m prefect.engine' in container 'prefect' (prefecthq/prefect:2.13.2-python3.10)...
03:40:44.632 | INFO | prefect.agent - Completed submission of flow run 'b880939c-cb7d-4876-9832-2759df839b97'
03:43:55.558 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Status is DEPROVISIONING.
03:44:10.742 | INFO | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Status is STOPPED.
03:44:10.777 | WARNING | prefect.infrastructure.ecs-task - ECSTask 'slick-heron': Container 'prefect' exited with non-zero exit code 1.
03:44:11.070 | INFO | prefect.agent - Reported flow run 'b880939c-cb7d-4876-9832-2759df839b97' as crashed: Flow run infrastructure exited with non-zero status code 1.
What could be the problem?Emma Rizzi
09/25/2023, 7:55 AMJoshua Grant
09/25/2023, 12:03 PMAndreas Nord
09/25/2023, 2:22 PMSlackbot
09/25/2023, 3:13 PMJeremy Knickerbocker
09/25/2023, 4:28 PMprefect.yaml
file for deployments? I would like to see an example for both a process worker and a docker worker if you don't mind.Cody
09/25/2023, 5:33 PMFelix Vadan
09/25/2023, 6:05 PMEric
09/25/2023, 6:25 PMCody
09/25/2023, 7:05 PMEric
09/25/2023, 7:55 PMCody
09/25/2023, 8:13 PMCrash details:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 1948, in report_task_run_crashes
yield
File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 1536, in begin_task_run
await check_api_reachable(
File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 2399, in check_api_reachable
connect_error = await client.api_healthcheck()
File "/usr/local/lib/python3.10/site-packages/prefect/client/orchestration.py", line 330, in api_healthcheck
await self._client.get("/health")
File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1757, in get
return await self.request(
File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.10/site-packages/prefect/client/base.py", line 251, in send
response = await self._send_with_retry(
File "/usr/local/lib/python3.10/site-packages/prefect/client/base.py", line 193, in _send_with_retry
response = await request()
File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1617, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 366, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request
raise exc
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request
stream = await self._connect(request)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 124, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
File "/usr/local/lib/python3.10/site-packages/httpcore/_backends/auto.py", line 31, in connect_tcp
return await self._backend.connect_tcp(
File "/usr/local/lib/python3.10/site-packages/httpcore/_backends/anyio.py", line 114, in connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
File "/usr/local/lib/python3.10/site-packages/anyio/_core/_sockets.py", line 221, in connect_tcp
await event.wait()
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1778, in wait
if await self._event.wait():
File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
await fut
asyncio.exceptions.CancelledError
Cody
09/26/2023, 5:47 AMNimesh
09/26/2023, 6:14 AMNoam Banay
09/26/2023, 1:01 PMVinicius Gambi
09/26/2023, 2:05 PMVinicius Gambi
09/26/2023, 2:10 PMJames
09/26/2023, 4:32 PMJosh Paulin
09/26/2023, 9:56 PMCody
09/26/2023, 10:57 PMKyle
09/27/2023, 3:36 AMradek jezek
09/27/2023, 9:09 AMPrabhatGupta
09/27/2023, 11:00 AMShane Breeze
09/27/2023, 12:45 PMAndrei Rediu
09/27/2023, 1:12 PMJetta
09/27/2023, 1:53 PM