Skip to content

Commit

Permalink
fix passing enforce_parameter_schema in prefect deploy (#16418)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz authored Dec 17, 2024
1 parent 53a83eb commit 068ea22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/prefect/cli/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ async def deploy(
),
enforce_parameter_schema: bool = typer.Option(
True,
"--enforce-parameter-schema",
help=(
"Whether to enforce the parameter schema on this deployment. If set to"
" True, any parameters passed to this deployment must match the signature"
Expand All @@ -358,7 +357,6 @@ async def deploy(
Should be run from a project root directory.
"""

if variables is not None:
app.console.print(
generate_deprecation_message(
Expand Down Expand Up @@ -460,9 +458,9 @@ async def deploy(

@inject_client
async def _run_single_deploy(
deploy_config: Dict,
actions: Dict,
options: Optional[Dict] = None,
deploy_config: dict[str, Any],
actions: dict[str, Any],
options: Optional[dict[str, Any]] = None,
client: Optional["PrefectClient"] = None,
prefect_file: Path = Path("prefect.yaml"),
):
Expand Down Expand Up @@ -1524,7 +1522,7 @@ def _apply_cli_options_to_deploy_config(deploy_config, cli_options):
"flow_name",
"enforce_parameter_schema",
]
and cli_value
and cli_value is not None
):
deploy_config[cli_option] = cli_value

Expand Down
18 changes: 18 additions & 0 deletions tests/cli/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,24 @@ async def test_project_deploy(self, project_dir, prefect_client: PrefectClient):
assert deployment.job_variables == {"env": "prod"}
assert deployment.enforce_parameter_schema

async def test_deploy_with_no_enforce_parameter_schema(
self, project_dir, work_pool, prefect_client
):
await run_sync_in_worker_thread(
invoke_and_assert,
command=f"deploy ./flows/hello.py:my_flow --no-enforce-parameter-schema -n test-name -p {work_pool.name}",
expected_code=0,
)

deployment = await prefect_client.read_deployment_by_name(
"An important name/test-name"
)
assert deployment.name == "test-name"
assert deployment.work_pool_name == work_pool.name
assert deployment.tags == []
assert deployment.job_variables == {}
assert not deployment.enforce_parameter_schema

async def test_deploy_with_active_workers(
self, project_dir, work_pool, prefect_client, monkeypatch
):
Expand Down

0 comments on commit 068ea22

Please sign in to comment.