Allow setting PREFECT_SERVER_EPHEMERAL_STARTUP_TIMEOUT_SECONDS for prefect_test_harness
Bug summary
In the current Prefect RC (3.0.0rc19), usage of the prefect.testing.utilities.prefect_test_harness spins up a subprocess to start an API. There is neither a way to disable creation of this API, nor is there a way to affect the timeout of the subprocess using PREFECT_SERVER_EPHEMERAL_STARTUP_TIMEOUT_SECONDS, since the timeout is fixed to 30 seconds
On my notebook and our CI/CD this timeout is not sufficient to spin up the API, especially when debugging into the code. This causes an unavoidable (and flaky) RuntimeError.
One would expect, that one can use the settings to disable ephemeral api (PREFECT_SERVER_ALLOW_EPHEMERAL_MODE) or at least adjust the timeout of this api to ensure a consistent CI/CD behaviour.
Minimal example:
from prefect.testing.utilities import prefect_test_harness
def main():
with prefect_test_harness():
pass
if __name__ == "__main__":
main()
Result:
RuntimeError: Timed out while attempting to connect to ephemeral Prefect API server.
Version info (prefect version output)
Version: 3.0.0rc19
API version: 0.8.4
Python version: 3.11.9
Git commit: eac7892e
Built: Thu, Aug 22, 2024 10:02 AM
OS/Arch: linux/x86_64
Profile: default
Server type: cloud
Pydantic version: 2.8.2
Additional context
No response
Thanks for the issue @3XJuli! I think we could either update the prefect_test_harness to use the value of PREFECT_SERVER_EPHEMERAL_STARTUP_TIMEOUT_SECONDS internally and/or allow a timeout to be passed in. Would you be up to submitting a PR to add that functionality?