Bharat Khaneja
02/21/2025, 2:26 PMraise DeploymentApplyError(
prefect.deployments.runner.DeploymentApplyError: Error while applying deployment: Client error '422 Unprocessable Entity' for url 'https://*******/api/deployments/'
Response: {'exception_message': 'Invalid request received.', 'exception_detail': [{'type': 'extra_forbidden', 'loc': ['body', 'schedules', 0, 'slug'], 'msg': 'Extra inputs are not permitted', 'input': None}], 'request_body': {'name': 'Bharat Automation', 'flow_id': 'ba5b9e26-3bde-4820-af2d-19ade97c1d9b', 'paused': False, 'schedules': [{'schedule': {'cron': '30 */4 * * *', 'timezone': None, 'day_or': True}, 'active': True, 'max_scheduled_runs': None, 'parameters': {}, 'slug': None}], 'concurrency_limit': 1, 'concurrency_options': None, 'enforce_parameter_schema': True, 'parameter_openapi_schema': {'title': 'Parameters', 'type': 'object', 'properties': {}}, 'parameters': {}, 'tags': [], 'labels': {}, 'pull_steps': [{'prefect.deployments.steps.set_working_directory': {'directory': '/home/bkhaneja'}}], 'work_queue_name': None, 'work_pool_name': 'cla-infra', 'storage_document_id': None, 'infrastructure_document_id': None, 'description': 'None', 'path': None, 'version': '6248918156128180d3c40b3bd89e2025', 'entrypoint': 'test6.py:automation_executor', 'job_variables': {}}}
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
my script is simple like this, it works for first time but on seciond time it gives this error..
from prefect import flow, task
from prefect_shell import ShellOperation
from pathlib import Path
@task
def run_script(command: str):
shell_op = ShellOperation(commands=[command])
return shell_op.run()
# Flow for Bharat Automation Job
@flow(name="Bharat Automation Flow")
def automation_executor():
command = "/usr/bin/python3.9 *****"
run_script(command)
# Deploy all flows to Prefect server with schedules
if __name__ == "__main__":
automation_executor.from_source(
source=str(Path(__file__).parent.resolve()),
entrypoint=f"{Path(__file__).name}:automation_executor",
).deploy(name="Bharat Automation", work_pool_name="bk-infra", cron="30 */4 * * *", concurrency_limit=1)
(earlier on running it for second time was not causing any issue, started seeing this after prefect upgrade)Bharat Khaneja
02/21/2025, 2:27 PMMarvin
02/21/2025, 2:27 PMBianca Hoch
02/21/2025, 3:05 PMBianca Hoch
02/21/2025, 3:06 PMprefect version
Bianca Hoch
02/21/2025, 3:07 PMBharat Khaneja
02/21/2025, 3:11 PM# prefect version
Version: 3.2.6
API version: 0.8.4
Python version: 3.9.20
Git commit: 5ceb3ada
Built: Wed, Feb 19, 2025 9:24 PM
OS/Arch: linux/x86_64
Profile: ephemeral
Server type: server
Pydantic version: 2.10.6
Integrations:
prefect-shell: 0.3.1
Bharat Khaneja
02/21/2025, 3:11 PMBharat Khaneja
02/21/2025, 3:13 PMBianca Hoch
02/21/2025, 3:17 PMBharat Khaneja
02/21/2025, 6:23 PMBharat Khaneja
02/21/2025, 6:24 PM# prefect version
Version: 3.2.6
API version: 0.8.4
Python version: 3.11.11
Git commit: 5ceb3ada
Built: Wed, Feb 19, 2025 9:24 PM
OS/Arch: linux/x86_64
Profile: ephemeral
Server type: server
Pydantic version: 2.10.6
Integrations:
prefect-shell: 0.3.1
Bianca Hoch
02/21/2025, 9:16 PM