Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omit empty tags in RunnerDeployment #16075

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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