From 6b02e5165454581331928d57751fda30ceb7f88e Mon Sep 17 00:00:00 2001 From: Alex Streed Date: Tue, 22 Oct 2024 10:59:46 -0500 Subject: [PATCH] Create `ServerFlowRunGraphSettings` model --- src/prefect/settings/models/root.py | 10 ------ .../settings/models/server/flow_run_graph.py | 34 +++++++++++++++++++ src/prefect/settings/models/server/root.py | 5 +++ tests/test_settings.py | 6 ++-- 4 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 src/prefect/settings/models/server/flow_run_graph.py diff --git a/src/prefect/settings/models/root.py b/src/prefect/settings/models/root.py index d102174fa33b..11ccada0f176 100644 --- a/src/prefect/settings/models/root.py +++ b/src/prefect/settings/models/root.py @@ -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 diff --git a/src/prefect/settings/models/server/flow_run_graph.py b/src/prefect/settings/models/server/flow_run_graph.py new file mode 100644 index 000000000000..f7a54745b6d3 --- /dev/null +++ b/src/prefect/settings/models/server/flow_run_graph.py @@ -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", + ), + ) diff --git a/src/prefect/settings/models/server/root.py b/src/prefect/settings/models/server/root.py index e721de5816a6..3ba271891f6c 100644 --- a/src/prefect/settings/models/server/root.py +++ b/src/prefect/settings/models/server/root.py @@ -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): @@ -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", + ) diff --git a/tests/test_settings.py b/tests/test_settings.py index 21443f281299..2412871bf0bd 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -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}, @@ -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")},