prefect-client 2.16.7__tar.gz → 2.16.9__tar.gz

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 (297) hide show
  1. {prefect-client-2.16.7 → prefect-client-2.16.9}/PKG-INFO +1 -1
  2. {prefect-client-2.16.7 → prefect-client-2.16.9}/requirements-client.txt +2 -1
  3. {prefect-client-2.16.7 → prefect-client-2.16.9}/requirements.txt +1 -1
  4. {prefect-client-2.16.7 → prefect-client-2.16.9}/setup.cfg +1 -0
  5. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/compatibility/experimental.py +9 -8
  6. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/api.py +23 -42
  7. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/waiters.py +25 -22
  8. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/__init__.py +12 -3
  9. prefect-client-2.16.9/src/prefect/_internal/pydantic/_base_model.py +19 -0
  10. prefect-client-2.16.9/src/prefect/_internal/pydantic/_compat.py +50 -0
  11. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/_flags.py +2 -0
  12. prefect-client-2.16.9/src/prefect/_internal/pydantic/_types.py +8 -0
  13. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_construct.py +56 -0
  14. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_copy.py +55 -0
  15. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_dump.py +136 -0
  16. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_dump_json.py +112 -0
  17. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_fields.py +50 -0
  18. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_json_schema.py +82 -0
  19. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_rebuild.py +80 -0
  20. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_validate.py +75 -0
  21. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/model_validate_json.py +68 -0
  22. prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities/type_adapter.py +71 -0
  23. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/schemas/bases.py +1 -17
  24. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/schemas/validators.py +425 -4
  25. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/kubernetes.py +7 -3
  26. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/cloud.py +1 -1
  27. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/orchestration.py +8 -8
  28. prefect-client-2.16.9/src/prefect/client/schemas/actions.py +729 -0
  29. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/schemas/objects.py +47 -126
  30. prefect-client-2.16.9/src/prefect/client/schemas/responses.py +425 -0
  31. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/concurrency/events.py +2 -2
  32. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/context.py +2 -1
  33. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/base.py +4 -3
  34. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/runner.py +7 -25
  35. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/packaging/base.py +5 -6
  36. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/packaging/docker.py +19 -25
  37. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/packaging/file.py +10 -5
  38. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/packaging/orion.py +9 -4
  39. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/packaging/serializers.py +8 -58
  40. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/engine.py +23 -22
  41. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/actions.py +16 -1
  42. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/related.py +4 -4
  43. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/schemas/automations.py +13 -2
  44. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/schemas/deployment_triggers.py +73 -5
  45. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/schemas/events.py +1 -1
  46. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/flows.py +3 -0
  47. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/provisioners/ecs.py +1 -0
  48. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/configuration.py +2 -2
  49. prefect-client-2.16.9/src/prefect/pydantic/__init__.py +50 -0
  50. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/pydantic/main.py +2 -2
  51. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/serializers.py +6 -31
  52. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/settings.py +40 -17
  53. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/software/python.py +3 -5
  54. prefect-client-2.16.9/src/prefect/utilities/__init__.py +0 -0
  55. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/callables.py +1 -1
  56. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/collections.py +2 -1
  57. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/schema_tools/validation.py +2 -2
  58. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/workers/base.py +19 -10
  59. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/workers/block.py +3 -7
  60. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/workers/process.py +2 -5
  61. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect_client.egg-info/PKG-INFO +1 -1
  62. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect_client.egg-info/SOURCES.txt +12 -1
  63. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect_client.egg-info/requires.txt +2 -1
  64. prefect-client-2.16.7/src/prefect/_internal/pydantic/_base_model.py +0 -16
  65. prefect-client-2.16.7/src/prefect/_internal/pydantic/_compat.py +0 -464
  66. prefect-client-2.16.7/src/prefect/_internal/schemas/transformations.py +0 -106
  67. prefect-client-2.16.7/src/prefect/client/schemas/actions.py +0 -666
  68. prefect-client-2.16.7/src/prefect/client/schemas/responses.py +0 -251
  69. prefect-client-2.16.7/src/prefect/pydantic/__init__.py +0 -4
  70. {prefect-client-2.16.7 → prefect-client-2.16.9}/LICENSE +0 -0
  71. {prefect-client-2.16.7 → prefect-client-2.16.9}/MANIFEST.in +0 -0
  72. {prefect-client-2.16.7 → prefect-client-2.16.9}/README.md +0 -0
  73. {prefect-client-2.16.7 → prefect-client-2.16.9}/requirements-dev.txt +0 -0
  74. {prefect-client-2.16.7 → prefect-client-2.16.9}/setup.py +0 -0
  75. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/.prefectignore +0 -0
  76. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/__init__.py +0 -0
  77. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/__init__.py +0 -0
  78. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/_logging.py +0 -0
  79. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/compatibility/__init__.py +0 -0
  80. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/compatibility/deprecated.py +0 -0
  81. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/__init__.py +0 -0
  82. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/calls.py +0 -0
  83. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/cancellation.py +0 -0
  84. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/event_loop.py +0 -0
  85. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/inspection.py +0 -0
  86. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/primitives.py +0 -0
  87. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/services.py +0 -0
  88. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/concurrency/threads.py +0 -0
  89. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/annotations/__init__.py +0 -0
  90. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/annotations/pendulum.py +0 -0
  91. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/schemas.py +0 -0
  92. {prefect-client-2.16.7/src/prefect/_internal/schemas → prefect-client-2.16.9/src/prefect/_internal/pydantic/utilities}/__init__.py +0 -0
  93. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/v1_schema.py +0 -0
  94. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/v2_schema.py +0 -0
  95. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pydantic/v2_validated_func.py +0 -0
  96. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/pytz.py +0 -0
  97. {prefect-client-2.16.7/src/prefect/_vendor → prefect-client-2.16.9/src/prefect/_internal/schemas}/__init__.py +0 -0
  98. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/schemas/fields.py +0 -0
  99. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_internal/schemas/serializers.py +0 -0
  100. {prefect-client-2.16.7/src/prefect/_vendor/fastapi/dependencies → prefect-client-2.16.9/src/prefect/_vendor}/__init__.py +0 -0
  101. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/__init__.py +0 -0
  102. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/applications.py +0 -0
  103. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/background.py +0 -0
  104. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/concurrency.py +0 -0
  105. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/datastructures.py +0 -0
  106. {prefect-client-2.16.7/src/prefect/_vendor/fastapi/openapi → prefect-client-2.16.9/src/prefect/_vendor/fastapi/dependencies}/__init__.py +0 -0
  107. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/dependencies/models.py +0 -0
  108. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/dependencies/utils.py +0 -0
  109. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/encoders.py +0 -0
  110. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/exception_handlers.py +0 -0
  111. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/exceptions.py +0 -0
  112. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/logger.py +0 -0
  113. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/__init__.py +0 -0
  114. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/asyncexitstack.py +0 -0
  115. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/cors.py +0 -0
  116. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/gzip.py +0 -0
  117. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/httpsredirect.py +0 -0
  118. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/trustedhost.py +0 -0
  119. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/middleware/wsgi.py +0 -0
  120. {prefect-client-2.16.7/src/prefect/concurrency → prefect-client-2.16.9/src/prefect/_vendor/fastapi/openapi}/__init__.py +0 -0
  121. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/openapi/constants.py +0 -0
  122. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/openapi/docs.py +0 -0
  123. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/openapi/models.py +0 -0
  124. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/openapi/utils.py +0 -0
  125. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/param_functions.py +0 -0
  126. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/params.py +0 -0
  127. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/requests.py +0 -0
  128. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/responses.py +0 -0
  129. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/routing.py +0 -0
  130. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/__init__.py +0 -0
  131. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/api_key.py +0 -0
  132. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/base.py +0 -0
  133. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/http.py +0 -0
  134. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/oauth2.py +0 -0
  135. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/open_id_connect_url.py +0 -0
  136. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/security/utils.py +0 -0
  137. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/staticfiles.py +0 -0
  138. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/templating.py +0 -0
  139. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/testclient.py +0 -0
  140. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/types.py +0 -0
  141. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/utils.py +0 -0
  142. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/fastapi/websockets.py +0 -0
  143. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/__init__.py +0 -0
  144. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/_compat.py +0 -0
  145. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/_exception_handler.py +0 -0
  146. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/_utils.py +0 -0
  147. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/applications.py +0 -0
  148. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/authentication.py +0 -0
  149. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/background.py +0 -0
  150. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/concurrency.py +0 -0
  151. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/config.py +0 -0
  152. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/convertors.py +0 -0
  153. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/datastructures.py +0 -0
  154. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/endpoints.py +0 -0
  155. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/exceptions.py +0 -0
  156. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/formparsers.py +0 -0
  157. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/__init__.py +0 -0
  158. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/authentication.py +0 -0
  159. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/base.py +0 -0
  160. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/cors.py +0 -0
  161. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/errors.py +0 -0
  162. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/exceptions.py +0 -0
  163. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/gzip.py +0 -0
  164. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/httpsredirect.py +0 -0
  165. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/sessions.py +0 -0
  166. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/trustedhost.py +0 -0
  167. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/middleware/wsgi.py +0 -0
  168. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/requests.py +0 -0
  169. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/responses.py +0 -0
  170. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/routing.py +0 -0
  171. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/schemas.py +0 -0
  172. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/staticfiles.py +0 -0
  173. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/status.py +0 -0
  174. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/templating.py +0 -0
  175. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/testclient.py +0 -0
  176. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/types.py +0 -0
  177. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_vendor/starlette/websockets.py +0 -0
  178. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/_version.py +0 -0
  179. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/agent.py +0 -0
  180. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/artifacts.py +0 -0
  181. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/__init__.py +0 -0
  182. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/abstract.py +0 -0
  183. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/core.py +0 -0
  184. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/fields.py +0 -0
  185. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/notifications.py +0 -0
  186. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/system.py +0 -0
  187. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/blocks/webhook.py +0 -0
  188. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/__init__.py +0 -0
  189. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/base.py +0 -0
  190. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/collections.py +0 -0
  191. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/constants.py +0 -0
  192. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/schemas/__init__.py +0 -0
  193. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/schemas/filters.py +0 -0
  194. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/schemas/schedules.py +0 -0
  195. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/schemas/sorting.py +0 -0
  196. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/subscriptions.py +0 -0
  197. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/client/utilities.py +0 -0
  198. {prefect-client-2.16.7/src/prefect/deprecated → prefect-client-2.16.9/src/prefect/concurrency}/__init__.py +0 -0
  199. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/concurrency/asyncio.py +0 -0
  200. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/concurrency/common.py +0 -0
  201. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/concurrency/services.py +0 -0
  202. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/concurrency/sync.py +0 -0
  203. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/__init__.py +0 -0
  204. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/deployments.py +0 -0
  205. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/schedules.py +0 -0
  206. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/steps/__init__.py +0 -0
  207. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/steps/core.py +0 -0
  208. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/steps/pull.py +0 -0
  209. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deployments/steps/utility.py +0 -0
  210. {prefect-client-2.16.7/src/prefect/utilities → prefect-client-2.16.9/src/prefect/deprecated}/__init__.py +0 -0
  211. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/data_documents.py +0 -0
  212. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/deprecated/packaging/__init__.py +0 -0
  213. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/__init__.py +0 -0
  214. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/clients.py +0 -0
  215. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/filters.py +0 -0
  216. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/instrument.py +0 -0
  217. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/schemas/__init__.py +0 -0
  218. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/schemas/labelling.py +0 -0
  219. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/utilities.py +0 -0
  220. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/events/worker.py +0 -0
  221. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/exceptions.py +0 -0
  222. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/filesystems.py +0 -0
  223. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/flow_runs.py +0 -0
  224. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/futures.py +0 -0
  225. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/__init__.py +0 -0
  226. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/base.py +0 -0
  227. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/container.py +0 -0
  228. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/kubernetes.py +0 -0
  229. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/process.py +0 -0
  230. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/provisioners/__init__.py +0 -0
  231. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/provisioners/cloud_run.py +0 -0
  232. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/provisioners/container_instance.py +0 -0
  233. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/infrastructure/provisioners/modal.py +0 -0
  234. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/input/__init__.py +0 -0
  235. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/input/actions.py +0 -0
  236. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/input/run_input.py +0 -0
  237. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/__init__.py +0 -0
  238. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/filters.py +0 -0
  239. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/formatters.py +0 -0
  240. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/handlers.py +0 -0
  241. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/highlighters.py +0 -0
  242. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/loggers.py +0 -0
  243. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/logging/logging.yml +0 -0
  244. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/manifests.py +0 -0
  245. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/plugins.py +0 -0
  246. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/profiles.toml +0 -0
  247. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/py.typed +0 -0
  248. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/results.py +0 -0
  249. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runner/__init__.py +0 -0
  250. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runner/runner.py +0 -0
  251. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runner/server.py +0 -0
  252. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runner/storage.py +0 -0
  253. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runner/submit.py +0 -0
  254. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runner/utils.py +0 -0
  255. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runtime/__init__.py +0 -0
  256. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runtime/deployment.py +0 -0
  257. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runtime/flow_run.py +0 -0
  258. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/runtime/task_run.py +0 -0
  259. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/server/api/collections_data/views/aggregate-worker-metadata.json +0 -0
  260. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/server/api/static/prefect-logo-mark-gradient.png +0 -0
  261. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/software/__init__.py +0 -0
  262. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/software/base.py +0 -0
  263. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/software/conda.py +0 -0
  264. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/software/pip.py +0 -0
  265. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/states.py +0 -0
  266. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/task_engine.py +0 -0
  267. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/task_runners.py +0 -0
  268. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/task_server.py +0 -0
  269. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/tasks.py +0 -0
  270. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/annotations.py +0 -0
  271. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/asyncutils.py +0 -0
  272. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/compat.py +0 -0
  273. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/context.py +0 -0
  274. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/dispatch.py +0 -0
  275. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/dockerutils.py +0 -0
  276. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/filesystem.py +0 -0
  277. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/hashing.py +0 -0
  278. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/importtools.py +0 -0
  279. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/math.py +0 -0
  280. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/names.py +0 -0
  281. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/processutils.py +0 -0
  282. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/pydantic.py +0 -0
  283. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/render_swagger.py +0 -0
  284. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/schema_tools/__init__.py +0 -0
  285. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/schema_tools/hydration.py +0 -0
  286. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/services.py +0 -0
  287. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/slugify.py +0 -0
  288. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/templating.py +0 -0
  289. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/text.py +0 -0
  290. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/utilities/visualization.py +0 -0
  291. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/variables.py +0 -0
  292. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/workers/__init__.py +0 -0
  293. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/workers/server.py +0 -0
  294. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect/workers/utilities.py +0 -0
  295. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect_client.egg-info/dependency_links.txt +0 -0
  296. {prefect-client-2.16.7 → prefect-client-2.16.9}/src/prefect_client.egg-info/top_level.txt +0 -0
  297. {prefect-client-2.16.7 → prefect-client-2.16.9}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.16.7
3
+ Version: 2.16.9
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
@@ -7,7 +7,7 @@ croniter >= 1.0.12, < 3.0.0
7
7
  fsspec >= 2022.5.0
8
8
  graphviz >= 0.20.1
9
9
  griffe >= 0.20.0
10
- httpcore >=0.15.0, < 2.0.0
10
+ httpcore >=1.0.5, < 2.0.0
11
11
  httpx[http2] >= 0.23, != 0.23.2
12
12
  importlib_metadata >= 4.4; python_version < '3.10'
13
13
  importlib-resources >= 6.1.3, < 6.2.0
@@ -21,6 +21,7 @@ pendulum < 3.0; python_version < '3.12'
21
21
  pendulum >= 3.0.0, <4; python_version >= '3.12'
22
22
  # the version constraints for pydantic are merged with those from fastapi 0.103.2
23
23
  pydantic[email]>=1.10.0,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0
24
+ pydantic_core >= 2.10.0, < 3.0.0
24
25
  python_dateutil >= 2.8.2, < 3.0.0
25
26
  python-slugify >= 5.0, < 9.0
26
27
  pyyaml >= 5.4.1, < 7.0.0
@@ -15,4 +15,4 @@ kubernetes >= 24.2.0, < 30.0.0
15
15
  pytz >= 2021.1, < 2025
16
16
  readchar >= 4.0.0, < 5.0.0
17
17
  sqlalchemy[asyncio] >= 1.4.22, != 1.4.33, < 3.0.0
18
- typer >= 0.4.2
18
+ typer >= 0.12.0, < 0.13.0
@@ -13,6 +13,7 @@ markers =
13
13
  clear_db: marker to clear the database after test completion
14
14
  env =
15
15
  PREFECT_TEST_MODE = 1
16
+ PREFECT_LOGGING_SERVER_LEVEL = DEBUG
16
17
  asyncio_mode = auto
17
18
  timeout = 90
18
19
  filterwarnings =
@@ -10,6 +10,7 @@ Warnings may also be disabled globally with the setting `PREFECT_EXPERIMENTAL_WA
10
10
  Some experimental features require opt-in to enable any usage. These require the setting
11
11
  `PREFECT_EXPERIMENTAL_ENABLE_<GROUP>` to be set or an error will be thrown on use.
12
12
  """
13
+
13
14
  import functools
14
15
  import warnings
15
16
  from typing import Any, Callable, Optional, Set, Type, TypeVar
@@ -24,7 +25,7 @@ else:
24
25
  from prefect.settings import PREFECT_EXPERIMENTAL_WARN, SETTING_VARIABLES, Setting
25
26
  from prefect.utilities.callables import get_call_parameters
26
27
 
27
- T = TypeVar("T", bound=Callable)
28
+ T = TypeVar("T", bound=Callable[..., Any])
28
29
  M = TypeVar("M", bound=pydantic.BaseModel)
29
30
 
30
31
 
@@ -47,12 +48,6 @@ class ExperimentalWarning(Warning):
47
48
  """
48
49
 
49
50
 
50
- class ExperimentalError(Exception):
51
- """
52
- An exception related to experimental code.
53
- """
54
-
55
-
56
51
  class ExperimentalFeature(ExperimentalWarning):
57
52
  """
58
53
  A warning displayed on use of an experimental feature.
@@ -61,6 +56,12 @@ class ExperimentalFeature(ExperimentalWarning):
61
56
  """
62
57
 
63
58
 
59
+ class ExperimentalError(Exception):
60
+ """
61
+ An exception related to experimental code.
62
+ """
63
+
64
+
64
65
  class ExperimentalFeatureDisabled(ExperimentalError):
65
66
  """
66
67
  An error displayed on use of a disabled experimental feature that requires opt-in.
@@ -112,7 +113,7 @@ def experimental(
112
113
 
113
114
  group_warn = _warn_setting_for_group(group)
114
115
 
115
- def decorator(fn: T):
116
+ def decorator(fn: T) -> T:
116
117
  @functools.wraps(fn)
117
118
  def wrapper(*args, **kwargs):
118
119
  if opt_in and not group_opt_in:
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Primary developer-facing API for concurrency management.
3
3
  """
4
+
4
5
  import abc
5
6
  import asyncio
6
7
  import concurrent.futures
@@ -18,6 +19,7 @@ from typing import (
18
19
 
19
20
  from typing_extensions import ParamSpec
20
21
 
22
+ from prefect._internal.concurrency.calls import get_current_call
21
23
  from prefect._internal.concurrency.threads import (
22
24
  WorkerThread,
23
25
  get_global_loop,
@@ -104,40 +106,6 @@ class _base(abc.ABC):
104
106
  runner.submit(call)
105
107
  return call
106
108
 
107
- @staticmethod
108
- def call_soon_in_waiting_thread(
109
- __call: Union[Callable[[], T], Call[T]],
110
- thread: threading.Thread,
111
- timeout: Optional[float] = None,
112
- ) -> Call[T]:
113
- """
114
- Schedule a call for execution in the thread that is waiting for the current
115
- call.
116
-
117
- Returns the submitted call.
118
- """
119
- call = _cast_to_call(__call)
120
- waiter = get_waiter_for_thread(thread)
121
- if waiter is None:
122
- raise RuntimeError(f"No waiter found for thread {thread}.")
123
-
124
- call.set_timeout(timeout)
125
- waiter.submit(call)
126
- return call
127
-
128
- @staticmethod
129
- def call_in_waiting_thread(
130
- __call: Union[Callable[[], T], Call[T]],
131
- thread: threading.Thread,
132
- timeout: Optional[float] = None,
133
- ) -> T:
134
- """
135
- Run a call in the thread that is waiting for the current call.
136
-
137
- Returns the result of the call.
138
- """
139
- raise NotImplementedError()
140
-
141
109
  @staticmethod
142
110
  def call_in_new_thread(
143
111
  __call: Union[Callable[[], T], Call[T]], timeout: Optional[float] = None
@@ -196,13 +164,20 @@ class from_async(_base):
196
164
  return call.result()
197
165
 
198
166
  @staticmethod
199
- def call_in_waiting_thread(
167
+ def call_soon_in_waiting_thread(
200
168
  __call: Union[Callable[[], T], Call[T]],
201
169
  thread: threading.Thread,
202
170
  timeout: Optional[float] = None,
203
- ) -> Awaitable[T]:
204
- call = _base.call_soon_in_waiting_thread(__call, thread, timeout=timeout)
205
- return call.aresult()
171
+ ) -> Call[T]:
172
+ call = _cast_to_call(__call)
173
+ parent_call = get_current_call()
174
+ waiter = get_waiter_for_thread(thread, parent_call)
175
+ if waiter is None:
176
+ raise RuntimeError(f"No waiter found for thread {thread}.")
177
+
178
+ call.set_timeout(timeout)
179
+ waiter.submit(call)
180
+ return call
206
181
 
207
182
  @staticmethod
208
183
  def call_in_new_thread(
@@ -257,13 +232,19 @@ class from_sync(_base):
257
232
  return call.result()
258
233
 
259
234
  @staticmethod
260
- def call_in_waiting_thread(
235
+ def call_soon_in_waiting_thread(
261
236
  __call: Union[Callable[[], T], Call[T]],
262
237
  thread: threading.Thread,
263
238
  timeout: Optional[float] = None,
264
- ) -> T:
265
- call = _base.call_soon_in_waiting_thread(__call, thread, timeout=timeout)
266
- return call.result()
239
+ ) -> Call[T]:
240
+ call = _cast_to_call(__call)
241
+ waiter = get_waiter_for_thread(thread)
242
+ if waiter is None:
243
+ raise RuntimeError(f"No waiter found for thread {thread}.")
244
+
245
+ call.set_timeout(timeout)
246
+ waiter.submit(call)
247
+ return call
267
248
 
268
249
  @staticmethod
269
250
  def call_in_new_thread(
@@ -9,9 +9,9 @@ import contextlib
9
9
  import inspect
10
10
  import queue
11
11
  import threading
12
- import weakref
13
12
  from collections import deque
14
13
  from typing import Awaitable, Generic, List, Optional, TypeVar, Union
14
+ from weakref import WeakKeyDictionary
15
15
 
16
16
  import anyio
17
17
 
@@ -24,34 +24,37 @@ T = TypeVar("T")
24
24
 
25
25
 
26
26
  # Waiters are stored in a stack for each thread
27
- _WAITERS_BY_THREAD: "weakref.WeakKeyDictionary[threading.Thread, deque[Waiter]]" = (
28
- weakref.WeakKeyDictionary()
27
+ _WAITERS_BY_THREAD: "WeakKeyDictionary[threading.Thread, deque[Waiter]]" = (
28
+ WeakKeyDictionary()
29
29
  )
30
30
 
31
31
 
32
- def get_waiter_for_thread(thread: threading.Thread) -> Optional["Waiter"]:
32
+ def get_waiter_for_thread(
33
+ thread: threading.Thread, parent_call: Optional[Call] = None
34
+ ) -> Optional["Waiter"]:
33
35
  """
34
- Get the current waiter for a thread.
36
+ Get the current waiter for a thread and an optional parent call.
35
37
 
36
- Returns `None` if one does not exist.
38
+ To avoid assigning outer callbacks to inner waiters in the case of nested calls,
39
+ the parent call is used to determine which waiter to return. If a parent call is
40
+ not provided, we return the most recently created waiter (last in the stack).
41
+
42
+ see https://github.com/PrefectHQ/prefect/issues/12036
43
+
44
+ Returns `None` if no active waiter is found for the thread.
37
45
  """
38
- waiters = _WAITERS_BY_THREAD.get(thread)
39
-
40
- if waiters:
41
- idx = -1
42
- while abs(idx) <= len(waiters):
43
- try:
44
- waiter = waiters[idx]
45
- if not waiter.call_is_done():
46
- return waiter
47
- idx = idx - 1
48
- # It is possible that items are being added or removed
49
- # from the deque, so the index we're using may not always
50
- # be valid.
51
- except IndexError:
52
- break
53
46
 
54
- return None
47
+ waiters: "Optional[deque[Waiter]]" = _WAITERS_BY_THREAD.get(thread)
48
+
49
+ if waiters and (active_waiters := [w for w in waiters if not w.call_is_done()]):
50
+ if parent_call and (
51
+ matching_waiter := next(
52
+ (w for w in active_waiters if w._call == parent_call), None
53
+ )
54
+ ): # if exists an active waiter responsible for the parent call, return it
55
+ return matching_waiter
56
+ else: # otherwise, return the most recently created waiter
57
+ return active_waiters[-1]
55
58
 
56
59
 
57
60
  def add_waiter_for_thread(waiter: "Waiter", thread: threading.Thread):
@@ -6,21 +6,25 @@
6
6
  ### This is a tradeoff we're willing to make for now until pydantic v1 is
7
7
  ### no longer supported.
8
8
 
9
- from pydantic.version import VERSION as PYDANTIC_VERSION
10
9
 
11
- HAS_PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.")
10
+ from ._flags import HAS_PYDANTIC_V2
12
11
 
13
12
  from ._compat import (
14
13
  model_dump,
15
14
  model_json_schema,
16
15
  model_validate,
17
- IncEx,
18
16
  model_dump_json,
19
17
  model_copy,
20
18
  model_validate_json,
19
+ TypeAdapter,
21
20
  validate_python,
21
+ BaseModel,
22
+ Field,
23
+ FieldInfo,
22
24
  )
23
25
 
26
+ from ._types import IncEx
27
+
24
28
  __all__ = [
25
29
  "model_dump",
26
30
  "model_json_schema",
@@ -29,5 +33,10 @@ __all__ = [
29
33
  "model_dump_json",
30
34
  "model_copy",
31
35
  "model_validate_json",
36
+ "TypeAdapter",
32
37
  "validate_python",
38
+ "BaseModel",
39
+ "HAS_PYDANTIC_V2",
40
+ "Field",
41
+ "FieldInfo",
33
42
  ]
@@ -0,0 +1,19 @@
1
+ import typing
2
+
3
+ from prefect._internal.pydantic._flags import (
4
+ HAS_PYDANTIC_V2,
5
+ USE_PYDANTIC_V2,
6
+ )
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from pydantic import BaseModel, Field
10
+ from pydantic.fields import FieldInfo
11
+
12
+ if HAS_PYDANTIC_V2 and not USE_PYDANTIC_V2:
13
+ from pydantic.v1 import BaseModel, Field
14
+ from pydantic.v1.fields import FieldInfo
15
+ else:
16
+ from pydantic import BaseModel, Field
17
+ from pydantic.fields import FieldInfo
18
+
19
+ __all__ = ["BaseModel", "Field", "FieldInfo"]
@@ -0,0 +1,50 @@
1
+ from ._base_model import BaseModel as PydanticBaseModel
2
+ from ._base_model import Field, FieldInfo
3
+ from ._flags import HAS_PYDANTIC_V2, USE_PYDANTIC_V2
4
+ from .utilities.model_construct import ModelConstructMixin, model_construct
5
+ from .utilities.model_copy import ModelCopyMixin, model_copy
6
+ from .utilities.model_dump import ModelDumpMixin, model_dump
7
+ from .utilities.model_dump_json import ModelDumpJsonMixin, model_dump_json
8
+ from .utilities.model_fields import ModelFieldMixin
9
+ from .utilities.model_json_schema import ModelJsonSchemaMixin, model_json_schema
10
+ from .utilities.model_validate import ModelValidateMixin, model_validate
11
+ from .utilities.model_validate_json import ModelValidateJsonMixin, model_validate_json
12
+ from .utilities.type_adapter import TypeAdapter, validate_python
13
+
14
+ if HAS_PYDANTIC_V2 and USE_PYDANTIC_V2:
15
+ # In this case, there's no functionality to add, so we just alias the Pydantic v2 BaseModel
16
+ class BaseModel(PydanticBaseModel): # type: ignore
17
+ pass
18
+
19
+ else:
20
+ # In this case, we're working with a Pydantic v1 model, so we need to add Pydantic v2 functionality
21
+ # TODO: Find a smarter way of attaching these methods so that they don't need to be redefined
22
+
23
+ class BaseModel(
24
+ ModelConstructMixin,
25
+ ModelCopyMixin,
26
+ ModelDumpMixin,
27
+ ModelDumpJsonMixin,
28
+ ModelJsonSchemaMixin,
29
+ ModelValidateMixin,
30
+ ModelValidateJsonMixin,
31
+ ModelFieldMixin,
32
+ PydanticBaseModel,
33
+ ):
34
+ pass
35
+
36
+
37
+ __all__ = [
38
+ "model_construct",
39
+ "model_copy",
40
+ "model_dump",
41
+ "model_dump_json",
42
+ "model_json_schema",
43
+ "model_validate",
44
+ "model_validate_json",
45
+ "TypeAdapter",
46
+ "validate_python",
47
+ "BaseModel",
48
+ "Field",
49
+ "FieldInfo",
50
+ ]
@@ -11,5 +11,7 @@ USE_PYDANTIC_V2 = os.environ.get(
11
11
  "PREFECT_EXPERIMENTAL_ENABLE_PYDANTIC_V2_INTERNALS", False
12
12
  ) in {"1", "true", "True"}
13
13
 
14
+ USE_V2_MODELS = HAS_PYDANTIC_V2 and USE_PYDANTIC_V2
15
+
14
16
  # Set to True if Pydantic v2 is present but not enabled, indicating deprecation warnings may occur.
15
17
  EXPECT_DEPRECATION_WARNINGS = HAS_PYDANTIC_V2 and not USE_PYDANTIC_V2
@@ -0,0 +1,8 @@
1
+ from typing import Any, Dict, Literal, Set, Union
2
+
3
+ from typing_extensions import TypeAlias
4
+
5
+ IncEx: TypeAlias = "Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any], None]"
6
+
7
+ DEFAULT_REF_TEMPLATE = "#/$defs/{model}"
8
+ JsonSchemaMode = Literal["validation", "serialization"]
@@ -0,0 +1,56 @@
1
+ import typing
2
+
3
+ from typing_extensions import Self
4
+
5
+ from prefect._internal.pydantic._base_model import BaseModel
6
+ from prefect._internal.pydantic._flags import USE_V2_MODELS
7
+
8
+ T = typing.TypeVar("T", bound="BaseModel")
9
+
10
+
11
+ def model_construct(
12
+ model: typing.Type[T],
13
+ _fields_set: typing.Optional[typing.Set[str]] = None,
14
+ **values: typing.Any,
15
+ ) -> T:
16
+ """Creates a new instance of the `model` class with validated data.
17
+
18
+ Creates a new model setting `__dict__` and `__pydantic_fields_set__` from trusted or pre-validated data.
19
+ Default values are respected, but no other validation is performed.
20
+
21
+ Args:
22
+ _fields_set: The set of field names accepted for the Model instance.
23
+ values: Trusted or pre-validated data dictionary.
24
+
25
+ Returns:
26
+ A new instance of the `model` class with validated data.
27
+ """
28
+ if USE_V2_MODELS:
29
+ return model.model_construct(_fields_set=_fields_set, **values)
30
+ else:
31
+ return getattr(model, "construct")(**values)
32
+
33
+
34
+ class ModelConstructMixin(BaseModel):
35
+ @classmethod
36
+ def model_construct(
37
+ cls: typing.Type["Self"],
38
+ _fields_set: typing.Optional[typing.Set[str]] = None,
39
+ **values: typing.Any,
40
+ ) -> "Self":
41
+ """Creates a new instance of the `model` class with validated data.
42
+
43
+ Creates a new model setting `__dict__` and `__pydantic_fields_set__` from trusted or pre-validated data.
44
+ Default values are respected, but no other validation is performed.
45
+
46
+ Args:
47
+ _fields_set: The set of field names accepted for the Model instance.
48
+ values: Trusted or pre-validated data dictionary.
49
+
50
+ Returns:
51
+ A new instance of the `model` class with validated data.
52
+ """
53
+ return model_construct(cls, _fields_set=_fields_set, **values)
54
+
55
+
56
+ __all__ = ["model_construct", "ModelConstructMixin"]
@@ -0,0 +1,55 @@
1
+ import typing
2
+
3
+ from typing_extensions import Self
4
+
5
+ from prefect._internal.pydantic._base_model import BaseModel
6
+ from prefect._internal.pydantic._flags import USE_V2_MODELS
7
+
8
+ T = typing.TypeVar("T", bound="BaseModel")
9
+
10
+
11
+ def model_copy( # type: ignore[no-redef]
12
+ model_instance: T,
13
+ *,
14
+ update: typing.Optional[typing.Dict[str, typing.Any]] = None,
15
+ deep: bool = False,
16
+ ) -> T:
17
+ """
18
+ Returns a copy of the model.
19
+
20
+ Args:
21
+ update: Values to change/add in the new model. Note: the data is not validated
22
+ before creating the new model. You should trust this data.
23
+ deep: Set to `True` to make a deep copy of the model.
24
+
25
+ Returns:
26
+ New model instance.
27
+ """
28
+ if USE_V2_MODELS:
29
+ return model_instance.model_copy(update=update, deep=deep)
30
+ else:
31
+ return getattr(model_instance, "copy")(update=update, deep=deep)
32
+
33
+
34
+ class ModelCopyMixin(BaseModel):
35
+ def model_copy(
36
+ self: "Self",
37
+ *,
38
+ update: typing.Optional[typing.Dict[str, typing.Any]] = None,
39
+ deep: bool = False,
40
+ ) -> "Self":
41
+ """
42
+ Returns a copy of the model.
43
+
44
+ Args:
45
+ update: Values to change/add in the new model. Note: the data is not validated
46
+ before creating the new model. You should trust this data.
47
+ deep: Set to `True` to make a deep copy of the model.
48
+
49
+ Returns:
50
+ New model instance.
51
+ """
52
+ return model_copy(self, update=update, deep=deep)
53
+
54
+
55
+ __all__ = ["model_copy"]
@@ -0,0 +1,136 @@
1
+ import typing
2
+ import warnings as python_warnings
3
+
4
+ from pydantic_core import from_json
5
+ from typing_extensions import Self
6
+
7
+ from prefect._internal.pydantic._base_model import BaseModel
8
+ from prefect._internal.pydantic._flags import USE_V2_MODELS
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from prefect._internal.pydantic._types import IncEx
12
+
13
+ T = typing.TypeVar("T", bound="BaseModel")
14
+
15
+
16
+ def model_dump( # type: ignore[no-redef]
17
+ model_instance: "BaseModel",
18
+ *,
19
+ mode: typing.Union[typing.Literal["json", "python"], str] = "python",
20
+ include: "IncEx" = None,
21
+ exclude: "IncEx" = None,
22
+ by_alias: bool = False,
23
+ exclude_unset: bool = False,
24
+ exclude_defaults: bool = False,
25
+ exclude_none: bool = False,
26
+ round_trip: bool = False,
27
+ warnings: bool = True,
28
+ ) -> typing.Dict[str, typing.Any]:
29
+ """
30
+ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
31
+
32
+ Args:
33
+ mode: The mode in which `to_python` should run.
34
+ If mode is 'json', the output will only contain JSON serializable types.
35
+ If mode is 'python', the output may contain non-JSON-serializable Python objects.
36
+ include: A set of fields to include in the output.
37
+ exclude: A set of fields to exclude from the output.
38
+ context: Additional context to pass to the serializer.
39
+ by_alias: Whether to use the field's alias in the dictionary key if defined.
40
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
41
+ exclude_defaults: Whether to exclude fields that are set to their default value.
42
+ exclude_none: Whether to exclude fields that have a value of `None`.
43
+ round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
44
+ warnings: Whether to log warnings when invalid fields are encountered.
45
+ serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
46
+
47
+ Returns:
48
+ A dictionary representation of the model.
49
+ """
50
+ if USE_V2_MODELS:
51
+ return model_instance.model_dump(
52
+ mode=mode,
53
+ include=include,
54
+ exclude=exclude,
55
+ by_alias=by_alias,
56
+ exclude_unset=exclude_unset,
57
+ exclude_defaults=exclude_defaults,
58
+ exclude_none=exclude_none,
59
+ round_trip=round_trip,
60
+ warnings=warnings,
61
+ )
62
+ else:
63
+ if mode == "json":
64
+ with python_warnings.catch_warnings():
65
+ python_warnings.simplefilter("ignore")
66
+ return from_json(
67
+ model_instance.json(
68
+ include=include,
69
+ exclude=exclude,
70
+ by_alias=by_alias,
71
+ exclude_unset=exclude_unset,
72
+ exclude_defaults=exclude_defaults,
73
+ exclude_none=exclude_none,
74
+ )
75
+ )
76
+
77
+ return getattr(model_instance, "dict")(
78
+ include=include,
79
+ exclude=exclude,
80
+ by_alias=by_alias,
81
+ exclude_unset=exclude_unset,
82
+ exclude_defaults=exclude_defaults,
83
+ exclude_none=exclude_none,
84
+ )
85
+
86
+
87
+ class ModelDumpMixin(BaseModel):
88
+ def model_dump(
89
+ self: "Self",
90
+ *,
91
+ mode: typing.Union[typing.Literal["json", "python"], str] = "python",
92
+ include: "IncEx" = None,
93
+ exclude: "IncEx" = None,
94
+ by_alias: bool = False,
95
+ exclude_unset: bool = False,
96
+ exclude_defaults: bool = False,
97
+ exclude_none: bool = False,
98
+ round_trip: bool = False,
99
+ warnings: bool = True,
100
+ ) -> typing.Dict[str, typing.Any]:
101
+ """
102
+ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
103
+
104
+ Args:
105
+ mode: The mode in which `to_python` should run.
106
+ If mode is 'json', the output will only contain JSON serializable types.
107
+ If mode is 'python', the output may contain non-JSON-serializable Python objects.
108
+ include: A set of fields to include in the output.
109
+ exclude: A set of fields to exclude from the output.
110
+ context: Additional context to pass to the serializer.
111
+ by_alias: Whether to use the field's alias in the dictionary key if defined.
112
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
113
+ exclude_defaults: Whether to exclude fields that are set to their default value.
114
+ exclude_none: Whether to exclude fields that have a value of `None`.
115
+ round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
116
+ warnings: Whether to log warnings when invalid fields are encountered.
117
+ serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
118
+
119
+ Returns:
120
+ A dictionary representation of the model.
121
+ """
122
+ return model_dump(
123
+ self,
124
+ mode=mode,
125
+ include=include,
126
+ exclude=exclude,
127
+ by_alias=by_alias,
128
+ exclude_unset=exclude_unset,
129
+ exclude_defaults=exclude_defaults,
130
+ exclude_none=exclude_none,
131
+ round_trip=round_trip,
132
+ warnings=warnings,
133
+ )
134
+
135
+
136
+ __all__ = ["model_dump", "ModelDumpMixin"]