From bef9e216f802acc0d8d1efa4ce7623219873737d Mon Sep 17 00:00:00 2001 From: nate nowack Date: Thu, 1 Aug 2024 12:06:25 -0500 Subject: [PATCH] Remove `PrefectHttpxSyncEphemeralClient` (#14823) --- src/prefect/client/base.py | 28 ---------------------------- src/prefect/client/orchestration.py | 12 +++--------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/src/prefect/client/base.py b/src/prefect/client/base.py index b2e9c55eef7a..4a018e2f7352 100644 --- a/src/prefect/client/base.py +++ b/src/prefect/client/base.py @@ -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 @@ -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() diff --git a/src/prefect/client/orchestration.py b/src/prefect/client/orchestration.py index 53a0a98f562a..b23f56fbaa17 100644 --- a/src/prefect/client/orchestration.py +++ b/src/prefect/client/orchestration.py @@ -144,7 +144,6 @@ ASGIApp, PrefectHttpxAsyncClient, PrefectHttpxSyncClient, - PrefectHttpxSyncEphemeralClient, ServerType, app_lifespan_context, ) @@ -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 #