Open Duncan-Hunter opened 9 months ago
Hi @Duncan-Hunter, thanks for creating your first issue with Prefect! We're glad to have you in the community.
I was able to reproduce this using Python 3.8.13 and Prefect version 2.14.10.
Upgrading to Python 3.10.4, I was no longer able to reproduce the issue.
I think the solution for now is to upgrade to Python 3.10 or above, or for this particular case to pass in the flow parameter validate_parameters=False
.
We should probably add a test for this case.
cc @urimandujano
Hi @serinamarie,
I was able to reproduce this issue with Python 3.11 and Prefect 2.14.16
Hi @serinamarie - I too can reproduce the problem in Python 3.11, and am finding that it relates to Pydantic v1/v2 objects. For example:
from pydantic import BaseModel
from pydantic.v1 import BaseModel as BaseModelv1
from prefect import flow
class T1(BaseModelv1):
s: str
class T2(BaseModel):
s: str
@flow(name="test1")
def test_flow1(t: T1):
print(t)
@flow(name="test2")
def test_flow2(t: T2):
print(t)
@flow(name="test3", validate_parameters=False)
def test_flow3(t: T1):
print(t)
# Pydantic v1 - this fails with:
# TypeError: BaseModel.validate() takes 2 positional arguments but 3 were given
test_flow1({"s": "Hello!"})
# Pydantic v2 - this works:
test_flow2({"s": "Hello!"})
# Pydantic v1, validate_parameters=False - this works:
test_flow3({"s": "Hello!"})
My environment:
prefect 2.19.2
pydantic 2.7.2
First check
Bug summary
I'm attempting to use a dataclass as an argument to a prefect flow. When installing in a clean environment (I've been using poetry) with just
poetry add prefect
I get prefect version 2.14.9, and Pydantic version:When I run the test code below, I get an error.
However, if I specify
pydantic[email]=2.2.1
, the test case runs fine (Additional context).Apologies if: this is a problem with Pydantic; it's not reproducible; I'm not supposed to use prefect like this.
Reproduction
Error
Versions
Additional context
With Pydantic version 2.2.1: