prefect-client 2.18.1__tar.gz → 2.18.2__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 (303) hide show
  1. {prefect-client-2.18.1/src/prefect_client.egg-info → prefect-client-2.18.2}/PKG-INFO +1 -1
  2. {prefect-client-2.18.1 → prefect-client-2.18.2}/setup.cfg +2 -4
  3. prefect-client-2.18.2/src/prefect/automations.py +162 -0
  4. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/orchestration.py +29 -11
  5. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/objects.py +11 -8
  6. prefect-client-2.18.2/src/prefect/events/cli/automations.py +324 -0
  7. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/clients.py +3 -2
  8. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/filters.py +1 -1
  9. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/schemas/automations.py +2 -2
  10. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/schemas/deployment_triggers.py +1 -1
  11. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/schemas/events.py +11 -4
  12. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/schemas/labelling.py +1 -1
  13. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/flows.py +14 -11
  14. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/input/run_input.py +3 -1
  15. prefect-client-2.18.2/src/prefect/new_flow_engine.py +444 -0
  16. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/new_task_engine.py +159 -45
  17. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/server/api/collections_data/views/aggregate-worker-metadata.json +1 -1
  18. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/settings.py +21 -0
  19. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/tasks.py +134 -24
  20. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/asyncutils.py +16 -12
  21. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/workers/process.py +2 -1
  22. {prefect-client-2.18.1 → prefect-client-2.18.2/src/prefect_client.egg-info}/PKG-INFO +1 -1
  23. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect_client.egg-info/SOURCES.txt +1 -0
  24. prefect-client-2.18.1/src/prefect/events/cli/automations.py +0 -201
  25. prefect-client-2.18.1/src/prefect/new_flow_engine.py +0 -293
  26. {prefect-client-2.18.1 → prefect-client-2.18.2}/LICENSE +0 -0
  27. {prefect-client-2.18.1 → prefect-client-2.18.2}/MANIFEST.in +0 -0
  28. {prefect-client-2.18.1 → prefect-client-2.18.2}/README.md +0 -0
  29. {prefect-client-2.18.1 → prefect-client-2.18.2}/requirements-client.txt +0 -0
  30. {prefect-client-2.18.1 → prefect-client-2.18.2}/requirements-dev.txt +0 -0
  31. {prefect-client-2.18.1 → prefect-client-2.18.2}/requirements.txt +0 -0
  32. {prefect-client-2.18.1 → prefect-client-2.18.2}/setup.py +0 -0
  33. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/.prefectignore +0 -0
  34. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/__init__.py +0 -0
  35. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/__init__.py +0 -0
  36. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/_logging.py +0 -0
  37. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/compatibility/__init__.py +0 -0
  38. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/compatibility/deprecated.py +0 -0
  39. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/compatibility/experimental.py +0 -0
  40. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/__init__.py +0 -0
  41. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/api.py +0 -0
  42. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/calls.py +0 -0
  43. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/cancellation.py +0 -0
  44. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/event_loop.py +0 -0
  45. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/inspection.py +0 -0
  46. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/primitives.py +0 -0
  47. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/services.py +0 -0
  48. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/threads.py +0 -0
  49. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/concurrency/waiters.py +0 -0
  50. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/__init__.py +0 -0
  51. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/_base_model.py +0 -0
  52. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/_compat.py +0 -0
  53. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/_flags.py +0 -0
  54. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/_types.py +0 -0
  55. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/annotations/__init__.py +0 -0
  56. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/annotations/pendulum.py +0 -0
  57. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/schemas.py +0 -0
  58. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/__init__.py +0 -0
  59. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/config_dict.py +0 -0
  60. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/field_validator.py +0 -0
  61. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_construct.py +0 -0
  62. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_copy.py +0 -0
  63. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_dump.py +0 -0
  64. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_dump_json.py +0 -0
  65. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_fields.py +0 -0
  66. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_fields_set.py +0 -0
  67. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_json_schema.py +0 -0
  68. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_rebuild.py +0 -0
  69. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_validate.py +0 -0
  70. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_validate_json.py +0 -0
  71. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/model_validator.py +0 -0
  72. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/utilities/type_adapter.py +0 -0
  73. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/v1_schema.py +0 -0
  74. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/v2_schema.py +0 -0
  75. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pydantic/v2_validated_func.py +0 -0
  76. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/pytz.py +0 -0
  77. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/schemas/__init__.py +0 -0
  78. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/schemas/bases.py +0 -0
  79. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/schemas/fields.py +0 -0
  80. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/schemas/serializers.py +0 -0
  81. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_internal/schemas/validators.py +0 -0
  82. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/__init__.py +0 -0
  83. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/__init__.py +0 -0
  84. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/applications.py +0 -0
  85. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/background.py +0 -0
  86. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/concurrency.py +0 -0
  87. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/datastructures.py +0 -0
  88. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/dependencies/__init__.py +0 -0
  89. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/dependencies/models.py +0 -0
  90. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/dependencies/utils.py +0 -0
  91. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/encoders.py +0 -0
  92. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/exception_handlers.py +0 -0
  93. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/exceptions.py +0 -0
  94. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/logger.py +0 -0
  95. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/__init__.py +0 -0
  96. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/asyncexitstack.py +0 -0
  97. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/cors.py +0 -0
  98. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/gzip.py +0 -0
  99. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/httpsredirect.py +0 -0
  100. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/trustedhost.py +0 -0
  101. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/middleware/wsgi.py +0 -0
  102. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/openapi/__init__.py +0 -0
  103. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/openapi/constants.py +0 -0
  104. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/openapi/docs.py +0 -0
  105. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/openapi/models.py +0 -0
  106. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/openapi/utils.py +0 -0
  107. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/param_functions.py +0 -0
  108. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/params.py +0 -0
  109. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/requests.py +0 -0
  110. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/responses.py +0 -0
  111. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/routing.py +0 -0
  112. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/__init__.py +0 -0
  113. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/api_key.py +0 -0
  114. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/base.py +0 -0
  115. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/http.py +0 -0
  116. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/oauth2.py +0 -0
  117. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/open_id_connect_url.py +0 -0
  118. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/security/utils.py +0 -0
  119. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/staticfiles.py +0 -0
  120. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/templating.py +0 -0
  121. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/testclient.py +0 -0
  122. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/types.py +0 -0
  123. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/utils.py +0 -0
  124. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/fastapi/websockets.py +0 -0
  125. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/__init__.py +0 -0
  126. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/_compat.py +0 -0
  127. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/_exception_handler.py +0 -0
  128. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/_utils.py +0 -0
  129. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/applications.py +0 -0
  130. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/authentication.py +0 -0
  131. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/background.py +0 -0
  132. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/concurrency.py +0 -0
  133. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/config.py +0 -0
  134. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/convertors.py +0 -0
  135. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/datastructures.py +0 -0
  136. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/endpoints.py +0 -0
  137. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/exceptions.py +0 -0
  138. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/formparsers.py +0 -0
  139. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/__init__.py +0 -0
  140. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/authentication.py +0 -0
  141. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/base.py +0 -0
  142. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/cors.py +0 -0
  143. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/errors.py +0 -0
  144. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/exceptions.py +0 -0
  145. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/gzip.py +0 -0
  146. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/httpsredirect.py +0 -0
  147. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/sessions.py +0 -0
  148. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/trustedhost.py +0 -0
  149. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/middleware/wsgi.py +0 -0
  150. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/requests.py +0 -0
  151. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/responses.py +0 -0
  152. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/routing.py +0 -0
  153. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/schemas.py +0 -0
  154. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/staticfiles.py +0 -0
  155. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/status.py +0 -0
  156. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/templating.py +0 -0
  157. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/testclient.py +0 -0
  158. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/types.py +0 -0
  159. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_vendor/starlette/websockets.py +0 -0
  160. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/_version.py +0 -0
  161. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/agent.py +0 -0
  162. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/artifacts.py +0 -0
  163. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/__init__.py +0 -0
  164. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/abstract.py +0 -0
  165. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/core.py +0 -0
  166. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/fields.py +0 -0
  167. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/kubernetes.py +0 -0
  168. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/notifications.py +0 -0
  169. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/system.py +0 -0
  170. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/blocks/webhook.py +0 -0
  171. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/__init__.py +0 -0
  172. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/base.py +0 -0
  173. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/cloud.py +0 -0
  174. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/collections.py +0 -0
  175. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/constants.py +0 -0
  176. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/__init__.py +0 -0
  177. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/actions.py +0 -0
  178. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/filters.py +0 -0
  179. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/responses.py +0 -0
  180. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/schedules.py +0 -0
  181. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/schemas/sorting.py +0 -0
  182. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/subscriptions.py +0 -0
  183. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/client/utilities.py +0 -0
  184. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/concurrency/__init__.py +0 -0
  185. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/concurrency/asyncio.py +0 -0
  186. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/concurrency/events.py +0 -0
  187. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/concurrency/services.py +0 -0
  188. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/concurrency/sync.py +0 -0
  189. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/context.py +0 -0
  190. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/__init__.py +0 -0
  191. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/base.py +0 -0
  192. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/deployments.py +0 -0
  193. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/runner.py +0 -0
  194. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/schedules.py +0 -0
  195. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/steps/__init__.py +0 -0
  196. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/steps/core.py +0 -0
  197. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/steps/pull.py +0 -0
  198. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deployments/steps/utility.py +0 -0
  199. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/__init__.py +0 -0
  200. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/data_documents.py +0 -0
  201. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/packaging/__init__.py +0 -0
  202. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/packaging/base.py +0 -0
  203. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/packaging/docker.py +0 -0
  204. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/packaging/file.py +0 -0
  205. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/packaging/orion.py +0 -0
  206. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/deprecated/packaging/serializers.py +0 -0
  207. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/engine.py +0 -0
  208. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/__init__.py +0 -0
  209. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/actions.py +0 -0
  210. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/cli/__init__.py +0 -0
  211. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/instrument.py +0 -0
  212. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/related.py +0 -0
  213. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/schemas/__init__.py +0 -0
  214. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/utilities.py +0 -0
  215. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/events/worker.py +0 -0
  216. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/exceptions.py +0 -0
  217. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/filesystems.py +0 -0
  218. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/flow_runs.py +0 -0
  219. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/futures.py +0 -0
  220. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/__init__.py +0 -0
  221. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/base.py +0 -0
  222. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/container.py +0 -0
  223. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/kubernetes.py +0 -0
  224. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/process.py +0 -0
  225. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/provisioners/__init__.py +0 -0
  226. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/provisioners/cloud_run.py +0 -0
  227. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/provisioners/container_instance.py +0 -0
  228. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/provisioners/ecs.py +0 -0
  229. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/infrastructure/provisioners/modal.py +0 -0
  230. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/input/__init__.py +0 -0
  231. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/input/actions.py +0 -0
  232. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/__init__.py +0 -0
  233. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/configuration.py +0 -0
  234. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/filters.py +0 -0
  235. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/formatters.py +0 -0
  236. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/handlers.py +0 -0
  237. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/highlighters.py +0 -0
  238. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/loggers.py +0 -0
  239. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/logging/logging.yml +0 -0
  240. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/manifests.py +0 -0
  241. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/plugins.py +0 -0
  242. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/profiles.toml +0 -0
  243. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/py.typed +0 -0
  244. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/pydantic/__init__.py +0 -0
  245. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/pydantic/main.py +0 -0
  246. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/results.py +0 -0
  247. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runner/__init__.py +0 -0
  248. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runner/runner.py +0 -0
  249. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runner/server.py +0 -0
  250. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runner/storage.py +0 -0
  251. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runner/submit.py +0 -0
  252. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runner/utils.py +0 -0
  253. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runtime/__init__.py +0 -0
  254. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runtime/deployment.py +0 -0
  255. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runtime/flow_run.py +0 -0
  256. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/runtime/task_run.py +0 -0
  257. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/serializers.py +0 -0
  258. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/server/api/static/prefect-logo-mark-gradient.png +0 -0
  259. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/software/__init__.py +0 -0
  260. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/software/base.py +0 -0
  261. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/software/conda.py +0 -0
  262. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/software/pip.py +0 -0
  263. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/software/python.py +0 -0
  264. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/states.py +0 -0
  265. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/task_engine.py +0 -0
  266. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/task_runners.py +0 -0
  267. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/task_server.py +0 -0
  268. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/types/__init__.py +0 -0
  269. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/__init__.py +0 -0
  270. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/annotations.py +0 -0
  271. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/callables.py +0 -0
  272. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/collections.py +0 -0
  273. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/compat.py +0 -0
  274. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/context.py +0 -0
  275. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/dispatch.py +0 -0
  276. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/dockerutils.py +0 -0
  277. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/engine.py +0 -0
  278. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/filesystem.py +0 -0
  279. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/hashing.py +0 -0
  280. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/importtools.py +0 -0
  281. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/math.py +0 -0
  282. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/names.py +0 -0
  283. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/processutils.py +0 -0
  284. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/pydantic.py +0 -0
  285. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/render_swagger.py +0 -0
  286. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/schema_tools/__init__.py +0 -0
  287. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/schema_tools/hydration.py +0 -0
  288. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/schema_tools/validation.py +0 -0
  289. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/services.py +0 -0
  290. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/slugify.py +0 -0
  291. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/templating.py +0 -0
  292. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/text.py +0 -0
  293. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/utilities/visualization.py +0 -0
  294. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/variables.py +0 -0
  295. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/workers/__init__.py +0 -0
  296. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/workers/base.py +0 -0
  297. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/workers/block.py +0 -0
  298. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/workers/server.py +0 -0
  299. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect/workers/utilities.py +0 -0
  300. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect_client.egg-info/dependency_links.txt +0 -0
  301. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect_client.egg-info/requires.txt +0 -0
  302. {prefect-client-2.18.1 → prefect-client-2.18.2}/src/prefect_client.egg-info/top_level.txt +0 -0
  303. {prefect-client-2.18.1 → prefect-client-2.18.2}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.18.1
3
+ Version: 2.18.2
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
@@ -56,10 +56,8 @@ filterwarnings =
56
56
  [mypy]
57
57
  plugins =
58
58
  pydantic.mypy
59
- files =
60
- src/prefect/concurrency/,
61
- src/prefect/events/,
62
- src/prefect/input/
59
+ ignore_missing_imports = True
60
+ follow_imports = skip
63
61
 
64
62
  [mypy-ruamel]
65
63
  ignore_missing_imports = True
@@ -0,0 +1,162 @@
1
+ from typing import Optional
2
+ from uuid import UUID
3
+
4
+ from pydantic import Field
5
+ from typing_extensions import Self
6
+
7
+ from prefect.client.utilities import get_or_create_client
8
+ from prefect.events.schemas.automations import (
9
+ AutomationCore,
10
+ CompositeTrigger,
11
+ CompoundTrigger,
12
+ EventTrigger,
13
+ MetricTrigger,
14
+ MetricTriggerOperator,
15
+ MetricTriggerQuery,
16
+ Posture,
17
+ PrefectMetric,
18
+ ResourceSpecification,
19
+ ResourceTrigger,
20
+ SequenceTrigger,
21
+ Trigger,
22
+ )
23
+ from prefect.exceptions import PrefectHTTPStatusError
24
+ from prefect.utilities.asyncutils import sync_compatible
25
+
26
+ __all__ = [
27
+ "AutomationCore",
28
+ "EventTrigger",
29
+ "ResourceTrigger",
30
+ "Posture",
31
+ "Trigger",
32
+ "ResourceSpecification",
33
+ "MetricTriggerOperator",
34
+ "MetricTrigger",
35
+ "PrefectMetric",
36
+ "CompositeTrigger",
37
+ "SequenceTrigger",
38
+ "CompoundTrigger",
39
+ "MetricTriggerQuery",
40
+ ]
41
+
42
+
43
+ class Automation(AutomationCore):
44
+ id: Optional[UUID] = Field(default=None, description="The ID of this automation")
45
+
46
+ @sync_compatible
47
+ async def create(self: Self) -> Self:
48
+ """
49
+ Create a new automation.
50
+
51
+ auto_to_create = Automation(
52
+ name="woodchonk",
53
+ trigger=EventTrigger(
54
+ expect={"animal.walked"},
55
+ match={
56
+ "genus": "Marmota",
57
+ "species": "monax",
58
+ },
59
+ posture="Reactive",
60
+ threshold=3,
61
+ within=timedelta(seconds=10),
62
+ ),
63
+ actions=[CancelFlowRun()]
64
+ )
65
+ created_automation = auto_to_create.create()
66
+ """
67
+ client, _ = get_or_create_client()
68
+ automation = AutomationCore(**self.dict(exclude={"id"}))
69
+ self.id = await client.create_automation(automation=automation)
70
+ return self
71
+
72
+ @sync_compatible
73
+ async def update(self: Self):
74
+ """
75
+ Updates an existing automation.
76
+ auto = Automation.read(id=123)
77
+ auto.name = "new name"
78
+ auto.update()
79
+ """
80
+
81
+ client, _ = get_or_create_client()
82
+ automation = AutomationCore(**self.dict(exclude={"id", "owner_resource"}))
83
+ await client.update_automation(automation_id=self.id, automation=automation)
84
+
85
+ @classmethod
86
+ @sync_compatible
87
+ async def read(
88
+ cls: Self, id: Optional[UUID] = None, name: Optional[str] = None
89
+ ) -> Self:
90
+ """
91
+ Read an automation by ID or name.
92
+ automation = Automation.read(name="woodchonk")
93
+
94
+ or
95
+
96
+ automation = Automation.read(id=UUID("b3514963-02b1-47a5-93d1-6eeb131041cb"))
97
+ """
98
+ if id and name:
99
+ raise ValueError("Only one of id or name can be provided")
100
+ if not id and not name:
101
+ raise ValueError("One of id or name must be provided")
102
+ client, _ = get_or_create_client()
103
+ if id:
104
+ try:
105
+ automation = await client.read_automation(automation_id=id)
106
+ except PrefectHTTPStatusError as exc:
107
+ if exc.response.status_code == 404:
108
+ raise ValueError(f"Automation with ID {id!r} not found")
109
+ return Automation(**automation.dict())
110
+ else:
111
+ automation = await client.read_automations_by_name(name=name)
112
+ if len(automation) > 0:
113
+ return Automation(**automation[0].dict()) if automation else None
114
+ else:
115
+ raise ValueError(f"Automation with name {name!r} not found")
116
+
117
+ @sync_compatible
118
+ async def delete(self: Self) -> bool:
119
+ """
120
+ auto = Automation.read(id = 123)
121
+ auto.delete()
122
+ """
123
+ try:
124
+ client, _ = get_or_create_client()
125
+ await client.delete_automation(self.id)
126
+ return True
127
+ except PrefectHTTPStatusError as exc:
128
+ if exc.response.status_code == 404:
129
+ return False
130
+ raise
131
+
132
+ @sync_compatible
133
+ async def disable(self: Self) -> bool:
134
+ """
135
+ Disable an automation.
136
+ auto = Automation.read(id = 123)
137
+ auto.disable()
138
+ """
139
+ try:
140
+ client, _ = get_or_create_client()
141
+ await client.pause_automation(self.id)
142
+ return True
143
+ except PrefectHTTPStatusError as exc:
144
+ if exc.response.status_code == 404:
145
+ return False
146
+ raise
147
+
148
+ @sync_compatible
149
+ async def enable(self: Self) -> bool:
150
+ """
151
+ Enable an automation.
152
+ auto = Automation.read(id = 123)
153
+ auto.enable()
154
+ """
155
+ try:
156
+ client, _ = get_or_create_client()
157
+ await client.resume_automation("asd")
158
+ return True
159
+ except PrefectHTTPStatusError as exc:
160
+ if exc.response.status_code == 404:
161
+ return False
162
+ raise
@@ -623,12 +623,12 @@ class PrefectClient:
623
623
  async def create_flow_run(
624
624
  self,
625
625
  flow: "FlowObject",
626
- name: str = None,
626
+ name: Optional[str] = None,
627
627
  parameters: Optional[Dict[str, Any]] = None,
628
628
  context: Optional[Dict[str, Any]] = None,
629
- tags: Iterable[str] = None,
630
- parent_task_run_id: UUID = None,
631
- state: "prefect.states.State" = None,
629
+ tags: Optional[Iterable[str]] = None,
630
+ parent_task_run_id: Optional[UUID] = None,
631
+ state: Optional["prefect.states.State"] = None,
632
632
  ) -> FlowRun:
633
633
  """
634
634
  Create a flow run for a flow.
@@ -3161,6 +3161,16 @@ class PrefectClient:
3161
3161
 
3162
3162
  return UUID(response.json()["id"])
3163
3163
 
3164
+ async def update_automation(self, automation_id: UUID, automation: AutomationCore):
3165
+ """Updates an automation in Prefect Cloud."""
3166
+ if not self.server_type.supports_automations():
3167
+ self._raise_for_unsupported_automations()
3168
+ response = await self._client.put(
3169
+ f"/automations/{automation_id}",
3170
+ json=automation.dict(json_compatible=True, exclude_unset=True),
3171
+ )
3172
+ response.raise_for_status
3173
+
3164
3174
  async def read_automations(self) -> List[Automation]:
3165
3175
  if not self.server_type.supports_automations():
3166
3176
  self._raise_for_unsupported_automations()
@@ -3169,16 +3179,24 @@ class PrefectClient:
3169
3179
  response.raise_for_status()
3170
3180
  return pydantic.parse_obj_as(List[Automation], response.json())
3171
3181
 
3172
- async def find_automation(self, id_or_name: str) -> Optional[Automation]:
3173
- try:
3174
- id = UUID(id_or_name)
3175
- except ValueError:
3176
- id = None
3182
+ async def find_automation(
3183
+ self, id_or_name: Union[str, UUID], exit_if_not_found: bool = True
3184
+ ) -> Optional[Automation]:
3185
+ if isinstance(id_or_name, str):
3186
+ try:
3187
+ id = UUID(id_or_name)
3188
+ except ValueError:
3189
+ id = None
3190
+ elif isinstance(id_or_name, UUID):
3191
+ id = id_or_name
3177
3192
 
3178
3193
  if id:
3179
- automation = await self.read_automation(id)
3180
- if automation:
3194
+ try:
3195
+ automation = await self.read_automation(id)
3181
3196
  return automation
3197
+ except prefect.exceptions.HTTPStatusError as e:
3198
+ if e.response.status_code == status.HTTP_404_NOT_FOUND:
3199
+ raise prefect.exceptions.ObjectNotFound(http_exc=e) from e
3182
3200
 
3183
3201
  automations = await self.read_automations()
3184
3202
 
@@ -53,6 +53,7 @@ if TYPE_CHECKING:
53
53
  from prefect.deprecated.data_documents import DataDocument
54
54
  from prefect.results import BaseResult
55
55
 
56
+
56
57
  R = TypeVar("R")
57
58
 
58
59
 
@@ -120,20 +121,20 @@ class WorkQueueStatus(AutoEnum):
120
121
 
121
122
 
122
123
  class StateDetails(PrefectBaseModel):
123
- flow_run_id: UUID = None
124
- task_run_id: UUID = None
124
+ flow_run_id: Optional[UUID] = None
125
+ task_run_id: Optional[UUID] = None
125
126
  # for task runs that represent subflows, the subflow's run ID
126
- child_flow_run_id: UUID = None
127
+ child_flow_run_id: Optional[UUID] = None
127
128
  scheduled_time: DateTimeTZ = None
128
- cache_key: str = None
129
+ cache_key: Optional[str] = None
129
130
  cache_expiration: DateTimeTZ = None
130
131
  untrackable_result: bool = False
131
132
  pause_timeout: DateTimeTZ = None
132
133
  pause_reschedule: bool = False
133
- pause_key: str = None
134
+ pause_key: Optional[str] = None
134
135
  run_input_keyset: Optional[Dict[str, str]] = None
135
- refresh_cache: bool = None
136
- retriable: bool = None
136
+ refresh_cache: Optional[bool] = None
137
+ retriable: Optional[bool] = None
137
138
  transition_id: Optional[UUID] = None
138
139
  task_parameters_id: Optional[UUID] = None
139
140
 
@@ -160,7 +161,9 @@ class State(ObjectBaseModel, Generic[R]):
160
161
  def result(self: "State[R]", raise_on_failure: bool = False) -> Union[R, Exception]:
161
162
  ...
162
163
 
163
- def result(self, raise_on_failure: bool = True, fetch: Optional[bool] = None):
164
+ def result(
165
+ self, raise_on_failure: bool = True, fetch: Optional[bool] = None
166
+ ) -> Union[R, Exception]:
164
167
  """
165
168
  Retrieve the result attached to this state.
166
169
 
@@ -0,0 +1,324 @@
1
+ """
2
+ Command line interface for working with automations.
3
+ """
4
+
5
+ import functools
6
+ from typing import Optional
7
+ from uuid import UUID
8
+
9
+ import orjson
10
+ import typer
11
+ import yaml as pyyaml
12
+ from rich.pretty import Pretty
13
+ from rich.table import Table
14
+ from rich.text import Text
15
+
16
+ from prefect.cli._types import PrefectTyper
17
+ from prefect.cli._utilities import exit_with_error, exit_with_success
18
+ from prefect.cli.root import app
19
+ from prefect.client.orchestration import get_client
20
+ from prefect.events.schemas.automations import Automation
21
+ from prefect.exceptions import PrefectHTTPStatusError
22
+
23
+ automations_app = PrefectTyper(
24
+ name="automation",
25
+ help="Commands for managing automations.",
26
+ )
27
+ app.add_typer(automations_app, aliases=["automations"])
28
+
29
+
30
+ def requires_automations(func):
31
+ @functools.wraps(func)
32
+ async def wrapper(*args, **kwargs):
33
+ try:
34
+ return await func(*args, **kwargs)
35
+ except RuntimeError as exc:
36
+ if "Enable experimental" in str(exc):
37
+ exit_with_error(str(exc))
38
+ raise
39
+
40
+ return wrapper
41
+
42
+
43
+ @automations_app.command()
44
+ @requires_automations
45
+ async def ls():
46
+ """List all automations."""
47
+ async with get_client() as client:
48
+ automations = await client.read_automations()
49
+
50
+ table = Table(title="Automations", show_lines=True)
51
+
52
+ table.add_column("Automation")
53
+ table.add_column("Enabled")
54
+ table.add_column("Trigger")
55
+ table.add_column("Actions")
56
+
57
+ for automation in automations:
58
+ identifier_column = Text()
59
+
60
+ identifier_column.append(automation.name, style="white bold")
61
+ identifier_column.append("\n")
62
+
63
+ identifier_column.append(str(automation.id), style="cyan")
64
+ identifier_column.append("\n")
65
+
66
+ if automation.description:
67
+ identifier_column.append(automation.description, style="white")
68
+ identifier_column.append("\n")
69
+
70
+ if automation.actions_on_trigger or automation.actions_on_resolve:
71
+ actions = (
72
+ [
73
+ f"(trigger) {action.describe_for_cli()}"
74
+ for action in automation.actions
75
+ ]
76
+ + [
77
+ f"(trigger) {action.describe_for_cli()}"
78
+ for action in automation.actions_on_trigger
79
+ ]
80
+ + [
81
+ f"(resolve) {action.describe_for_cli()}"
82
+ for action in automation.actions
83
+ ]
84
+ + [
85
+ f"(resolve) {action.describe_for_cli()}"
86
+ for action in automation.actions_on_resolve
87
+ ]
88
+ )
89
+ else:
90
+ actions = [action.describe_for_cli() for action in automation.actions]
91
+
92
+ table.add_row(
93
+ identifier_column,
94
+ str(automation.enabled),
95
+ automation.trigger.describe_for_cli(),
96
+ "\n".join(actions),
97
+ )
98
+
99
+ app.console.print(table)
100
+
101
+
102
+ @automations_app.command()
103
+ @requires_automations
104
+ async def inspect(
105
+ name: Optional[str] = typer.Argument(None, help="An automation's name"),
106
+ id: Optional[str] = typer.Option(None, "--id", help="An automation's id"),
107
+ yaml: bool = typer.Option(False, "--yaml", help="Output as YAML"),
108
+ json: bool = typer.Option(False, "--json", help="Output as JSON"),
109
+ ):
110
+ """
111
+ Inspect an automation.
112
+
113
+ Arguments:
114
+
115
+ name: the name of the automation to inspect
116
+
117
+ id: the id of the automation to inspect
118
+
119
+ yaml: output as YAML
120
+
121
+ json: output as JSON
122
+
123
+ Examples:
124
+
125
+ $ prefect automation inspect "my-automation"
126
+
127
+ $ prefect automation inspect --id "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
128
+
129
+ $ prefect automation inspect "my-automation" --yaml
130
+
131
+ $ prefect automation inspect "my-automation" --json
132
+ """
133
+ if not id and not name:
134
+ exit_with_error("Please provide either a name or an id.")
135
+
136
+ if name:
137
+ async with get_client() as client:
138
+ automation = await client.read_automations_by_name(name=name)
139
+ if not automation:
140
+ exit_with_error(f"Automation {name!r} not found.")
141
+
142
+ elif id:
143
+ async with get_client() as client:
144
+ try:
145
+ uuid_id = UUID(id)
146
+ automation = await client.read_automation(uuid_id)
147
+ except (PrefectHTTPStatusError, ValueError):
148
+ exit_with_error(f"Automation with id {id!r} not found.")
149
+
150
+ if yaml or json:
151
+ if isinstance(automation, list):
152
+ automation = [a.dict(json_compatible=True) for a in automation]
153
+ elif isinstance(automation, Automation):
154
+ automation = automation.dict(json_compatible=True)
155
+ if yaml:
156
+ app.console.print(pyyaml.dump(automation, sort_keys=False))
157
+ elif json:
158
+ app.console.print(
159
+ orjson.dumps(automation, option=orjson.OPT_INDENT_2).decode()
160
+ )
161
+ else:
162
+ app.console.print(Pretty(automation))
163
+
164
+
165
+ @automations_app.command(aliases=["enable"])
166
+ @requires_automations
167
+ async def resume(
168
+ name: Optional[str] = typer.Argument(None, help="An automation's name"),
169
+ id: Optional[str] = typer.Option(None, "--id", help="An automation's id"),
170
+ ):
171
+ """
172
+ Resume an automation.
173
+
174
+ Arguments:
175
+
176
+ name: the name of the automation to resume
177
+
178
+ id: the id of the automation to resume
179
+
180
+ Examples:
181
+
182
+ $ prefect automation resume "my-automation"
183
+
184
+ $ prefect automation resume --id "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
185
+ """
186
+ if not id and not name:
187
+ exit_with_error("Please provide either a name or an id.")
188
+
189
+ if name:
190
+ async with get_client() as client:
191
+ automation = await client.read_automations_by_name(name=name)
192
+ if not automation:
193
+ exit_with_error(
194
+ f"Automation with name {name!r} not found. You can also specify an id with the `--id` flag."
195
+ )
196
+ if len(automation) > 1:
197
+ if not typer.confirm(
198
+ f"Multiple automations found with name {name!r}. Do you want to resume all of them?",
199
+ default=False,
200
+ ):
201
+ exit_with_error("Resume aborted.")
202
+
203
+ for a in automation:
204
+ await client.resume_automation(a.id)
205
+ exit_with_success(
206
+ f"Resumed automation(s) with name {name!r} and id(s) {', '.join([repr(str(a.id)) for a in automation])}."
207
+ )
208
+
209
+ elif id:
210
+ async with get_client() as client:
211
+ try:
212
+ uuid_id = UUID(id)
213
+ automation = await client.read_automation(uuid_id)
214
+ except (PrefectHTTPStatusError, ValueError):
215
+ exit_with_error(f"Automation with id {id!r} not found.")
216
+ await client.resume_automation(automation.id)
217
+ exit_with_success(f"Resumed automation with id {str(automation.id)!r}.")
218
+
219
+
220
+ @automations_app.command(aliases=["disable"])
221
+ @requires_automations
222
+ async def pause(
223
+ name: Optional[str] = typer.Argument(None, help="An automation's name"),
224
+ id: Optional[str] = typer.Option(None, "--id", help="An automation's id"),
225
+ ):
226
+ """
227
+ Pause an automation.
228
+
229
+ Arguments:
230
+
231
+ name: the name of the automation to pause
232
+
233
+ id: the id of the automation to pause
234
+
235
+ Examples:
236
+
237
+ $ prefect automation pause "my-automation"
238
+
239
+ $ prefect automation pause --id "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
240
+ """
241
+ if not id and not name:
242
+ exit_with_error("Please provide either a name or an id.")
243
+
244
+ if name:
245
+ async with get_client() as client:
246
+ automation = await client.read_automations_by_name(name=name)
247
+ if not automation:
248
+ exit_with_error(
249
+ f"Automation with name {name!r} not found. You can also specify an id with the `--id` flag."
250
+ )
251
+ if len(automation) > 1:
252
+ if not typer.confirm(
253
+ f"Multiple automations found with name {name!r}. Do you want to pause all of them?",
254
+ default=False,
255
+ ):
256
+ exit_with_error("Pause aborted.")
257
+
258
+ for a in automation:
259
+ await client.pause_automation(a.id)
260
+ exit_with_success(
261
+ f"Paused automation(s) with name {name!r} and id(s) {', '.join([repr(str(a.id)) for a in automation])}."
262
+ )
263
+
264
+ elif id:
265
+ async with get_client() as client:
266
+ try:
267
+ uuid_id = UUID(id)
268
+ automation = await client.read_automation(uuid_id)
269
+ except (PrefectHTTPStatusError, ValueError):
270
+ exit_with_error(f"Automation with id {id!r} not found.")
271
+ await client.pause_automation(automation.id)
272
+ exit_with_success(f"Paused automation with id {str(automation.id)!r}.")
273
+
274
+
275
+ @automations_app.command()
276
+ @requires_automations
277
+ async def delete(
278
+ name: Optional[str] = typer.Argument(None, help="An automation's name"),
279
+ id: Optional[str] = typer.Option(None, "--id", help="An automation's id"),
280
+ ):
281
+ """Delete an automation.
282
+
283
+ Arguments:
284
+ name: the name of the automation to delete
285
+ id: the id of the automation to delete
286
+
287
+ Examples:
288
+ $ prefect automation delete "my-automation"
289
+ $ prefect automation delete --id "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
290
+ """
291
+
292
+ async with get_client() as client:
293
+ if not id and not name:
294
+ exit_with_error("Please provide either a name or an id.")
295
+
296
+ if id:
297
+ automation = await client.read_automation(id)
298
+ if not automation:
299
+ exit_with_error(f"Automation with id {id!r} not found.")
300
+ if not typer.confirm(
301
+ (f"Are you sure you want to delete automation with id {id!r}?"),
302
+ default=False,
303
+ ):
304
+ exit_with_error("Deletion aborted.")
305
+ await client.delete_automation(id)
306
+ exit_with_success(f"Deleted automation with id {id!r}")
307
+
308
+ elif name:
309
+ automation = await client.read_automations_by_name(name=name)
310
+ if not automation:
311
+ exit_with_error(
312
+ f"Automation {name!r} not found. You can also specify an id with the `--id` flag."
313
+ )
314
+ elif len(automation) > 1:
315
+ exit_with_error(
316
+ f"Multiple automations found with name {name!r}. Please specify an id with the `--id` flag instead."
317
+ )
318
+ if not typer.confirm(
319
+ (f"Are you sure you want to delete automation with name {name!r}?"),
320
+ default=False,
321
+ ):
322
+ exit_with_error("Deletion aborted.")
323
+ await client.delete_automation(automation[0].id)
324
+ exit_with_success(f"Deleted automation with name {name!r}")
@@ -11,6 +11,7 @@ from typing import (
11
11
  Optional,
12
12
  Tuple,
13
13
  Type,
14
+ cast,
14
15
  )
15
16
  from uuid import UUID
16
17
 
@@ -377,7 +378,7 @@ SEEN_EVENTS_TTL = 120
377
378
 
378
379
  class PrefectEventSubscriber:
379
380
  """
380
- Subscribes to a Prefect Cloud event stream, yielding events as they occur.
381
+ Subscribes to a Prefect event stream, yielding events as they occur.
381
382
 
382
383
  Example:
383
384
 
@@ -412,7 +413,7 @@ class PrefectEventSubscriber:
412
413
  the client should attempt to reconnect
413
414
  """
414
415
  if not api_url:
415
- api_url = PREFECT_API_URL.value()
416
+ api_url = cast(str, PREFECT_API_URL.value())
416
417
  self._api_key = None
417
418
 
418
419
  from prefect.events.filters import EventFilter
@@ -43,7 +43,7 @@ class AutomationFilter(PrefectBaseModel):
43
43
  )
44
44
 
45
45
 
46
- class EventDataFilter(PrefectBaseModel, extra="forbid"):
46
+ class EventDataFilter(PrefectBaseModel, extra="forbid"): # type: ignore[call-arg]
47
47
  """A base class for filtering event data."""
48
48
 
49
49
  _top_level_filter: "EventFilter | None" = PrivateAttr(None)
@@ -39,7 +39,7 @@ class Posture(AutoEnum):
39
39
  Metric = "Metric"
40
40
 
41
41
 
42
- class Trigger(PrefectBaseModel, abc.ABC, extra="ignore"):
42
+ class Trigger(PrefectBaseModel, abc.ABC, extra="ignore"): # type: ignore[call-arg]
43
43
  """
44
44
  Base class describing a set of criteria that must be satisfied in order to trigger
45
45
  an automation.
@@ -391,7 +391,7 @@ CompoundTrigger.update_forward_refs()
391
391
  SequenceTrigger.update_forward_refs()
392
392
 
393
393
 
394
- class AutomationCore(PrefectBaseModel, extra="ignore"):
394
+ class AutomationCore(PrefectBaseModel, extra="ignore"): # type: ignore[call-arg]
395
395
  """Defines an action a user wants to take when a certain number of events
396
396
  do or don't happen to the matching resources"""
397
397
 
@@ -48,7 +48,7 @@ from .automations import (
48
48
  from .events import ResourceSpecification
49
49
 
50
50
 
51
- class BaseDeploymentTrigger(PrefectBaseModel, abc.ABC, extra="ignore"):
51
+ class BaseDeploymentTrigger(PrefectBaseModel, abc.ABC, extra="ignore"): # type: ignore[call-arg]
52
52
  """
53
53
  Base class describing a set of criteria that must be satisfied in order to trigger
54
54
  an automation.