prefect-client 2.16.8__py3-none-any.whl → 2.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. prefect/__init__.py +0 -18
  2. prefect/_internal/compatibility/deprecated.py +108 -5
  3. prefect/_internal/compatibility/experimental.py +9 -8
  4. prefect/_internal/concurrency/api.py +23 -42
  5. prefect/_internal/concurrency/waiters.py +25 -22
  6. prefect/_internal/pydantic/__init__.py +16 -3
  7. prefect/_internal/pydantic/_base_model.py +39 -4
  8. prefect/_internal/pydantic/_compat.py +69 -452
  9. prefect/_internal/pydantic/_flags.py +5 -0
  10. prefect/_internal/pydantic/_types.py +8 -0
  11. prefect/_internal/pydantic/utilities/__init__.py +0 -0
  12. prefect/_internal/pydantic/utilities/config_dict.py +72 -0
  13. prefect/_internal/pydantic/utilities/field_validator.py +135 -0
  14. prefect/_internal/pydantic/utilities/model_construct.py +56 -0
  15. prefect/_internal/pydantic/utilities/model_copy.py +55 -0
  16. prefect/_internal/pydantic/utilities/model_dump.py +136 -0
  17. prefect/_internal/pydantic/utilities/model_dump_json.py +112 -0
  18. prefect/_internal/pydantic/utilities/model_fields.py +50 -0
  19. prefect/_internal/pydantic/utilities/model_fields_set.py +29 -0
  20. prefect/_internal/pydantic/utilities/model_json_schema.py +82 -0
  21. prefect/_internal/pydantic/utilities/model_rebuild.py +80 -0
  22. prefect/_internal/pydantic/utilities/model_validate.py +75 -0
  23. prefect/_internal/pydantic/utilities/model_validate_json.py +68 -0
  24. prefect/_internal/pydantic/utilities/model_validator.py +79 -0
  25. prefect/_internal/pydantic/utilities/type_adapter.py +71 -0
  26. prefect/_internal/schemas/bases.py +1 -17
  27. prefect/_internal/schemas/validators.py +425 -4
  28. prefect/agent.py +1 -1
  29. prefect/blocks/kubernetes.py +7 -3
  30. prefect/blocks/notifications.py +18 -18
  31. prefect/blocks/webhook.py +1 -1
  32. prefect/client/base.py +7 -0
  33. prefect/client/cloud.py +1 -1
  34. prefect/client/orchestration.py +51 -11
  35. prefect/client/schemas/actions.py +367 -297
  36. prefect/client/schemas/filters.py +28 -28
  37. prefect/client/schemas/objects.py +78 -147
  38. prefect/client/schemas/responses.py +240 -60
  39. prefect/client/schemas/schedules.py +6 -8
  40. prefect/concurrency/events.py +2 -2
  41. prefect/context.py +4 -2
  42. prefect/deployments/base.py +6 -13
  43. prefect/deployments/deployments.py +34 -9
  44. prefect/deployments/runner.py +9 -27
  45. prefect/deprecated/packaging/base.py +5 -6
  46. prefect/deprecated/packaging/docker.py +19 -25
  47. prefect/deprecated/packaging/file.py +10 -5
  48. prefect/deprecated/packaging/orion.py +9 -4
  49. prefect/deprecated/packaging/serializers.py +8 -58
  50. prefect/engine.py +55 -618
  51. prefect/events/actions.py +16 -1
  52. prefect/events/clients.py +45 -13
  53. prefect/events/filters.py +19 -2
  54. prefect/events/related.py +4 -4
  55. prefect/events/schemas/automations.py +13 -2
  56. prefect/events/schemas/deployment_triggers.py +73 -5
  57. prefect/events/schemas/events.py +1 -1
  58. prefect/events/utilities.py +12 -4
  59. prefect/events/worker.py +26 -8
  60. prefect/exceptions.py +3 -8
  61. prefect/filesystems.py +7 -7
  62. prefect/flows.py +7 -3
  63. prefect/infrastructure/provisioners/ecs.py +1 -0
  64. prefect/logging/configuration.py +2 -2
  65. prefect/manifests.py +1 -8
  66. prefect/profiles.toml +1 -1
  67. prefect/pydantic/__init__.py +74 -2
  68. prefect/pydantic/main.py +26 -2
  69. prefect/serializers.py +6 -31
  70. prefect/settings.py +72 -26
  71. prefect/software/python.py +3 -5
  72. prefect/task_server.py +2 -2
  73. prefect/utilities/callables.py +1 -1
  74. prefect/utilities/collections.py +2 -1
  75. prefect/utilities/dispatch.py +1 -0
  76. prefect/utilities/engine.py +629 -0
  77. prefect/utilities/pydantic.py +1 -1
  78. prefect/utilities/schema_tools/validation.py +2 -2
  79. prefect/utilities/visualization.py +1 -1
  80. prefect/variables.py +88 -12
  81. prefect/workers/base.py +20 -11
  82. prefect/workers/block.py +4 -8
  83. prefect/workers/process.py +2 -5
  84. {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/METADATA +4 -3
  85. {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/RECORD +88 -72
  86. prefect/_internal/schemas/transformations.py +0 -106
  87. {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/LICENSE +0 -0
  88. {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/WHEEL +0 -0
  89. {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/top_level.txt +0 -0
@@ -1,106 +0,0 @@
1
- import copy
2
- from dataclasses import dataclass
3
- from typing import Any, Optional, Type, TypeVar
4
-
5
- from prefect._internal.pydantic import HAS_PYDANTIC_V2
6
-
7
- if HAS_PYDANTIC_V2:
8
- from pydantic.v1 import BaseModel
9
- else:
10
- from pydantic import BaseModel
11
-
12
- B = TypeVar("B", bound=BaseModel)
13
-
14
-
15
- @dataclass
16
- class _FieldFrom:
17
- """Container for holding the origin of a field's definition"""
18
-
19
- origin: Type[BaseModel]
20
-
21
-
22
- def FieldFrom(origin: Type[BaseModel]) -> Any:
23
- """
24
- Indicates that the given field is to be copied from another class by
25
- `copy_model_fields`.
26
- """
27
- return _FieldFrom(origin=origin)
28
-
29
-
30
- def copy_model_fields(model_class: Type[B]) -> Type[B]:
31
- """
32
- A class decorator which copies field definitions and field validators from other
33
- Pydantic BaseModel classes. This does _not_ make the model a subclass of any of
34
- the copied field's owning classes, nor does this copy root validators from any of
35
- those classes. Note that you should still include the type hint for the field in
36
- order to make typing explicit.
37
-
38
- Use this decorator and the corresponding `FieldFrom` to compose response and
39
- action schemas from other classes.
40
-
41
- Examples:
42
-
43
- >>> from pydantic import BaseModel
44
- >>> from prefect._internal.schemas.transformation import copy_model_fields, FieldFrom
45
- >>>
46
- >>> class Parent(BaseModel):
47
- ... name: str
48
- ... sensitive: str
49
- >>>
50
- >>> @copy_model_fields
51
- >>> class Derived(BaseModel):
52
- ... name: str = FieldFrom(Parent)
53
- ... my_own: str
54
-
55
- In this example, `Derived` will have the fields `name`, and `my_own`, with the
56
- `name` field being a complete copy of the `Parent.name` field.
57
-
58
- """
59
- for name, field in model_class.__fields__.items():
60
- if not isinstance(field.default, _FieldFrom):
61
- continue
62
-
63
- origin = field.default.origin
64
-
65
- origin_field = origin.__fields__[name]
66
-
67
- # For safety, types defined on the model must match those of the origin
68
- # We make an exception here for `Optional` where the model can make the same
69
- # type definition nullable.
70
- if (
71
- field.type_ != origin_field.type_
72
- and not field.type_ == Optional[origin_field.type_]
73
- ):
74
- if not issubclass(
75
- origin_field.type_,
76
- field.type_,
77
- ):
78
- raise TypeError(
79
- f"Field {name} ({field.type_}) does not match the type of the"
80
- f" origin field {origin_field.type_}"
81
- )
82
-
83
- # Create a copy of the origin field
84
- new_field = copy.deepcopy(origin_field)
85
-
86
- # Retain any validators from the model field
87
- new_field.post_validators = new_field.post_validators or []
88
- new_field.pre_validators = new_field.pre_validators or []
89
- new_field.post_validators.extend(field.post_validators or [])
90
- new_field.pre_validators.extend(field.pre_validators or [])
91
-
92
- # Retain "optional" from the model field
93
- new_field.required = field.required
94
- new_field.allow_none = field.allow_none
95
-
96
- model_class.__fields__[name] = new_field
97
-
98
- if name in origin.__validators__:
99
- # The type: ignores here are because pydantic has a mistyping for these
100
- # __validators__ fields (TODO: file an upstream PR)
101
- validators: list = list(origin.__validators__[name]) # type: ignore
102
- if name in model_class.__validators__:
103
- validators.extend(model_class.__validators__[name]) # type: ignore
104
- model_class.__validators__[name] = validators # type: ignore
105
-
106
- return model_class