<@ULVA73B9P> prefect seems to ignore the job varia...
# ask-marvin
c
@Marvin prefect seems to ignore the job variable or its value when I input it in the UI in the Job variables section. I added the variable under the settings page and reference it in the flow run code with
mybool = Variable.get("mybool", default=True)
. What am I missing?
m
It seems you're trying to use Prefect's job variables, but you might be mixing up the concepts of job variables and Prefect's variable system. Here's what you need to know: 1. Job Variables vs. Prefect Variables: Job variables are meant to be passed during deployment or run time to configure infrastructure or environment settings. They can be overridden using the UI or CLI when initiating a flow run. Prefect's
Variable.get()
method, on the other hand, is used to retrieve variables stored in Prefect's variable storage, not job variables. 2. Using Job Variables: When deploying a flow, you can define job variables in the
prefect.yaml
file or pass them as a dictionary to the
job_variables
argument of the
.deploy()
method. These are then visible in the UI under the Configuration tab and can be overridden for specific flow runs. 3. Using Prefect Variables: To use Prefect's variable system, make sure you've set up the variable correctly using the Prefect CLI or API. The method
Variable.get("mybool", default=True)
will fetch a variable named "mybool" if it exists in Prefect's variable storage. For job variables, ensure they are correctly defined in the deployment configuration and passed during the flow run. For more details on customizing job variables, you can refer to the Prefect documentation. If you're specifically trying to use Prefect's variable storage, ensure the variable "mybool" is set up in the Prefect server or cloud environment where your flow is running. If it doesn't exist, the default value
True
will be used. If you need further assistance, feel free to ask!
n
hi @Conrad F - this is a common point of confusion https://prefect-community.slack.com/archives/CL09KU1K7/p1741965196739459
c
thanks @Nate, that was helpful to get a better undertanding of the different concepts 👍