Coverage for /usr/local/lib/python3.12/site-packages/prefect/settings/models/experiments.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 11:21 +0000

1from __future__ import annotations 1a

2 

3from functools import partial 1a

4from typing import Annotated, ClassVar, Union 1a

5 

6from pydantic import AliasChoices, AliasPath, BeforeValidator, Field 1a

7from pydantic_settings import SettingsConfigDict 1a

8 

9from prefect.settings.base import PrefectBaseSettings, build_settings_config 1a

10from prefect.types import validate_set_T_from_delim_string 1a

11 

12 

13class PluginsSettings(PrefectBaseSettings): 1a

14 """ 

15 Settings for configuring the experimental plugin system 

16 """ 

17 

18 model_config: ClassVar[SettingsConfigDict] = build_settings_config( 1a

19 ("experiments", "plugins") 

20 ) 

21 

22 enabled: bool = Field( 1a

23 default=False, 

24 description="Enable the experimental plugin system.", 

25 ) 

26 

27 allow: Annotated[ 1a

28 Union[set[str], None], 

29 BeforeValidator(partial(validate_set_T_from_delim_string, type_=str)), 

30 ] = Field( 

31 default=None, 

32 description="Comma-separated list of plugin names to allow. If set, only these plugins will be loaded.", 

33 ) 

34 

35 deny: Annotated[ 1a

36 Union[set[str], None], 

37 BeforeValidator(partial(validate_set_T_from_delim_string, type_=str)), 

38 ] = Field( 

39 default=None, 

40 description="Comma-separated list of plugin names to deny. These plugins will not be loaded.", 

41 ) 

42 

43 setup_timeout_seconds: float = Field( 1a

44 default=20.0, 

45 description="Maximum time in seconds for all plugins to complete their setup hooks.", 

46 ) 

47 

48 strict: bool = Field( 1a

49 default=False, 

50 description="If True, exit if a required plugin fails during setup.", 

51 ) 

52 

53 safe_mode: bool = Field( 1a

54 default=False, 

55 description="If True, load plugins but do not execute their hooks. Useful for testing.", 

56 ) 

57 

58 

59class ExperimentsSettings(PrefectBaseSettings): 1a

60 """ 

61 Settings for configuring experimental features 

62 """ 

63 

64 model_config: ClassVar[SettingsConfigDict] = build_settings_config(("experiments",)) 1a

65 

66 warn: bool = Field( 1a

67 default=True, 

68 description="If `True`, warn on usage of experimental features.", 

69 validation_alias=AliasChoices( 

70 AliasPath("warn"), "prefect_experiments_warn", "prefect_experimental_warn" 

71 ), 

72 ) 

73 

74 plugins: PluginsSettings = Field( 1a

75 default_factory=PluginsSettings, 

76 description="Settings for the experimental plugin system", 

77 )