Piotr
07/02/2025, 6:42 AMMarvin
07/02/2025, 6:42 AMMarvin
07/02/2025, 6:43 AMlog_prints=True
as the default:
1. Using Environment Variables:
Add this to your Helm values file under the server.env
section:
yaml
server:
env:
PREFECT_LOGGING_LOG_PRINTS: "True"
2. Using a Profile Configuration:
You can set this in your Prefect profile configuration. Either:
a. Modify your profile settings via CLI:
bash
prefect config set PREFECT_LOGGING_LOG_PRINTS=True
b. Or directly edit your `~/.prefect/profiles.toml`:
toml
[profiles.default]
PREFECT_LOGGING_LOG_PRINTS = true
The environment variable approach through Helm is recommended for server-wide settings, as it will apply to all flows running in that environment. The profile configuration approach is more suitable for local development or when you want different settings for different environments.
Remember that this setting can still be overridden at the flow level using the log_prints
parameter in the @flow
decorator if needed:
python
@flow(log_prints=False)
def my_flow():
print("This won't be logged")
Would you like me to provide more details about any of these configuration methods?Piotr
07/02/2025, 7:31 AMMarvin
07/02/2025, 7:31 AMMarvin
07/02/2025, 7:32 AMyaml
worker:
env:
PREFECT_LOGGING_LOG_PRINTS: "true"
2. If you're using an agent, add:
yaml
agent:
env:
PREFECT_LOGGING_LOG_PRINTS: "true"
The reason your original configuration didn't work is that setting it only in the server.env
section affects the Prefect server itself, but not the actual flow executions which happen in the workers/agents.
Additionally, you can verify the setting is being picked up by:
1. Check the environment variables in your worker/agent pod:
bash
kubectl exec -it <worker-or-agent-pod-name> -- env | grep PREFECT_LOGGING
2. Add a test flow with a print statement to verify:
python
from prefect import flow
@flow
def test_flow():
print("Test print statement")
return "Done"
If you're still having issues after making these changes, could you let me know:
1. Whether you're using workers or agents
2. The relevant section of your values.yaml file
3. Whether you're seeing the environment variable in the pod when you check?Piotr
07/02/2025, 7:48 AMMarvin
07/02/2025, 7:48 AMMarvin
07/02/2025, 7:48 AMyaml
config:
env:
- name: PREFECT_LOGGING_LOG_PRINTS
value: "true"
Glad you got it working! The worker chart uses this array format to align with Kubernetes' native pod environment variable specification.