@Marvin
in the old version 1 of prefect it was possible to call
prefect.context.get("my_variable")
to get a variable handed over via the UI.
What can I use in version 3 to do the same?
m
Marvin
03/24/2025, 9:51 AM
In Prefect 3.x, you can manage and access variables through the Prefect UI, API, CLI, and directly in your Python code. To access these variables in your code, you can use the Prefect Python SDK's methods for interacting with variables.
Here's how you can retrieve a variable's value in Python:
Copy code
python
from prefect import variables
value = variables.get("my_variable")
This method allows you to access variables that are set in the Prefect UI or through other interfaces like the CLI.
For more information, you can refer to the Prefect 3.x documentation on variables.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.