Skip to content

Commit

Permalink
Remove PrefectHttpxSyncEphemeralClient (#14823)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz authored Aug 1, 2024
1 parent c539c4e commit bef9e21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 37 deletions.
28 changes: 0 additions & 28 deletions src/prefect/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from asgi_lifespan import LifespanManager
from httpx import HTTPStatusError, Request, Response
from starlette import status
from starlette.testclient import TestClient
from typing_extensions import Self

import prefect
Expand Down Expand Up @@ -616,33 +615,6 @@ def _add_csrf_headers(self, request: Request):
request.headers["Prefect-Csrf-Client"] = str(self.csrf_client_id)


class PrefectHttpxSyncEphemeralClient(TestClient, PrefectHttpxSyncClient):
"""
This client is a synchronous httpx client that can be used to talk directly
to an ASGI app, such as an ephemeral Prefect API.
It is a subclass of both Starlette's `TestClient` and Prefect's
`PrefectHttpxSyncClient`, so it combines the synchronous testing
capabilities of `TestClient` with the Prefect-specific behaviors of
`PrefectHttpxSyncClient`.
"""

def __init__(
self,
*args,
# override TestClient default
raise_server_exceptions=False,
**kwargs,
):
super().__init__(
*args,
raise_server_exceptions=raise_server_exceptions,
**kwargs,
)

pass


class ServerType(AutoEnum):
EPHEMERAL = AutoEnum.auto()
SERVER = AutoEnum.auto()
Expand Down
12 changes: 3 additions & 9 deletions src/prefect/client/orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
ASGIApp,
PrefectHttpxAsyncClient,
PrefectHttpxSyncClient,
PrefectHttpxSyncEphemeralClient,
ServerType,
app_lifespan_context,
)
Expand Down Expand Up @@ -3493,14 +3492,9 @@ def __init__(
and PREFECT_CLIENT_CSRF_SUPPORT_ENABLED.value()
)

if self.server_type == ServerType.EPHEMERAL:
self._client = PrefectHttpxSyncEphemeralClient(
api, base_url="http://ephemeral-prefect/api"
)
else:
self._client = PrefectHttpxSyncClient(
**httpx_settings, enable_csrf_support=enable_csrf_support
)
self._client = PrefectHttpxSyncClient(
**httpx_settings, enable_csrf_support=enable_csrf_support
)

# See https://www.python-httpx.org/advanced/#custom-transports
#
Expand Down

0 comments on commit bef9e21

Please sign in to comment.