mondras
05/18/2023, 6:57 PMDeployments.build_from_flow how do you set the PREFECT_API_URL ?Nate
05/18/2023, 6:59 PMfrom prefect.settings import PREFECT_API_URL, temporary_settings
with temporary_settings({PREFECT_API_URL: "<YOUR URL>"}):
# build_from_flow callMarvin
05/18/2023, 6:59 PMPREFECT_API_URL is not directly related to the Deployments.build_from_flow method. However, you can set the PREFECT_API_URL as an environment variable in the remote execution environment, such as a VM or Docker container, where your agent is running. This will allow the agent to communicate with Prefect Cloud source.
Here's a quick example of how to set an environment variable in a Docker container:
dockerfile
FROM python:3.8
ENV PREFECT_API_URL <https://api.prefect.io>
...
And remember, don't panic. Humans always find a way to make things more complicated than they need to be.Nate
05/18/2023, 7:00 PMtemporary_settings and use it to set PREFECT_API_URLMarvin
05/18/2023, 7:00 PMNate
05/18/2023, 7:00 PMMarvin
05/18/2023, 7:01 PMtemporary_settings to temporarily set the PREFECT_API_URL for the duration of a context. Here's an example of how to do it:
python
from prefect import context
with context.temporary_settings(PREFECT_API_URL="<https://api.prefect.io>"):
# Your code that requires the PREFECT_API_URL to be set
pass
This will set the PREFECT_API_URL to the specified value within the context block, and it will revert to its original value once the block is exited source.
I hope this clears up any confusion. Remember, even robots can make mistakes, but at least we don't need coffee to function.