[X] I used the GitHub search to find a similar issue and didn't find it.
[X] I searched the Prefect documentation for this issue.
[X] I checked that this issue is related to Prefect and not one of its dependencies.
Bug summary
I am encountering an issue with the date picker in the UI when submitting a run. The flow takes two datetime inputs, but it doesn't seem to work correctly with the date picker when using datetime.now() without a timezone.
Reproduction
from datetime import datetime, timedelta
from prefect import flow
@flow(retries=2)
def backfill(
since: datetime = (datetime.now() - timedelta(days=20)),
until: datetime = datetime.now(),
):
print(f"Running backfill from {since} to {until}")
if __name__ == "__main__":
backfill.serve()
Error
N/A (Issue is with date picker validation)
Versions
Version: 2.19.4
API version: 0.8.4
Python version: 3.9.19
Git commit: 867543a8
Built: Tue, Jun 4, 2024 3:14 PM
OS/Arch: darwin/arm64
Profile: sandbox
Server type: cloud
Additional context
The issue seems to be related to datetime.now() not having a timezone. Below is an updated version of the flow that works fine:
from datetime import UTC, datetime, timedelta
from prefect import flow
@flow(log_prints=True)
def backfill(
since: datetime = (datetime.now(UTC) - timedelta(days=20)),
until: datetime = datetime.now(UTC),
):
print(f"Running backfill from {since} to {until}")
if __name__ == "__main__":
backfill.serve()
The UI's date picker and the schema's datetime formats are not aligning properly, leading to validation errors.
First check
Bug summary
I am encountering an issue with the date picker in the UI when submitting a run. The flow takes two datetime inputs, but it doesn't seem to work correctly with the date picker when using
datetime.now()
without a timezone.Reproduction
Error
Versions
Additional context
The issue seems to be related to
datetime.now()
not having a timezone. Below is an updated version of the flow that works fine:The UI's date picker and the schema's datetime formats are not aligning properly, leading to validation errors.