Are `pendulum.Date` objects supported as Prefect f...
# prefect-ui
j
Are
pendulum.Date
objects supported as Prefect flow parameters? I ask because the UI looks a little broken even though the flow was deployed. You can see that the type switcher doesn't have the type label at all, and the input throws an error.
n
hi @Jacob Blanco can you show your flow signature? this appears to work for me
Copy code
from pendulum import Date

from prefect import flow


@flow
def test_datetime_param(dt: Date):
    print(dt)


if __name__ == "__main__":
    test_datetime_param.serve(parameters={"dt": Date.today()})
j
Interesting. Let me dig into it. This was reported by one of our data scientists so I don't have the code in front of me.
👍 1
I went ahead and created a dummy flow to test various combinations of providing parameters Code is below.
Copy code
import pendulum
import prefect
from pendulum import DateTime
from prefect import flow
from pydantic import BaseModel, Field


class ExampleFlowParams(BaseModel):
    name: str = Field(description="The name of the birthday celebrator")
    dob: pendulum.Date = Field(description="Date of Birth")
    birthday_msg: str = "Happy birthday!",
    planned_birthday_party_date: DateTime | None = Field(description="When the party will happen, if any.", default=None)

    # @todo Can be removed once we update to Prefect 3.1.4 (that turns this on by default)
    class Config:
        arbitrary_types_allowed = True


@flow(name="Parameters Example Flow")
def parameters_example_flow(
    name: str,
    dob: pendulum.Date,
    params: ExampleFlowParams,
    planned_birthday_party_date: pendulum.DateTime | None = None,
    birthday_msg: str = "Happy birthday!",
):
    logger = prefect.get_run_logger()
    logger.info(f"{birthday_msg} {name} ({dob})!")
    if params.planned_birthday_party_date:
        logger.info(f"Looking forward to your party on {params.planned_birthday_party_date} or {planned_birthday_party_date}.")
You can see the result in the UI, a few things to highlight: • Seems like
DateTime
doesn't work either in a model or in the function arguments. Selecting the empty type label in the field results in an empty text box with
null
in the field being shown. • Date works as you've shown when it's defined as a function argument but not in a model. •
Happy new year! Any thoughts?