Jahn Thomas Fidje
08/24/2024, 7:17 AMdate.today()
when the flow runs.
Currently I solve this by defaulting the date-parameter to None
and replacing it with date.today()
inside the flow if this is the case. This works fine, but I would really like a way to populate the parameters tab in the UI with the actual parameters used in the flow.
Is there a better way to do dynamic parameters like this?Nate
08/24/2024, 5:39 PMThis works fine, but I would really like a way to populate the parameters tab in the UI with the actual parameters used in the flow.i.e. what's your flow signature and whats the ideal UX for running your flow from the UI?
Jahn Thomas Fidje
08/25/2024, 6:29 AMend_date
was set to during the scheduled runNate
08/25/2024, 5:31 PMrun_deployment
to programmatically schedule your runs instead of using the schedule, where you can provide the end_date
explicitly and it will show upJahn Thomas Fidje
08/25/2024, 7:59 PMdefault_factory
defined with a Field()
, but that did not work as expected either šNate
08/25/2024, 8:09 PMfrom datetime import timedelta
from typing import Literal
from pydantic import BaseModel, Field
from pydantic_extra_types.pendulum_dt import DateTime
from prefect import flow
class NiceDateParams(BaseModel):
area: Literal["sand", "snow", "ice"]
currency: Literal["usd", "eur", "jpy"]
start_date: DateTime = Field(
default_factory=lambda: DateTime.now() - timedelta(days=1)
)
end_date: DateTime = Field(default_factory=lambda: DateTime.now())
@flow(log_prints=True)
def f(params: NiceDateParams):
print(params)
if __name__ == "__main__":
f.serve()
pydantic is the right tool to get a nice form, but that doesn't really address the fact that you're not passing the value you want to see into the API (ie as logs or as parameters via run_deployment
or manual run)Jahn Thomas Fidje
08/27/2024, 5:47 AM