Hey all, what is the best practice for creating va...
# ask-community
j
Hey all, what is the best practice for creating variables (i.e. date stamp) that you want to re-use across tasks? I can't just declare the variable as the date stamp doesn't update after the initial registry.
w
It sounds like Parameters are what you want, to me: https://docs.prefect.io/core/concepts/parameters.html
k
Hey @Jelle Vegter, if it’s not updating after initial registry, you likely did something like
time = Parameter("time", default=datetime.datetime.now())
. Prefect serializes your Flow so this value is evaluated during registration. You have two options. The first is storing you Flow as a script. See this . The second is deferring the evaluation of
datetime.datetime.now()
to a task. So you can do
time = Parameter("time", default="now")
, and then have a task that returns
datetime.datetime.now()
is the value is “now”
j
Thanks both!