KG
07/22/2025, 3:08 PMprefect.exceptions.PrefectHTTPStatusError: Client error '404 Not Found' for url '<https://api.prefect.cloud/api/accounts/abc/workspaces/abc/deployments/40c948a1-0f0b-4e10-8f00-87bcaa3e6ce8>'
Marvin
07/22/2025, 3:08 PMMarvin
07/22/2025, 3:08 PMClient error '404 Not Found' for url '<https://api.prefect.cloud/api/accounts/abc/workspaces/abc/deployments/40c948a1-0f0b-4e10-8f00-87bcaa3e6ce8>'
Here are the most likely causes and solutions:
1. Deployment Does Not Exist:
- The deployment ID 40c948a1-0f0b-4e10-8f00-87bcaa3e6ce8
cannot be found in your Prefect Cloud workspace
- This could happen if:
- The deployment was deleted
- The deployment failed to register properly
- You're accessing the wrong workspace
2. Authentication/Authorization Issues:
- Verify that your worker has the correct API key configured
- Ensure the API key has access to the correct workspace
To troubleshoot:
1. Verify the Deployment:
- Check if the deployment exists in the Prefect UI
- You can also verify using the CLI:
bash
prefect deployment ls
2. Check Worker Configuration:
- Verify the worker is connected to the correct workspace
- Ensure the PREFECT_API_KEY and PREFECT_API_URL are correctly set in your worker pod
- Check the worker logs for any authentication-related messages
3. Verify Workspace:
- Confirm you're in the correct workspace using:
bash
prefect workspace ls
4. If Creating a New Deployment:
- Ensure you're using the correct deployment creation syntax for Prefect 3.x:
python
flow.from_source(...).deploy(...)
Would you like me to help you verify any specific part of this setup or would you like more details about any of these troubleshooting steps?Kevin Grismore
07/22/2025, 3:09 PMKG
07/22/2025, 3:23 PMMarvin
07/22/2025, 3:23 PMMarvin
07/22/2025, 3:24 PMpython
from prefect.client import get_client
from typing import List
from prefect.client.schemas.objects import DeploymentResponse
async def list_active_deployments() -> List[DeploymentResponse]:
"""
Lists all active deployments using the async Prefect client.
Returns:
List[DeploymentResponse]: A list of deployment objects containing deployment details
Example:
```python
import asyncio
# Run the function
deployments = asyncio.run(list_active_deployments())
# Print deployment details
for deployment in deployments:
print(f"Name: {deployment.name}")
print(f"ID: {deployment.id}")
print(f"Work Pool: {deployment.work_pool_name}")
print("---")
"""
async with get_client() as client:
# Fetch all deployments
deployments = await client.read_deployments()
return deployments
# If you want to run this directly (not imported as a module)
if name == "__main__":
import asyncio
async def main():
deployments = await list_active_deployments()
for deployment in deployments:
print(f"Name: {deployment.name}")
print(f"ID: {deployment.id}")
print(f"Work Pool: {deployment.work_pool_name}")
print("---")
asyncio.run(main())
This function:
1. Uses the `get_client()` function to create a Prefect client instance
2. Uses async context manager to properly manage the client connection
3. Calls `read_deployments()` to fetch all deployments
4. Returns the list of deployments as `DeploymentResponse` objects
Each `DeploymentResponse` object contains useful information about the deployment, including:
- `name`: The deployment name
- `id`: The deployment ID
- `work_pool_name`: The associated work pool
- `version`: The deployment version
- `tags`: Any associated tags
- And more...
If you want to filter the deployments, you can add filters to the `read_deployments()` call. For example, to filter by work pool:
```python
async def list_deployments_by_work_pool(work_pool_name: str) -> List[DeploymentResponse]:
async with get_client() as client:
deployments = await client.read_deployments(
work_pool_filter={"name": {"any_": [work_pool_name]}}
)
return deployments
Would you like me to explain any part of this in more detail or show you how to add specific filters to the query?