Coverage for /usr/local/lib/python3.12/site-packages/prefect/settings/models/tasks.py: 100%
23 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
1from typing import ClassVar, Optional 1a
3from pydantic import AliasChoices, AliasPath, Field 1a
4from pydantic_settings import SettingsConfigDict 1a
6from prefect.settings.base import PrefectBaseSettings, build_settings_config 1a
7from prefect.types import TaskRetryDelaySeconds 1a
10class TasksRunnerSettings(PrefectBaseSettings): 1a
11 model_config: ClassVar[SettingsConfigDict] = build_settings_config( 1a
12 ("tasks", "runner")
13 )
15 thread_pool_max_workers: Optional[int] = Field( 1a
16 default=None,
17 gt=0,
18 description="The maximum number of workers for ThreadPoolTaskRunner.",
19 validation_alias=AliasChoices(
20 AliasPath("thread_pool_max_workers"),
21 "prefect_tasks_runner_thread_pool_max_workers",
22 "prefect_task_runner_thread_pool_max_workers",
23 ),
24 )
26 process_pool_max_workers: Optional[int] = Field( 1a
27 default=None,
28 gt=0,
29 description="The maximum number of workers for ProcessPoolTaskRunner.",
30 )
33class TasksSchedulingSettings(PrefectBaseSettings): 1a
34 model_config: ClassVar[SettingsConfigDict] = build_settings_config( 1a
35 ("tasks", "scheduling")
36 )
38 default_storage_block: Optional[str] = Field( 1a
39 default=None,
40 description="The `block-type/block-document` slug of a block to use as the default storage for autonomous tasks.",
41 validation_alias=AliasChoices(
42 AliasPath("default_storage_block"),
43 "prefect_tasks_scheduling_default_storage_block",
44 "prefect_task_scheduling_default_storage_block",
45 ),
46 )
48 delete_failed_submissions: bool = Field( 1a
49 default=True,
50 description="Whether or not to delete failed task submissions from the database.",
51 validation_alias=AliasChoices(
52 AliasPath("delete_failed_submissions"),
53 "prefect_tasks_scheduling_delete_failed_submissions",
54 "prefect_task_scheduling_delete_failed_submissions",
55 ),
56 )
59class TasksSettings(PrefectBaseSettings): 1a
60 model_config: ClassVar[SettingsConfigDict] = build_settings_config(("tasks",)) 1a
62 refresh_cache: bool = Field( 1a
63 default=False,
64 description="If `True`, enables a refresh of cached results: re-executing the task will refresh the cached results.",
65 )
67 default_no_cache: bool = Field( 1a
68 default=False,
69 description="If `True`, sets the default cache policy on all tasks to `NO_CACHE`.",
70 )
72 disable_caching: bool = Field( 1a
73 default=False,
74 description="If `True`, disables caching on all tasks regardless of cache policy.",
75 )
77 default_retries: int = Field( 1a
78 default=0,
79 ge=0,
80 description="This value sets the default number of retries for all tasks.",
81 validation_alias=AliasChoices(
82 AliasPath("default_retries"),
83 "prefect_tasks_default_retries",
84 "prefect_task_default_retries",
85 ),
86 )
88 default_retry_delay_seconds: TaskRetryDelaySeconds = Field( 1a
89 default=0,
90 description="This value sets the default retry delay seconds for all tasks.",
91 validation_alias=AliasChoices(
92 AliasPath("default_retry_delay_seconds"),
93 "prefect_tasks_default_retry_delay_seconds",
94 "prefect_task_default_retry_delay_seconds",
95 ),
96 )
98 default_persist_result: Optional[bool] = Field( 1a
99 default=None,
100 description="If `True`, results will be persisted by default for all tasks. Set to `False` to disable persistence by default. "
101 "Note that setting to `False` will override the behavior set by a parent flow or task.",
102 )
104 runner: TasksRunnerSettings = Field( 1a
105 default_factory=TasksRunnerSettings,
106 description="Settings for controlling task runner behavior",
107 )
109 scheduling: TasksSchedulingSettings = Field( 1a
110 default_factory=TasksSchedulingSettings,
111 description="Settings for controlling client-side task scheduling behavior",
112 )