Jack P
01/13/2024, 9:32 PMMarvin
01/13/2024, 9:32 PMdeployment.yaml
. However, the direct ability to create a list of specified options for deployment parameters in the Prefect UI is not explicitly mentioned. For this reason, I cannot confirm whether there is a predefined way to create a dropdown or selection list for parameters in the Prefect UI.
Additionally, editing deployment.yaml
is possible before running prefect deployment apply
, and changing parameter values through the UI affects future flow runs that are based on that deployment.
As for using Pydantic, there's no information extracted that indicates the necessity or method to use Pydantic models with Prefect Deployment Parameters. Pydantic is commonly used in Python for data validation and settings management, but Prefect's documentation does not explicitly state its use in the context of deployment parameters.
For a more specific answer regarding creating a list of specified options and the use of Pydantic with Prefect, I would suggest reaching out to the Prefect community or checking Prefect's official documentation and GitHub repository. If necessary, I can search Prefect's GitHub issues for more related information. Would you like me to do that for you?Kevin Grismore
01/13/2024, 9:34 PMJack P
01/13/2024, 9:34 PMKevin Grismore
01/13/2024, 9:34 PMLiteral
Kevin Grismore
01/13/2024, 9:35 PMNate
01/13/2024, 9:35 PMfrom enum import Enum
from prefect import flow
class CardinalDirection(Enum):
NORTH = "north"
SOUTH = "south"
EAST = "east"
WEST = "west"
@flow
def where_to_go(direction: CardinalDirection):
print(f"Going {direction.name}!")
if __name__ == "__main__":
where_to_go.serve("enums")
Kevin Grismore
01/13/2024, 9:35 PMJack P
01/13/2024, 9:37 PMNate
01/13/2024, 9:41 PMNate
01/13/2024, 9:41 PMJack P
01/13/2024, 9:42 PMNate
01/13/2024, 9:43 PMKrystal
02/14/2024, 9:34 AMconfig
is a Pydantic model. Attached the snippet for the pydantic model here too. Any idea why this is?
class TestConfig(BaseModel):
environment: Environment = (
Field(..., description="The environment to send the API requests to"),
)
df_uri: str | S3URI = Field(
default=DEFAULT_URI,
description="S3 URI of the csv. Must contain one of these columns ['content_id', 'video_id', 'image_id']",
)
garm_model: str = Field(
default="xxx", description="Name of the garm model"
)
decimals: int = Field(
default=3, description="Decimal places when comparing results"
)
Nate
02/14/2024, 1:48 PMenvironment: Environment = (
Field(..., description="The environment to send the API requests to"),
)
this says that environment
is a thing of type Environment
and has a default value of a tuple
of Field
objects of length one, which I don't think is what you want
maybe you want this instead?
class TestConfig(BaseModel):
environment: Environment = Field(..., description="The environment to send the API requests to")
Krystal
02/14/2024, 2:00 PMKrystal
02/14/2024, 2:00 PMKrystal
02/14/2024, 2:00 PMNate
02/14/2024, 2:00 PMNate
02/14/2024, 2:00 PMKrystal
02/14/2024, 2:01 PMprefect.yaml
for deployment?Nate
02/14/2024, 2:14 PMIn [1]: from pydantic import BaseModel
In [2]: class Foo(BaseModel):
...: x: str
...: y: int
...:
In [3]: from prefect import flow
In [4]: @flow
...: def accepts_foo(foo: Foo):
...: print(foo, type(foo))
...:
In [5]: accepts_foo({"x": "marvin", "y": 42})
08:03:37.178 | INFO | prefect.engine - Created flow run 'icy-trout' for flow 'accepts-foo'
x='marvin' y=42 <class '__main__.Foo'>
08:03:38.747 | INFO | Flow run 'icy-trout' - Finished in state Completed()
so as a yaml object you'd have something like
parameters:
foo:
x: marvin
y: 42
Krystal
02/14/2024, 2:18 PMKrystal
02/14/2024, 2:18 PMJack P
02/28/2024, 4:48 PM