Hello All, I have a workflow which takes a date p...
# ask-the-community
c
Hello All, I have a workflow which takes a date parameter as a string. This workflow has a task which needs
date -1
as input. So when I use
datetime.strptime(date.get(), "%Y-%m-%d") - datetime.timedelta(days=1)
, Flyte throws
'Promise' object has no attribute 'get'
error. Using
datetime.strptime(date, "%Y-%m-%d") - datetime.timedelta(days=1)
throws
strptime() argument 1 must be str, not Promise
error. Any idea how to handle this isse?
Copy code
@workflow 
my_workflow(date: str, name: str) -> bool:
      yesterday = str(datetime.strptime(date.get(), "%Y-%m-%d") - datetime.timedelta(days=1))
      my_task(yesterday)

@task
my_task(yesterday: str):
   # task related code
s
Could you move the date manipulation to
my_task
?
date
and
name
in the workflow are promises, and the values will be materialized only in a task.
c
This task is being used by other workflows and tasks as well so if I change this task then it will affect all other workflow, need to make the change at many points.
it's sorted now 🙂 we just created a separate task where we can manipulate the dates.