Skip to content

Commit

Permalink
Create ServerFlowRunGraphSettings model
Browse files Browse the repository at this point in the history
  • Loading branch information
desertaxle committed Oct 22, 2024
1 parent ee31871 commit 6b02e51
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/prefect/settings/models/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,6 @@ class Settings(PrefectBaseSettings):
description="The maximum number of characters allowed for a task run cache key.",
)

api_max_flow_run_graph_nodes: int = Field(
default=10000,
description="The maximum size of a flow run graph on the v2 API",
)

api_max_flow_run_graph_artifacts: int = Field(
default=10000,
description="The maximum number of artifacts to show on a flow run graph on the v2 API",
)

###########################################################################
# API Services settings

Expand Down
34 changes: 34 additions & 0 deletions src/prefect/settings/models/server/flow_run_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pydantic import AliasChoices, AliasPath, Field
from pydantic_settings import SettingsConfigDict

from prefect.settings.base import PrefectBaseSettings


class ServerFlowRunGraphSettings(PrefectBaseSettings):
"""
Settings for controlling behavior of the flow run graph
"""

model_config = SettingsConfigDict(
env_prefix="PREFECT_SERVER_FLOW_RUN_GRAPH_", env_file=".env", extra="ignore"
)

max_nodes: int = Field(
default=10000,
description="The maximum size of a flow run graph on the v2 API",
validation_alias=AliasChoices(
AliasPath("max_nodes"),
"prefect_server_flow_run_graph_max_nodes",
"prefect_api_max_flow_run_graph_nodes",
),
)

max_artifacts: int = Field(
default=10000,
description="The maximum number of artifacts to show on a flow run graph on the v2 API",
validation_alias=AliasChoices(
AliasPath("max_artifacts"),
"prefect_server_flow_run_graph_max_artifacts",
"prefect_api_max_flow_run_graph_artifacts",
),
)
5 changes: 5 additions & 0 deletions src/prefect/settings/models/server/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .database import ServerDatabaseSettings
from .ephemeral import ServerEphemeralSettings
from .events import ServerEventsSettings
from .flow_run_graph import ServerFlowRunGraphSettings


class ServerSettings(PrefectBaseSettings):
Expand Down Expand Up @@ -117,3 +118,7 @@ class ServerSettings(PrefectBaseSettings):
default_factory=ServerEventsSettings,
description="Settings for controlling server events behavior",
)
flow_run_graph: ServerFlowRunGraphSettings = Field(
default_factory=ServerFlowRunGraphSettings,
description="Settings for controlling flow run graph behavior",
)
6 changes: 4 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"PREFECT_API_EVENTS_STREAM_OUT_ENABLED": {"test_value": True, "legacy": True},
"PREFECT_API_KEY": {"test_value": "key"},
"PREFECT_API_LOG_RETRYABLE_ERRORS": {"test_value": True, "legacy": True},
"PREFECT_API_MAX_FLOW_RUN_GRAPH_ARTIFACTS": {"test_value": 10},
"PREFECT_API_MAX_FLOW_RUN_GRAPH_NODES": {"test_value": 100},
"PREFECT_API_MAX_FLOW_RUN_GRAPH_ARTIFACTS": {"test_value": 10, "legacy": True},
"PREFECT_API_MAX_FLOW_RUN_GRAPH_NODES": {"test_value": 100, "legacy": True},
"PREFECT_API_REQUEST_TIMEOUT": {"test_value": 10.0},
"PREFECT_API_SERVICES_CANCELLATION_CLEANUP_ENABLED": {"test_value": True},
"PREFECT_API_SERVICES_CANCELLATION_CLEANUP_LOOP_SECONDS": {"test_value": 10.0},
Expand Down Expand Up @@ -269,6 +269,8 @@
"PREFECT_SERVER_EVENTS_RETENTION_PERIOD": {"test_value": timedelta(hours=7)},
"PREFECT_SERVER_EVENTS_STREAM_OUT_ENABLED": {"test_value": True},
"PREFECT_SERVER_EVENTS_WEBSOCKET_BACKFILL_PAGE_SIZE": {"test_value": 250},
"PREFECT_SERVER_FLOW_RUN_GRAPH_MAX_ARTIFACTS": {"test_value": 10},
"PREFECT_SERVER_FLOW_RUN_GRAPH_MAX_NODES": {"test_value": 100},
"PREFECT_SERVER_LOGGING_LEVEL": {"test_value": "INFO"},
"PREFECT_SERVER_LOG_RETRYABLE_ERRORS": {"test_value": True},
"PREFECT_SERVER_MEMO_STORE_PATH": {"test_value": Path("/path/to/memo")},
Expand Down

0 comments on commit 6b02e51

Please sign in to comment.