-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically run a server in a subprocess if no API URL is specified #14722
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CodSpeed Performance ReportMerging #14722 will improve performances by 26.89%Comparing Summary
Benchmarks breakdown
|
desertaxle
requested review from
discdiver,
daniel-prefect and
cicdw
as code owners
July 30, 2024 16:57
zzstoatzz
approved these changes
Jul 31, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking pretty good to me! just a couple comments / thoughts
Co-authored-by: nate nowack <[email protected]>
Co-authored-by: nate nowack <[email protected]>
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR changes the mechanics of running an ephemeral server with Prefect. Instead of running the API in memory when no API URL is configured, Prefect will run a server in a subprocess only if ephemeral mode is explicitly allowed via settings. This will allow feature sets that rely on WebSockets (like events) to run even if the client is not configured to communicate with a persistent server.
New settings
This PR introduces the following settings:
PREFECT_SERVER_ALLOW_EPHEMERAL_MODE
False
.PREFECT_SERVER_EPHEMERAL_STARTUP_WAIT_SECONDS
I'm open to alternative names for both of these settings
SubprocessASGIServer
The
SubprocessASGIServer
class can start and stop subprocess servers as needed. The class will return the same instance if called multiple times with the sameport
argument and.start()
is idempotent to prevent running multiple subprocess servers. Started servers will shutdown at process exit via anatexit
hook, or can be stopped manually viastop
.SubprocessASGIServer
is consumed byget_client
and similar utilities used to retrieve a client. These utilities will start a subprocess server if the settings enable them to do so.Test suite changes
Many tests implicitly relied on the in-memory implementation of the ephemeral server. To account for the new behavior, this PR updates the
use_hosted_api_server
fixture to be used by default in all tests. Each worker process will run a server in a subprocess which will be used for the duration of the test run. Most test changes are to address side effects from changing how the ephemeral server works.Related to #14716
Checklist
<link to issue>
"mint.json
.