Hi everyone! How can I create a variable (<this> o...
# ask-community
g
Hi everyone! How can I create a variable (this one) using python package prefect 2.10.10?
f
you probably can use client
from prefect import get_client
IIRC
g
ah right, totally forgot, thanks!
@flapili unfortunately there is no api to create a variable using the client
there are only read methods
f
then grab httpx session from client and do a http requests
it's a little ugly but it should work
g
never done that, do you have a snippet of code as example?
f
instead client will come from an attribut of the prefect client
g
should I use async from inside a task?
f
probably
I believe prefect client use a httpx async session
aren't you sure you won't need block instead ?
variable is for var templating of projects primary if I understood correctly
g
yes, I just want to save a flow parameter (like start date), to be able to make the flow extracting data from the value stores in the variable
or maybe a json with a couple of parameters
f
then use a json block ?
g
lol I didn’t know the existence of that, maybe that is better
the conversion would be free
then what are variables for?
f
to me (but I maybe missunderstood) it's usefull to bootstrap prefets's projects
g
generally speaking then I would use variable to save global configuration, I mean a parameter that should have the same value for every flow