prefect icon indicating copy to clipboard operation
prefect copied to clipboard

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

Open robfreedy opened this issue 1 year ago • 2 comments

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

robfreedy avatar Aug 02 '24 18:08 robfreedy

@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?

cicdw avatar Aug 09 '24 23:08 cicdw

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

vinceyyyyyy avatar Oct 29 '24 18:10 vinceyyyyyy

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

desertaxle avatar Nov 21 '24 21:11 desertaxle

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.

vinceyyy avatar Dec 31 '24 21:12 vinceyyy