<@ULVA73B9P> does prefect form allow conditional field according to the earlier field
m
@Marvin does prefect form allow conditional field according to the earlier field
m
thought for 159.4 seconds
Short answer: not in the way most people expect. Prefect forms in 3.x do not currently support dynamic conditional fields like: - show/hide field B based on field A - enable/disable field B based on field A What is supported is conditional validation / requirements via JSON Schema dependencies, so a field can become required if another field is filled in — but it will still be visible in the form. Docs: - Form building guide Example of supported conditional requirements:
Copy code
python
from pydantic import BaseModel, ConfigDict, Field

class MyParams(BaseModel):
    model_config = ConfigDict(
        json_schema_extra={
            "dependencies": {
                "coupon_code": {
                    "required": ["approver"]
                }
            }
        }
    )

    coupon_code: str | None = None
    approver: str | None = Field(
        default=None,
        description="Required if coupon_code is provided"
    )
If you want a more conditional UX, the best workaround is usually a discriminated union / separate schema variants, so the user selects a type first and then only sees the relevant fields for that variant. If you want, I can show you a Prefect-compatible example for: 1. conditional validation, or 2. a discriminated union form that behaves more like conditional fields.
m
@Marvin does prefect form allows file
m
thought for 172.3 seconds
Not directly, no — Prefect forms do not currently have a file upload field/widget in 3.x. What you can do: - pass a file path as a string - pass a URL/object storage key like an S3 key - pass base64-encoded content for small files - use a block/storage reference and let the flow load the file itself Relevant docs: - Form building guide - Interactive workflows A simple pattern is:
Copy code
python
from prefect import flow

@flow
def process_file(file_path: str):
    with open(file_path, "rb") as f:
        data = f.read()
    return len(data)
Or for cloud storage:
Copy code
python
from prefect import flow

@flow
def process_s3_file(bucket: str, key: str):
    # load file from S3 inside the flow
    ...
A note:
bytes
can exist in the schema, but Prefect’s form UI does not expose it as a real file picker/upload control. If you want, I can suggest the best pattern depending on whether your files are: - local files - S3/GCS/Azure files - files uploaded by non-technical users through the UI