Parameters in UI look different when class exists in same file as flow vs. different files
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)
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
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
@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?
I am having the exact same issue on 3.0.10 and 3.0.11.
Hey @vinceyyyyyy! Do you have an MRE where you're seeing this issue? I'm also having trouble reproducing it.
Hey @vinceyyyyyy! Do you have an MRE where you're seeing this issue? I'm also having trouble reproducing it.
I created a MRE here with the latest prefect 3.1.10: https://github.com/vinceyyy/prefect-ui-bug-mre
It turns out in my case, importing pydantic model from another file is not the cause, but something else happened along the importing.
For example, in this MRE the file containing the pydantic model also imports a non-exist variable USELESS_PLACEHOLDER, but prefect deploy runs fine with it.