Skip to content

Commit

Permalink
omit empty tags in RunnerDeployment (#16075)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz authored Nov 21, 2024
1 parent ada7db5 commit 78ee41c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/prefect/deployments/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def fast_flow():
PREFECT_DEFAULT_WORK_POOL_NAME,
PREFECT_UI_URL,
)
from prefect.types import ListOfNonEmptyStrings
from prefect.types.entrypoint import EntrypointType
from prefect.utilities.asyncutils import sync_compatible
from prefect.utilities.callables import ParameterSchema, parameter_schema
Expand Down Expand Up @@ -140,7 +141,7 @@ class RunnerDeployment(BaseModel):
version: Optional[str] = Field(
default=None, description="An optional version for the deployment."
)
tags: List[str] = Field(
tags: ListOfNonEmptyStrings = Field(
default_factory=list,
description="One of more tags to apply to this deployment.",
)
Expand Down
19 changes: 13 additions & 6 deletions src/prefect/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,30 @@ def check_variable_value(value: object) -> object:
return value


def cast_none_to_empty_dict(value: Any) -> dict[str, Any]:
if value is None:
return {}
return value


StrictVariableValue = Annotated[VariableValue, BeforeValidator(check_variable_value)]

LaxUrl = Annotated[str, BeforeValidator(lambda x: str(x).strip())]

StatusCode = Annotated[int, Field(ge=100, le=599)]


def cast_none_to_empty_dict(value: Any) -> dict[str, Any]:
if value is None:
return {}
return value


KeyValueLabels = Annotated[
dict[str, Union[StrictBool, StrictInt, StrictFloat, str]],
BeforeValidator(cast_none_to_empty_dict),
]


ListOfNonEmptyStrings = Annotated[
List[str], BeforeValidator(lambda x: [s for s in x if s.strip()])
]


class SecretDict(pydantic.Secret[Dict[str, Any]]):
pass

Expand Down Expand Up @@ -147,6 +153,7 @@ def validate_set_T_from_delim_string(
"LogLevel",
"NonNegativeInteger",
"PositiveInteger",
"ListOfNonEmptyStrings",
"NonNegativeFloat",
"Name",
"NameOrEmpty",
Expand Down

0 comments on commit 78ee41c

Please sign in to comment.