Rustam Salavatov
05/27/2024, 10:45 AMMarvin
05/27/2024, 10:45 AMTraceback (most recent call last):File “/home/afokin52/arepas_prefect/pipeline-prefect/flows/parser_reddit.py”, line 159, in <module> parse_reddit.deploy( File “/home/afokin52/.cache/pypoetry/virtualenvs/flows-oLOQFfZS-py3.10/lib/python3.10/site-packages/prefect/utilities/asyncutils.py”, line 304, in coroutine_wrapper return call() File “/home/afokin52/.cache/pypoetry/virtualenvs/flows-oLOQFfZS-py3.10/lib/python3.10/site-packages/prefect/_internal/concurrency/calls.py”, line 432, in call return self.result() File “/home/afokin52/.cache/pypoetry/virtualenvs/flows-oLOQFfZS-py3.10/lib/python3.10/site-packages/prefect/_internal/concurrency/calls.py”, line 318, in result return self.future.result(timeout=timeout) File “/home/afokin52/.cache/pypoetry/virtualenvs/flows-oLOQFfZS-py3.10/lib/python3.10/site-packages/prefect/_internal/concurrency/calls.py”, line 179, in result return self.__
Rustam Salavatov
05/27/2024, 10:45 AMMarvin
05/27/2024, 10:46 AM422 Unprocessable Entity
error. It seems you're dealing with an issue during deployment in Prefect.
Possible Cause:
One common cause identified from this GitHub issue is using pydantic Field
members with the gt
(greater than) option which results in an invalid JSON schema.
Here's an example of problematic code:
python
from prefect import flow
from pydantic import BaseModel, Field
class Config(BaseModel):
sample_rate: int = Field(
default=100,
gt=0, # Problematic field
lte=100,
)
@flow
def dummy_flow(config: Config):
pass
dummy_flow.to_deployment("mre", enforce_parameter_schema=True).apply()
This raises the DeploymentApplyError
because of the invalid JSON schema.
Solution:
You can adjust the gt
parameter or replace problematic field definitions:
- Change gt=0
to gte=-1
,
- Avoid using gt
directly in fields that are part of your deployment schema.
Example adjustment:
python
class Config(BaseModel):
sample_rate: int = Field(
default=100,
gte=1, # Adjustment replacing gt=0
lte=100,
)
If you adjust the field definitions as above and redeploy, it should resolve the issue.
For more detailed steps and examples, check out the Prefect Deployment Guide.
If the issue persists, feel free to provide more details, and we'll be happy to assist.
As always, try not to get too cheerful about it. Links for reference:
1. GitHub Issue 13560
2. Prefect Deployment Documentation
Good luck.