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

33 statements  

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

1# Import user-facing API 

2from typing import Any 1a

3from prefect.states import State 1a

4from prefect.logging import get_run_logger 1a

5from prefect.flows import FlowDecorator, flow, Flow, serve, aserve 1a

6from prefect.transactions import Transaction 1a

7from prefect.tasks import task, Task 1a

8from prefect.context import tags 1a

9from prefect.utilities.annotations import unmapped, allow_failure 1a

10from prefect._result_records import ResultRecordMetadata 1a

11from prefect.flow_runs import pause_flow_run, resume_flow_run, suspend_flow_run 1a

12from prefect.client.orchestration import get_client 1a

13from prefect.client.cloud import get_cloud_client 1a

14import prefect.variables # pyright: ignore[reportUnusedImport] # TODO: Does this need to be imported here? 1a

15import prefect.runtime # pyright: ignore[reportUnusedImport] # TODO: Does this need to be imported here? 1a

16 

17# Import modules that register types 

18import prefect.serializers # pyright: ignore[reportUnusedImport] 1a

19import prefect.blocks.notifications # pyright: ignore[reportUnusedImport] 1a

20import prefect.blocks.system # pyright: ignore[reportUnusedImport] 1a

21 

22# Initialize the process-wide profile and registry at import time 

23import prefect.context 1a

24 

25# Perform any forward-ref updates needed for Pydantic models 

26import prefect.client.schemas 1a

27 

28_types: dict[str, Any] = dict( 1a

29 Task=Task, 

30 Flow=Flow, 

31 ResultRecordMetadata=ResultRecordMetadata, 

32) 

33prefect.context.FlowRunContext.model_rebuild(_types_namespace=_types) 1a

34prefect.context.TaskRunContext.model_rebuild(_types_namespace=_types) 1a

35prefect.client.schemas.State.model_rebuild(_types_namespace=_types) 1a

36prefect.client.schemas.StateCreate.model_rebuild(_types_namespace=_types) 1a

37prefect.client.schemas.OrchestrationResult.model_rebuild(_types_namespace=_types) 1a

38Transaction.model_rebuild() 1a

39 

40# Configure logging 

41import prefect.logging.configuration 1a

42 

43prefect.logging.configuration.setup_logging() 1a

44prefect.logging.get_logger("profiles").debug( 1a

45 f"Using profile {prefect.context.get_settings_context().profile.name!r}" 

46) 

47 

48 

49from prefect._internal.compatibility.deprecated import ( 1a

50 inject_renamed_module_alias_finder, 

51) 

52 

53inject_renamed_module_alias_finder() 1a

54 

55flow: FlowDecorator 1a

56 

57 

58# Declare API for type-checkers 

59__all__ = [ 1a

60 "allow_failure", 

61 "flow", 

62 "Flow", 

63 "get_client", 

64 "get_cloud_client", 

65 "get_run_logger", 

66 "State", 

67 "tags", 

68 "task", 

69 "Task", 

70 "Transaction", 

71 "unmapped", 

72 "serve", 

73 "aserve", 

74 "pause_flow_run", 

75 "resume_flow_run", 

76 "suspend_flow_run", 

77]