<@ULVA73B9P> what is wrong here? Engine executio...
# marvin-ai
m
@Marvin what is wrong here? Engine execution exited with unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/prefect/flow_engine.py", line 1551, in run_flow parameters=_flow_parameters( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/prefect/flow_engine.py", line 1591, in _flow_parameters call_args, call_kwargs = parameters_to_args_kwargs(flow.fn, parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/prefect/utilities/callables.py", line 192, in parameters_to_args_kwargs raise SignatureMismatchError.from_bad_params( prefect.exceptions.SignatureMismatchError: Function expects parameters [] but was provided with parameters ['environment'] deployments: - name: my-flow entrypoint: flow.py:dynamic_reporting_pipeline schedules: [] paused: true parameters: environment: "{{ $PREFECT_DEPLOY_ENV }}" from prefect import flow from datetime import datetime from prefect.logging import get_run_logger from prefect import runtime @flow def dynamic_reporting_pipeline(): logger = get_run_logger() env = runtime.flow_run.parameters.get("environment", "unknown") logger.info(f"Running dynamic reporting pipeline in {env} environment")
m
thought for 132.6 seconds
You’re getting that SignatureMismatchError because your deployment is supplying a parameter
environment
, but your flow function doesn’t accept any parameters. In Prefect 3.x, any parameters defined in the deployment must match the flow function signature. You have two clean options: Option A — Make
environment
a flow parameter - Keep the deployment
parameters
section - Update the flow to accept
environment
and use it prefect.yaml
Copy code
deployments:
  - name: my-flow
    entrypoint: flow.py:dynamic_reporting_pipeline
    schedules: []
    paused: true
    parameters:
      environment: "{{ $PREFECT_DEPLOY_ENV }}"
flow.py
Copy code
from prefect import flow
from prefect.logging import get_run_logger

@flow
def dynamic_reporting_pipeline(environment: str = "unknown"):
    logger = get_run_logger()
    <http://logger.info|logger.info>(f"Running dynamic reporting pipeline in {environment} environment")
Notes: - Your current
runtime.flow_run.parameters.get(...)
will only work once the parameter exists on the flow (or you can just use the function arg directly as shown). - Make sure your actual code calls
<http://logger.info|logger.info>(...)
— the pasted
<http://logger.info|logger.info>(...)
looks like Slack link formatting, not valid Python. Option B — Use an environment variable instead of a flow parameter - Remove
parameters
from the deployment - Set an environment variable via
job_variables.env
- Read it with
os.getenv
inside your flow prefect.yaml
Copy code
deployments:
  - name: my-flow
    entrypoint: flow.py:dynamic_reporting_pipeline
    schedules: []
    paused: true
    job_variables:
      env:
        PREFECT_DEPLOY_ENV: "{{ $PREFECT_DEPLOY_ENV }}"
flow.py
Copy code
import os
from prefect import flow
from prefect.logging import get_run_logger

@flow
def dynamic_reporting_pipeline():
    logger = get_run_logger()
    env = os.getenv("PREFECT_DEPLOY_ENV", "unknown")
    <http://logger.info|logger.info>(f"Running dynamic reporting pipeline in {env} environment")
Your templating
{{ $PREFECT_DEPLOY_ENV }}
is correct for pulling from the local environment at deploy time. Docs for reference: - prefect.yaml reference: prefect.yaml reference - Customize job variables (env): Customize job variables (env) - Passing flow inputs (parameters): Pass flow inputs (parameters) - Runtime context: prefect.runtime.deployment and prefect.runtime.flow_run