https://prefect.io logo
d

Dimosthenis Schizas

02/07/2021, 12:19 AM
Hi everyone, sorry if my question is really dumb, but I couldn't find anything in the documentation. How can I register a flow with a date parameter, that will run on a schedule and will have by default the date of running. When i create the parameter like this:
Copy code
auction_date = Parameter(
        "auction_date", default=prefect.context.date.date()
    )
I get the following error message when trying to register:
Copy code
AttributeError: 'Context' object has no attribute 'date'
I am missing something here
a

Amanda Wee

02/07/2021, 12:21 AM
My approach was to give the parameter a
None
default, then pass it to a task that returns the actual date to use, i.e., the parameter value if it is not
None
, otherwise the current date.
👀 1
d

Dimosthenis Schizas

02/07/2021, 12:31 AM
Sounds like a good plan, thanks!
Hello again, it seems that this solution didn't work. I'm passing by default
None
and calling a task, which unfortunately never returns the current data.
from_date = Parameter("from_date", default=None)
Sorry, it was a typo after all
3 Views