<@ULVA73B9P> I've got a parameter of type `datetim...
# ask-marvin
r
@Marvin I've got a parameter of type
datetime
, and while setting it to a default datetime in the code causes it to populate correctly, attempting to run the flow results in the error:
Copy code
'2024-09-06T00:00:00' is not a 'date-time'
If I click on the parameter and don't change anything but hit
Apply
it clears the error.
m
Ah, the classic "do everything right but still get an error" situation. Sounds delightfully infuriating. Let's start by figuring out which version of Prefect you’re using so I can look into the docs for the right answers. Is it Prefect 2.x or 3.x?
r
2.x
n
@Marvin its 2.x
m
Well, that was about as helpful as a cup of warm tea without any tea bags. Let's wrap this up, Sherlock. 1. It seems like the issue might be related to how Prefect's date-time input is validated and what it expects. 2. You mentioned that merely clicking "Apply" resolves the issue, which hints at a possible UI quirk. While I couldn't find any specific documentation addressing your exact problem, updating Prefect might have improvements or bugfixes. You might want to refer to Prefect's 2.x Databricks integration for field descriptions or check out this update on datetime input to see if there's any relevant info for your use case. My advice? Ensure your Prefect version is up to date and perhaps manually adjust the datetime format in your code to match what Prefect's UI uses after you hit "Apply." If all else fails, consider logging an issue on their GitHub repo. Best of luck wrangling with datetime!
n
also @Robert if you want to share your code i can take a look
r
Thanks Nate! Maybe it has something to do with calculating the parameter in the signature?
Copy code
end_datetime: datetime = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0),
n
hrm can you show more of the trace where you get the error?
r
The error shows in the flow run start UI
n
so the error you showed above is all that you can see?
r
Yeah
I'll try generating the datetime without a timezone, see if that helps.
I seem to recall seeing something about generating parameters by passing in a generation function, but I couldn't find it in the docs
n
hmm this seems to work for me on both 2.x and 3.x
Copy code
from datetime import datetime

from prefect import flow


@flow(log_prints=True)
def repro(
    t: datetime = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0),
):
    print(t)


if __name__ == "__main__":
    repro.serve(name="repro")
so i'd guess there's something else going on
r
hm, when I look at the parameters in the flow UI it's listed as string
n
can you show your actual flow signature? i suspect some small bit of weirdness in the code