Jason Wiener
07/02/2025, 9:12 PM@flow
def insert_missing(local_files: list[dict[str, str]]):
blah()
Right now, this renders the parameter definition on screen as attached. Is there a way to communicate to Prefect server that each dictionary in the list should have two dialogs, one for the key and one for the value?Marvin
07/02/2025, 9:12 PMMarvin
07/02/2025, 9:13 PMpython
from pydantic import BaseModel
from prefect import flow
class FileMapping(BaseModel):
source_path: str
destination_path: str
@flow
def insert_missing(local_files: list[FileMapping]):
blah()
This approach will:
1. Create separate input fields for each dictionary's keys
2. Provide proper validation
3. Allow users to add/remove items from the list in the UI
4. Give you type safety in your code
You can also add descriptions and examples to make the UI more user-friendly:
python
from pydantic import BaseModel, Field
from prefect import flow
class FileMapping(BaseModel):
source_path: str = Field(
description="Path to the source file"
)
destination_path: str = Field(
description="Where the file should be copied to"
)
@flow
def insert_missing(local_files: list[FileMapping]):
blah()
The UI will now show a more structured form with clear labels and the ability to add multiple file mappings, each with dedicated fields for source and destination paths.
For more details on form building and parameter schemas, check out the Prefect documentation on form building.