<@ULVA73B9P> Why am I getting the following error ...
# ask-marvin
t
@Marvin Why am I getting the following error when I try to execute the following code:
Copy code
from prefect.deployments import run_deployment
run_deployment(name="my_function/My Sample Deployment", parameters={}, job_variables={"image": image})
The error is: pydantic.errors.PydanticUserError:
State
is not fully defined; you should define all referenced types, then call
State.model_rebuild()
.
m
The error you're encountering is related to Prefect's use of Pydantic for data validation. The error message indicates that the
State
model is not fully defined, which is usually a sign that there's a mismatch or issue with the Pydantic model definitions in your Prefect setup. Here are a few points to consider: 1. Prefect 3.x Changes: Prefect 3.x uses Pydantic 2, which might have introduced some changes in how models are validated or rebuilt. Ensure that your Prefect version is compatible with your code. More details can be found in the Prefect 3.x release notes. 2. State Model: The error suggests the need to rebuild the
State
model. This could be due to a missing or outdated model definition. It might be worth checking if there are any updates or patches related to this issue in the Prefect GitHub repository. 3. Deployment Changes: In Prefect 3.x, the
Deployment.build_from_flow()
method was removed. Make sure that your deployment code is updated to reflect the new API changes. 4. Work Pools: Prefect 3.x replaced agents with workers and introduced work pools. Ensure that your deployment configuration aligns with these changes. For more detailed information, you can explore Prefect's documentation on deployments and review the Prefect GitHub issues for any related updates or patches. If the problem persists, you might consider reaching out to the Prefect community or support for more specific guidance.
t
thanks @Alexander Azzam, I’ll give this a try. I also suspect that my client version is 3.0.11 and my server version is 3.1.5
a
maybe, but I’m haunted by that error and IIRC it’s just a pydantic thing that finally called BS on our importing scheme (or lack thereof)
t
Gotcha
Any tips on referencing something in prefect.main? I have an aggressive import removal tool that wont allow unreferenced imports
@Alexander Azzam - importing main worked - I had to add a reference to
main.__all__
in my script. However I was using
logging
in my script, but after including main the Prefect logging init that is executed seems to supress all of my messages. I was doing:
Copy code
logging.basicConfig(level=print, format='%(asctime)s - %(levelname)s - %(message)s')

<http://logging.info|logging.info>("Hello")
and now it doesn’t work