prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  PrefectHTTPStatusError: Client error '429 Too Many Requests' for url
  ### First check
  
  - [X] I added a descriptive title to this issue.
  - [X] I used the GitHub search to find a similar issue and didn't find it.
  - [X] I searched the Prefect documentation for this issue.
  - [X] I checked that this issue is related to Prefect and not one of its dependencies.
  
  ### Bug summary
  
  While using `prefect` with `prefect-dask` I encountered a rate limit error. this shouldn't be happening as prefect client base should retry on those. I'm not sure why this is happening but this has risen at `2.10.10` and did not exist before
  
  ### Reproduction
  
  ```python3
  Any Flow with prefect-dask
  ```
  
  
  ### Error
  
  ```python3
  Traceback (most recent call last):
    File "/usr/local/lib/python3.11/dist-packages/distributed/client.py", line 1697, in _close
      await self.scheduler_comm.close()
  asyncio.exceptions.CancelledError
  01:00:08.452 | ERROR   | Flow run 'psi5-alastria-x' - Crash detected! Execution was interrupted by an unexpected exception: PrefectHTTPStatusError: Client error '429 Too Many Requests' for url 'https://cloud-url/task_runs/'
  Response: {'detail': 'Orchestration API rate limit reached'}
  For more information check: https://httpstatuses.com/429
  ```
  
  
  ### Versions
  
  ```Text
  Version:             2.10.10
  API version:         0.8.4
  Python version:      3.11.2
  Git commit:          8159450b
  Built:               Thu, May 18, 2023 3:43 PM
  OS/Arch:             linux/x86_64
  Profile:             default
  Server type:         server
  ```
  
  
  ### Additional context
  
  _No response_
  
  </issue>
  <code>
  [start of src/prefect/client/cloud.py]
  1 import re
  2 from typing import Any, Dict, List, Optional
  3 
  4 import anyio
  5 import httpx
  6 import pydantic
  7 from fastapi import status
  8 
  9 import prefect.context
  10 import prefect.settings
  11 from prefect.client.schemas import Workspace
  12 from prefect.exceptions import PrefectException
  13 from prefect.settings import PREFECT_API_KEY, PREFECT_CLOUD_API_URL
  14 
  15 
  16 def get_cloud_client(
  17     host: Optional[str] = None,
  18     api_key: Optional[str] = None,
  19     httpx_settings: Optional[dict] = None,
  20     infer_cloud_url: bool = False,
  21 ) -> "CloudClient":
  22     """
  23     Needs a docstring.
  24     """
  25     if httpx_settings is not None:
  26         httpx_settings = httpx_settings.copy()
  27 
  28     if infer_cloud_url is False:
  29         host = host or PREFECT_CLOUD_API_URL.value()
  30     else:
  31         configured_url = prefect.settings.PREFECT_API_URL.value()
  32         host = re.sub(r"accounts/.{36}/workspaces/.{36}\Z", "", configured_url)
  33 
  34     return CloudClient(
  35         host=host,
  36         api_key=api_key or PREFECT_API_KEY.value(),
  37         httpx_settings=httpx_settings,
  38     )
  39 
  40 
  41 class CloudUnauthorizedError(PrefectException):
  42     """
  43     Raised when the CloudClient receives a 401 or 403 from the Cloud API.
  44     """
  45 
  46 
  47 class CloudClient:
  48     def __init__(
  49         self,
  50         host: str,
  51         api_key: str,
  52         httpx_settings: dict = None,
  53     ) -> None:
  54         httpx_settings = httpx_settings or dict()
  55         httpx_settings.setdefault("headers", dict())
  56         httpx_settings["headers"].setdefault("Authorization", f"Bearer {api_key}")
  57 
  58         httpx_settings.setdefault("base_url", host)
  59         self._client = httpx.AsyncClient(**httpx_settings)
  60 
  61     async def api_healthcheck(self):
  62         """
  63         Attempts to connect to the Cloud API and raises the encountered exception if not
  64         successful.
  65 
  66         If successful, returns `None`.
  67         """
  68         with anyio.fail_after(10):
  69             await self.read_workspaces()
  70 
  71     async def read_workspaces(self) -> List[Workspace]:
  72         return pydantic.parse_obj_as(List[Workspace], await self.get("/me/workspaces"))
  73 
  74     async def read_worker_metadata(self) -> Dict[str, Any]:
  75         return await self.get("collections/views/aggregate-worker-metadata")
  76 
  77     async def __aenter__(self):
  78         await self._client.__aenter__()
  79         return self
  80 
  81     async def __aexit__(self, *exc_info):
  82         return await self._client.__aexit__(*exc_info)
  83 
  84     def __enter__(self):
  85         raise RuntimeError(
  86             "The `CloudClient` must be entered with an async context. Use 'async "
  87             "with CloudClient(...)' not 'with CloudClient(...)'"
  88         )
  89 
  90     def __exit__(self, *_):
  91         assert False, "This should never be called but must be defined for __enter__"
  92 
  93     async def get(self, route, **kwargs):
  94         try:
  95             res = await self._client.get(route, **kwargs)
  96             res.raise_for_status()
  97         except httpx.HTTPStatusError as exc:
  98             if exc.response.status_code in (
  99                 status.HTTP_401_UNAUTHORIZED,
  100                 status.HTTP_403_FORBIDDEN,
  101             ):
  102                 raise CloudUnauthorizedError
  103             else:
  104                 raise exc
  105 
  106         return res.json()
  107
  [end of src/prefect/client/cloud.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/prefect/client/cloud.py b/src/prefect/client/cloud.py
  --- a/src/prefect/client/cloud.py
  +++ b/src/prefect/client/cloud.py
  @@ -8,6 +8,7 @@
   
   import prefect.context
   import prefect.settings
  +from prefect.client.base import PrefectHttpxClient
   from prefect.client.schemas import Workspace
   from prefect.exceptions import PrefectException
   from prefect.settings import PREFECT_API_KEY, PREFECT_CLOUD_API_URL
  @@ -56,7 +57,7 @@
           httpx_settings["headers"].setdefault("Authorization", f"Bearer {api_key}")
   
           httpx_settings.setdefault("base_url", host)
  -        self._client = httpx.AsyncClient(**httpx_settings)
  +        self._client = PrefectHttpxClient(**httpx_settings)
   
       async def api_healthcheck(self):
           """
  
verification_info: {"golden_diff": "diff --git a/src/prefect/client/cloud.py b/src/prefect/client/cloud.py\n--- a/src/prefect/client/cloud.py\n+++ b/src/prefect/client/cloud.py\n@@ -8,6 +8,7 @@\n \n import prefect.context\n import prefect.settings\n+from prefect.client.base import PrefectHttpxClient\n from prefect.client.schemas import Workspace\n from prefect.exceptions import PrefectException\n from prefect.settings import PREFECT_API_KEY, PREFECT_CLOUD_API_URL\n@@ -56,7 +57,7 @@\n         httpx_settings[\"headers\"].setdefault(\"Authorization\", f\"Bearer {api_key}\")\n \n         httpx_settings.setdefault(\"base_url\", host)\n-        self._client = httpx.AsyncClient(**httpx_settings)\n+        self._client = PrefectHttpxClient(**httpx_settings)\n \n     async def api_healthcheck(self):\n         \"\"\"\n", "issue": "PrefectHTTPStatusError: Client error '429 Too Many Requests' for url\n### First check\r\n\r\n- [X] I added a descriptive title to this issue.\r\n- [X] I used the GitHub search to find a similar issue and didn't find it.\r\n- [X] I searched the Prefect documentation for this issue.\r\n- [X] I checked that this issue is related to Prefect and not one of its dependencies.\r\n\r\n### Bug summary\r\n\r\nWhile using `prefect` with `prefect-dask` I encountered a rate limit error. this shouldn't be happening as prefect client base should retry on those. I'm not sure why this is happening but this has risen at `2.10.10` and did not exist before\r\n\r\n### Reproduction\r\n\r\n```python3\r\nAny Flow with prefect-dask\r\n```\r\n\r\n\r\n### Error\r\n\r\n```python3\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.11/dist-packages/distributed/client.py\", line 1697, in _close\r\n    await self.scheduler_comm.close()\r\nasyncio.exceptions.CancelledError\r\n01:00:08.452 | ERROR   | Flow run 'psi5-alastria-x' - Crash detected! Execution was interrupted by an unexpected exception: PrefectHTTPStatusError: Client error '429 Too Many Requests' for url 'https://cloud-url/task_runs/'\r\nResponse: {'detail': 'Orchestration API rate limit reached'}\r\nFor more information check: https://httpstatuses.com/429\r\n```\r\n\r\n\r\n### Versions\r\n\r\n```Text\r\nVersion:             2.10.10\r\nAPI version:         0.8.4\r\nPython version:      3.11.2\r\nGit commit:          8159450b\r\nBuilt:               Thu, May 18, 2023 3:43 PM\r\nOS/Arch:             linux/x86_64\r\nProfile:             default\r\nServer type:         server\r\n```\r\n\r\n\r\n### Additional context\r\n\r\n_No response_\n", "before_files": [{"content": "import re\nfrom typing import Any, Dict, List, Optional\n\nimport anyio\nimport httpx\nimport pydantic\nfrom fastapi import status\n\nimport prefect.context\nimport prefect.settings\nfrom prefect.client.schemas import Workspace\nfrom prefect.exceptions import PrefectException\nfrom prefect.settings import PREFECT_API_KEY, PREFECT_CLOUD_API_URL\n\n\ndef get_cloud_client(\n    host: Optional[str] = None,\n    api_key: Optional[str] = None,\n    httpx_settings: Optional[dict] = None,\n    infer_cloud_url: bool = False,\n) -> \"CloudClient\":\n    \"\"\"\n    Needs a docstring.\n    \"\"\"\n    if httpx_settings is not None:\n        httpx_settings = httpx_settings.copy()\n\n    if infer_cloud_url is False:\n        host = host or PREFECT_CLOUD_API_URL.value()\n    else:\n        configured_url = prefect.settings.PREFECT_API_URL.value()\n        host = re.sub(r\"accounts/.{36}/workspaces/.{36}\\Z\", \"\", configured_url)\n\n    return CloudClient(\n        host=host,\n        api_key=api_key or PREFECT_API_KEY.value(),\n        httpx_settings=httpx_settings,\n    )\n\n\nclass CloudUnauthorizedError(PrefectException):\n    \"\"\"\n    Raised when the CloudClient receives a 401 or 403 from the Cloud API.\n    \"\"\"\n\n\nclass CloudClient:\n    def __init__(\n        self,\n        host: str,\n        api_key: str,\n        httpx_settings: dict = None,\n    ) -> None:\n        httpx_settings = httpx_settings or dict()\n        httpx_settings.setdefault(\"headers\", dict())\n        httpx_settings[\"headers\"].setdefault(\"Authorization\", f\"Bearer {api_key}\")\n\n        httpx_settings.setdefault(\"base_url\", host)\n        self._client = httpx.AsyncClient(**httpx_settings)\n\n    async def api_healthcheck(self):\n        \"\"\"\n        Attempts to connect to the Cloud API and raises the encountered exception if not\n        successful.\n\n        If successful, returns `None`.\n        \"\"\"\n        with anyio.fail_after(10):\n            await self.read_workspaces()\n\n    async def read_workspaces(self) -> List[Workspace]:\n        return pydantic.parse_obj_as(List[Workspace], await self.get(\"/me/workspaces\"))\n\n    async def read_worker_metadata(self) -> Dict[str, Any]:\n        return await self.get(\"collections/views/aggregate-worker-metadata\")\n\n    async def __aenter__(self):\n        await self._client.__aenter__()\n        return self\n\n    async def __aexit__(self, *exc_info):\n        return await self._client.__aexit__(*exc_info)\n\n    def __enter__(self):\n        raise RuntimeError(\n            \"The `CloudClient` must be entered with an async context. Use 'async \"\n            \"with CloudClient(...)' not 'with CloudClient(...)'\"\n        )\n\n    def __exit__(self, *_):\n        assert False, \"This should never be called but must be defined for __enter__\"\n\n    async def get(self, route, **kwargs):\n        try:\n            res = await self._client.get(route, **kwargs)\n            res.raise_for_status()\n        except httpx.HTTPStatusError as exc:\n            if exc.response.status_code in (\n                status.HTTP_401_UNAUTHORIZED,\n                status.HTTP_403_FORBIDDEN,\n            ):\n                raise CloudUnauthorizedError\n            else:\n                raise exc\n\n        return res.json()\n", "path": "src/prefect/client/cloud.py"}]}