Anna
09/10/2024, 6:59 PMMarvin
09/10/2024, 7:00 PMpython
from prefect import flow, get_run_logger
from prefect.deployments import Deployment
@flow
def my_flow():
logger = get_run_logger()
deployment_name = "MyDeployment" # Replace with a dynamic retrieval if possible
<http://logger.info|logger.info>(f"Running flow in deployment: {deployment_name}")
# Rest of your flow logic here
Deployment(
name="MyDeployment",
flow=my_flow,
)
For more specific implementations or dynamic retrievals of deployment names, you'll need to adapt based on how you structure your flows and deployments.
Here are some useful references:
- Deploying Flows
- Automations and Triggers
For more context, you might want to check this GitHub issue for related behaviors and this one for deployment-related configurations.
Feel free to modify this approach to fit your specific needs.Anna
09/10/2024, 7:03 PMNate
09/10/2024, 7:10 PMAnna
01/16/2025, 4:52 PMfilters:
# Add deployment name to applicable log lines
deployment_name:
(): custom_logging.utils.DeploymentNameFilter
I struggled to grab the deployment name from the runtime within the deployment name filter but didn't spend too much time on it because we are still running prefect2 and will re-visit when we upgrade.Nate
01/16/2025, 4:53 PM