Jacob Blanco
12/19/2024, 2:24 AMpendulum.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.Nate
12/19/2024, 4:28 PMfrom 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()})
Jacob Blanco
12/20/2024, 12:56 AMJacob Blanco
12/20/2024, 2:45 AMimport 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.
•Jacob Blanco
01/06/2025, 1:43 AM