Slackbot
09/30/2024, 5:12 PMMarvin
09/30/2024, 5:13 PMtimeout_seconds
keyword argument in your flow definition. Here’s how you can do it in both Prefect 2.x and 3.x versions:
### Prefect 2.x
If you are using Prefect 2.x, you can set the timeout like this:
from prefect import flow
import time
@flow(timeout_seconds=600) # sets the timeout to 10 minutes
def my_flow():
print("Starting flow")
time.sleep(300) # simulate a long-running task
print("Flow completed")
Refer to the Prefect 2.x Timeout Documentation for more information.
### Prefect 3.x
If you are using Prefect 3.x, the syntax remains very similar:
from prefect import flow
import time
@flow(timeout_seconds=600) # sets the timeout to 10 minutes
def my_flow():
print("Starting flow")
time.sleep(300) # simulate a long-running task
print("Flow completed")
Refer to the Prefect 3.x Timeout Documentation for additional details.
By increasing the timeout_seconds
to a higher value, your flow execution will have a longer time window to complete, which should help address the timeout issues you are facing when pulling images on Kubernetes.
If these solutions do not address your specific issue, please feel free to provide additional details!