Enda Peng
04/28/2021, 8:51 PMwith Flow("Demo") as flow:
for_date = Parameter('for_date', required=True, default='20200101')
for_date_str = dt.datetime.strptime(for_date, "%Y%m%d")
Enda Peng
04/28/2021, 8:54 PMKevin Kho
for_date
is a deferred execution that is population at runtime while for_date_str
happens at run time. You would need to create a helper task to perform that operation and then return it so that the execution gets deferred as wellKevin Kho
@task
def string_to_time(for_date):
return dt.datetime.strptime(for_date, "%Y%m%d")
with Flow("Demo") as flow:
for_date = Parameter('for_date', required=True, default='20200101')
for_date_str = string_to_time(for_date)
Enda Peng
04/28/2021, 8:56 PMnature
wayKevin Kho
nature
wayEnda Peng
04/28/2021, 8:57 PMJimmy Le
04/30/2021, 1:20 PMJimmy Le
04/30/2021, 1:22 PMParameter('end_date', default=date().today().strptime(...))
the default date is static to when I deployed the flow.Kevin Kho
Kevin Kho
import pendulum
date = Parameter(name="date", default="yesterday")
@task
def generate_date(date_parameter):
if date_parameter == 'yesterday'
return pendulum.now().subtract(days=1)
return pendulum.parse(date_parameter)
Jimmy Le
04/30/2021, 1:39 PM