PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
17.55k stars 1.65k forks source link

Parameters in UI look different when class exists in same file as flow vs. different files #14835

Open robfreedy opened 3 months ago

robfreedy commented 3 months ago

Bug summary

When running a deployed flow that has a Pydantic based model as a parameter, the UI input looks different when the class is defined inside the same file as the flow vs. when the class is defined outside the file that the flow is defined in and imported.

MRE:

Class defined in the same file:

from prefect import flow
from pydantic import BaseModel

class MyParams(BaseModel):
    id: str
    name: str

@flow
def entrypoint(my_params: MyParams):
    print(my_params)

image

Class defined in a different file

from prefect import flow

from test_class import MyParams

@flow
def entrypoint(my_params: MyParams):
    print(my_params)
from pydantic import BaseModel

class MyParams(BaseModel):
    id: str
    name: str

image

Version info (prefect version output)

Version:             2.19.9
API version:         0.8.4
Python version:      3.11.9
Git commit:          0e5fa902
Built:               Thu, Jul 25, 2024 11:59 AM
OS/Arch:             darwin/arm64
Profile:             test
Server type:         cloud

Additional context

No response

cicdw commented 3 months ago

@robfreedy I was not able to reproduce on 2.x or on main. I also took a peek at the open API schemas (which is where the difference must be) and I get the exact same schema for both flows. Is there something else that might be changing between these two flows that might affect this difference? Could you re-test on the latest 2.x release?

vinceyyyyyy commented 3 weeks ago

I am having the exact same issue on 3.0.10 and 3.0.11.

desertaxle commented 2 days ago

Hey @vinceyyyyyy! Do you have an MRE where you're seeing this issue? I'm also having trouble reproducing it.