Adding a Drop Down to your Deployment UI

By using the Literal type from the Python typing library, you can define a valid list of values that get rendered as a drop-down list in the prefect UI.


from prefect import flow
from typing import Literal

DropDownChoices = Literal["Prefect", "Python", "Pizza"]

@flow(name="Print-Drop-Down-Flow", log_prints=True)
def print_drop_down_flow(drop_down_choice: DropDownChoices = "Prefect"):
    print(f"The drop down choice was: {drop_down_choice}")

if __name__ == "__main__":
    # create your first deployment