Jackson Nguyen
02/24/2025, 9:11 PMpydantic_param
, that is defined with pydantic. I get an error, saying my provided parameter "is not of type object". If I know the type that would be valid, is there a workaround for this?Marvin
02/24/2025, 9:12 PMpydantic_param
to a JSON string or dictionary before passing it to the command line. You can then parse this back into a pydantic model within your flow.
3. Ensure Compatibility: Make sure that you are not mixing Pydantic v1 and v2 models within your flow parameters.
### Example:
Suppose your pydantic model is MyModel
. You can convert it to a dictionary like so:
python
# Assuming `my_model_instance` is an instance of `MyModel`
param_dict = my_model_instance.dict()
When running your deployment from the command line, pass the serialized dictionary or JSON:
bash
prefect deployment run <deployment-name> --params '{"pydantic_param": {"key": "value"}}'
Then, within your flow, you can reconstruct the pydantic model:
python
from pydantic import BaseModel
class MyModel(BaseModel):
key: str
@flow
def my_flow(pydantic_param: dict):
model_instance = MyModel(**pydantic_param)
# Use model_instance as needed
For more insights, you can refer to the Prefect 3.x documentation and ensure that your deployment configurations align with the requirements.
If you continue to face issues, reviewing the specific error messages and ensuring that your parameter types are consistent with the expected input types would be beneficial.