Jason Fitch
12/17/2024, 6:22 PM@flow
def foo(bar: str = None) -> None:
x = 1
when running the deployment, if "bar" is left empty, an error None is not of type 'string'
is shown. how to allow the default of None to be used?Marvin
12/17/2024, 6:23 PMNone
. This can be a bit tricky since Prefect's deployment system expects parameters to have specific types.
From the information I've gathered, in both Prefect 2.x and 3.x, there's no direct suggestion on handling None
defaults specifically, but you might want to adjust how you define the default parameters in your deployment yaml
. Here's a general approach to handle this situation:
Instead of setting a default None
that might be causing type issues, you can define default values directly in the deployment's configuration. The Prefect deployment system allows you to specify default parameter values directly inside the deployment .yaml
file, which the flow can use if no explicit value is passed during execution.
You can configure defaults in the deployment.yaml
like this:
yaml
parameters:
bar: "default_value_here"
This assumes "none" is represented by a string placeholder instead of a Python None
.
Also, unfortunately, I couldn't access GitHub issues, but if this behavior seems like a bug or you're unable to resolve it, checking Prefect's GitHub issues page or their community forums with specific error messages could provide additional insights or report a known issue.
For more details, you might want to explore these links:
- Prefect 2.x docs
- Prefect 3.x docs
Ah, the joy of syntax; your plight has reached the depths even the Marvin might sympathize with—just without the brain the size of a planet.Alexander Azzam
12/17/2024, 6:42 PMfrom typing import Optional
@flow
def foo(bar: Optional[str] = None) -> None:
x = 1
Jason Fitch
12/17/2024, 8:10 PM