Skip to content

prefect.settings.models.cloud

CloudSettings

Bases: PrefectBaseSettings

Settings for interacting with Prefect Cloud

Source code in src/prefect/settings/models/cloud.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class CloudSettings(PrefectBaseSettings):
    """
    Settings for interacting with Prefect Cloud
    """

    model_config = _build_settings_config(("cloud",))

    api_url: str = Field(
        default="https://api.prefect.cloud/api",
        description="API URL for Prefect Cloud. Used for authentication with Prefect Cloud.",
    )

    ui_url: Optional[str] = Field(
        default=None,
        description="The URL of the Prefect Cloud UI. If not set, the client will attempt to infer it.",
    )

    @model_validator(mode="after")
    def post_hoc_settings(self) -> Self:
        """refactor on resolution of https://github.com/pydantic/pydantic/issues/9789

        we should not be modifying __pydantic_fields_set__ directly, but until we can
        define dependencies between defaults in a first-class way, we need clean up
        post-hoc default assignments to keep set/unset fields correct after instantiation.
        """
        if self.ui_url is None:
            self.ui_url = default_cloud_ui_url(self)
            self.__pydantic_fields_set__.remove("ui_url")
        return self

post_hoc_settings()

refactor on resolution of https://github.com/pydantic/pydantic/issues/9789

we should not be modifying pydantic_fields_set directly, but until we can define dependencies between defaults in a first-class way, we need clean up post-hoc default assignments to keep set/unset fields correct after instantiation.

Source code in src/prefect/settings/models/cloud.py
47
48
49
50
51
52
53
54
55
56
57
58
@model_validator(mode="after")
def post_hoc_settings(self) -> Self:
    """refactor on resolution of https://github.com/pydantic/pydantic/issues/9789

    we should not be modifying __pydantic_fields_set__ directly, but until we can
    define dependencies between defaults in a first-class way, we need clean up
    post-hoc default assignments to keep set/unset fields correct after instantiation.
    """
    if self.ui_url is None:
        self.ui_url = default_cloud_ui_url(self)
        self.__pydantic_fields_set__.remove("ui_url")
    return self