hey <@ULVA73B9P> I just pushed new parameters to m...
# ask-marvin
d
hey @Marvin I just pushed new parameters to my flows, they are pydantic parameters, why do i not see my parameters updating the UI? all i see are args and kwargs which work, but make it very difficult for my team to understand.
m
It looks like the issue you're facing has something to do with the way parameters are configured in your deployment and how they appear in the UI. Here are some points to consider: 1. Deployment Configuration: Ensure that your deployment configuration YAML correctly lists the parameters. The parameters should be specified as JSON key-value pairs matching those expected by your flow function. 2. **Using kwargs:** You can pass parameters using
**kwargs
, but this might make the parameters appear less clear in the UI. Prefect allows specifying detailed parameter schemas to avoid using generic
**kwargs
. 3. Updating Parameters in UI: You can edit parameters directly from the Prefect UI. Go to the deployment details page and select Edit. Changes will be applied to all future flow runs based on the deployment. 4. Ad-Hoc Runs: For custom parameter values during ad-hoc runs, navigate to the deployment details page, select Run, then Custom, and provide the new parameter values. 5. Pydantic Models: Ensure your Pydantic models are correctly handled. If the UI still doesn't reflect the changes, verify your models are defined and imported correctly where needed. Here's an example Flow to provide some context:
Copy code
python
from prefect import flow
from pydantic import BaseModel, Field

class MyParams(BaseModel):
    name: str
    num: int

@flow
def my_flow(params: MyParams):
    print(params.name, params.num)

if __name__ == "__main__":
    from prefect.deployments import DeploymentSpec
    DeploymentSpec(
        flow=my_flow,
        parameters={"params": {"name": "Marvin", "num": 42}},
        name="my-flow-deployment"
    )
You can refer to the full Prefect documentation on parameter configurations here: * https://docs.prefect.io/latest/concepts/deployments-block-based/ * https://docs.prefect.io/latest/concepts/flows/ If you still encounter issues, you might want to ensure your Pydantic models are compatible and properly integrated. If problems persist, consider raising an issue on the Prefect GitHub repository.
d
@Marvin, all i did was make a change to my pydantic parameters file which had been working for years, I am using Prefect 2.20.1, is there something im missing?
m
It appears your issue with Pydantic parameters not updating in the UI might be related to changes in Pydantic and how Prefect handles parameter schemas. Here are some things to note: 1. Prefect and Pydantic Compatibility: - There have been issues where Pydantic 2 handles optional fields differently, affecting how they display in the flow parameter input form in Prefect. This might result in an unexpected or confusing UI experience. 2. GitHub Issues: - Optional Fields in Pydantic 2: Pydantic 2 treats optional fields differently, which changes their display in the UI. This could cause the issues you're facing. Issue #12023. - Complex Optional Parameters: Sometimes, complex optional parameters are not treated as optional in custom runs, forcing user input even when the parameter should be optional. Issue #8479. 3. Prefect Version: - As of the latest information, ensure that you are updated to a version that might have fixes related to these issues. Prefect 3.0 is in the release candidate stage, so if feasible, you might consider testing with a more recent version if it has relevant fixes. 4. Workarounds: - Double-check that your Pydantic models and their usage in flows align with Prefect's expected schemas. - Explicitly define your parameters in the deployment YAML and avoid complex optional fields if they cause issues. 5. Documentation: - You can refer to detailed documentation for deployments and flows. For more details, you can review the specific GitHub issues mentioned: - Optional Fields in Pydantic 2 - Complex Optional Parameters If these steps don’t resolve the issue, you might want to file a detailed issue on the Prefect GitHub repository describing your changes and how the behavior has deviated.