prefect-client 2.19.2__tar.gz → 2.19.4__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 (302) hide show
  1. {prefect-client-2.19.2/src/prefect_client.egg-info → prefect-client-2.19.4}/PKG-INFO +1 -1
  2. {prefect-client-2.19.2 → prefect-client-2.19.4}/setup.cfg +0 -1
  3. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/objects.py +4 -0
  4. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/base.py +7 -1
  5. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/flows.py +66 -1
  6. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runner/runner.py +12 -8
  7. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/callables.py +261 -2
  8. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/importtools.py +71 -0
  9. {prefect-client-2.19.2 → prefect-client-2.19.4/src/prefect_client.egg-info}/PKG-INFO +1 -1
  10. {prefect-client-2.19.2 → prefect-client-2.19.4}/LICENSE +0 -0
  11. {prefect-client-2.19.2 → prefect-client-2.19.4}/MANIFEST.in +0 -0
  12. {prefect-client-2.19.2 → prefect-client-2.19.4}/README.md +0 -0
  13. {prefect-client-2.19.2 → prefect-client-2.19.4}/requirements-client.txt +0 -0
  14. {prefect-client-2.19.2 → prefect-client-2.19.4}/requirements-dev.txt +0 -0
  15. {prefect-client-2.19.2 → prefect-client-2.19.4}/requirements.txt +0 -0
  16. {prefect-client-2.19.2 → prefect-client-2.19.4}/setup.py +0 -0
  17. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/.prefectignore +0 -0
  18. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/__init__.py +0 -0
  19. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/__init__.py +0 -0
  20. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/_logging.py +0 -0
  21. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/compatibility/__init__.py +0 -0
  22. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/compatibility/deprecated.py +0 -0
  23. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/compatibility/experimental.py +0 -0
  24. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/__init__.py +0 -0
  25. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/api.py +0 -0
  26. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/calls.py +0 -0
  27. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/cancellation.py +0 -0
  28. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/event_loop.py +0 -0
  29. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/inspection.py +0 -0
  30. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/primitives.py +0 -0
  31. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/services.py +0 -0
  32. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/threads.py +0 -0
  33. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/concurrency/waiters.py +0 -0
  34. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/__init__.py +0 -0
  35. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/_base_model.py +0 -0
  36. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/_compat.py +0 -0
  37. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/_flags.py +0 -0
  38. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/_types.py +0 -0
  39. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/annotations/__init__.py +0 -0
  40. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/annotations/pendulum.py +0 -0
  41. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/schemas.py +0 -0
  42. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/__init__.py +0 -0
  43. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/config_dict.py +0 -0
  44. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/field_validator.py +0 -0
  45. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_construct.py +0 -0
  46. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_copy.py +0 -0
  47. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_dump.py +0 -0
  48. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_dump_json.py +0 -0
  49. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_fields.py +0 -0
  50. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_fields_set.py +0 -0
  51. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_json_schema.py +0 -0
  52. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_rebuild.py +0 -0
  53. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_validate.py +0 -0
  54. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_validate_json.py +0 -0
  55. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/model_validator.py +0 -0
  56. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/utilities/type_adapter.py +0 -0
  57. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/v1_schema.py +0 -0
  58. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/v2_schema.py +0 -0
  59. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pydantic/v2_validated_func.py +0 -0
  60. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/pytz.py +0 -0
  61. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/schemas/__init__.py +0 -0
  62. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/schemas/bases.py +0 -0
  63. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/schemas/fields.py +0 -0
  64. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/schemas/serializers.py +0 -0
  65. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_internal/schemas/validators.py +0 -0
  66. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/__init__.py +0 -0
  67. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/__init__.py +0 -0
  68. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/applications.py +0 -0
  69. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/background.py +0 -0
  70. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/concurrency.py +0 -0
  71. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/datastructures.py +0 -0
  72. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/dependencies/__init__.py +0 -0
  73. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/dependencies/models.py +0 -0
  74. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/dependencies/utils.py +0 -0
  75. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/encoders.py +0 -0
  76. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/exception_handlers.py +0 -0
  77. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/exceptions.py +0 -0
  78. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/logger.py +0 -0
  79. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/__init__.py +0 -0
  80. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/asyncexitstack.py +0 -0
  81. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/cors.py +0 -0
  82. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/gzip.py +0 -0
  83. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/httpsredirect.py +0 -0
  84. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/trustedhost.py +0 -0
  85. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/middleware/wsgi.py +0 -0
  86. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/openapi/__init__.py +0 -0
  87. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/openapi/constants.py +0 -0
  88. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/openapi/docs.py +0 -0
  89. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/openapi/models.py +0 -0
  90. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/openapi/utils.py +0 -0
  91. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/param_functions.py +0 -0
  92. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/params.py +0 -0
  93. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/requests.py +0 -0
  94. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/responses.py +0 -0
  95. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/routing.py +0 -0
  96. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/__init__.py +0 -0
  97. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/api_key.py +0 -0
  98. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/base.py +0 -0
  99. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/http.py +0 -0
  100. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/oauth2.py +0 -0
  101. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/open_id_connect_url.py +0 -0
  102. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/security/utils.py +0 -0
  103. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/staticfiles.py +0 -0
  104. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/templating.py +0 -0
  105. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/testclient.py +0 -0
  106. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/types.py +0 -0
  107. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/utils.py +0 -0
  108. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/fastapi/websockets.py +0 -0
  109. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/__init__.py +0 -0
  110. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/_compat.py +0 -0
  111. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/_exception_handler.py +0 -0
  112. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/_utils.py +0 -0
  113. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/applications.py +0 -0
  114. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/authentication.py +0 -0
  115. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/background.py +0 -0
  116. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/concurrency.py +0 -0
  117. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/config.py +0 -0
  118. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/convertors.py +0 -0
  119. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/datastructures.py +0 -0
  120. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/endpoints.py +0 -0
  121. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/exceptions.py +0 -0
  122. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/formparsers.py +0 -0
  123. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/__init__.py +0 -0
  124. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/authentication.py +0 -0
  125. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/base.py +0 -0
  126. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/cors.py +0 -0
  127. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/errors.py +0 -0
  128. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/exceptions.py +0 -0
  129. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/gzip.py +0 -0
  130. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/httpsredirect.py +0 -0
  131. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/sessions.py +0 -0
  132. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/trustedhost.py +0 -0
  133. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/middleware/wsgi.py +0 -0
  134. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/requests.py +0 -0
  135. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/responses.py +0 -0
  136. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/routing.py +0 -0
  137. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/schemas.py +0 -0
  138. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/staticfiles.py +0 -0
  139. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/status.py +0 -0
  140. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/templating.py +0 -0
  141. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/testclient.py +0 -0
  142. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/types.py +0 -0
  143. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_vendor/starlette/websockets.py +0 -0
  144. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/_version.py +0 -0
  145. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/agent.py +0 -0
  146. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/artifacts.py +0 -0
  147. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/automations.py +0 -0
  148. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/__init__.py +0 -0
  149. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/abstract.py +0 -0
  150. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/core.py +0 -0
  151. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/fields.py +0 -0
  152. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/kubernetes.py +0 -0
  153. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/notifications.py +0 -0
  154. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/system.py +0 -0
  155. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/blocks/webhook.py +0 -0
  156. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/__init__.py +0 -0
  157. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/base.py +0 -0
  158. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/cloud.py +0 -0
  159. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/collections.py +0 -0
  160. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/constants.py +0 -0
  161. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/orchestration.py +0 -0
  162. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/__init__.py +0 -0
  163. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/actions.py +0 -0
  164. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/filters.py +0 -0
  165. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/responses.py +0 -0
  166. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/schedules.py +0 -0
  167. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/schemas/sorting.py +0 -0
  168. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/subscriptions.py +0 -0
  169. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/client/utilities.py +0 -0
  170. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/concurrency/__init__.py +0 -0
  171. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/concurrency/asyncio.py +0 -0
  172. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/concurrency/events.py +0 -0
  173. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/concurrency/services.py +0 -0
  174. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/concurrency/sync.py +0 -0
  175. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/context.py +0 -0
  176. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/__init__.py +0 -0
  177. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/deployments.py +0 -0
  178. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/runner.py +0 -0
  179. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/schedules.py +0 -0
  180. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/steps/__init__.py +0 -0
  181. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/steps/core.py +0 -0
  182. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/steps/pull.py +0 -0
  183. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deployments/steps/utility.py +0 -0
  184. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/__init__.py +0 -0
  185. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/data_documents.py +0 -0
  186. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/packaging/__init__.py +0 -0
  187. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/packaging/base.py +0 -0
  188. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/packaging/docker.py +0 -0
  189. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/packaging/file.py +0 -0
  190. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/packaging/orion.py +0 -0
  191. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/deprecated/packaging/serializers.py +0 -0
  192. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/engine.py +0 -0
  193. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/__init__.py +0 -0
  194. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/actions.py +0 -0
  195. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/cli/__init__.py +0 -0
  196. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/cli/automations.py +0 -0
  197. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/clients.py +0 -0
  198. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/filters.py +0 -0
  199. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/instrument.py +0 -0
  200. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/related.py +0 -0
  201. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/schemas/__init__.py +0 -0
  202. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/schemas/automations.py +0 -0
  203. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/schemas/deployment_triggers.py +0 -0
  204. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/schemas/events.py +0 -0
  205. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/schemas/labelling.py +0 -0
  206. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/utilities.py +0 -0
  207. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/events/worker.py +0 -0
  208. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/exceptions.py +0 -0
  209. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/filesystems.py +0 -0
  210. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/flow_runs.py +0 -0
  211. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/futures.py +0 -0
  212. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/__init__.py +0 -0
  213. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/base.py +0 -0
  214. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/container.py +0 -0
  215. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/kubernetes.py +0 -0
  216. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/process.py +0 -0
  217. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/provisioners/__init__.py +0 -0
  218. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/provisioners/cloud_run.py +0 -0
  219. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/provisioners/container_instance.py +0 -0
  220. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/provisioners/ecs.py +0 -0
  221. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/infrastructure/provisioners/modal.py +0 -0
  222. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/input/__init__.py +0 -0
  223. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/input/actions.py +0 -0
  224. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/input/run_input.py +0 -0
  225. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/__init__.py +0 -0
  226. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/configuration.py +0 -0
  227. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/filters.py +0 -0
  228. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/formatters.py +0 -0
  229. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/handlers.py +0 -0
  230. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/highlighters.py +0 -0
  231. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/loggers.py +0 -0
  232. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/logging/logging.yml +0 -0
  233. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/manifests.py +0 -0
  234. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/new_flow_engine.py +0 -0
  235. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/new_task_engine.py +0 -0
  236. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/plugins.py +0 -0
  237. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/profiles.toml +0 -0
  238. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/py.typed +0 -0
  239. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/pydantic/__init__.py +0 -0
  240. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/pydantic/main.py +0 -0
  241. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/results.py +0 -0
  242. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runner/__init__.py +0 -0
  243. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runner/server.py +0 -0
  244. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runner/storage.py +0 -0
  245. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runner/submit.py +0 -0
  246. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runner/utils.py +0 -0
  247. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runtime/__init__.py +0 -0
  248. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runtime/deployment.py +0 -0
  249. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runtime/flow_run.py +0 -0
  250. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/runtime/task_run.py +0 -0
  251. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/serializers.py +0 -0
  252. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/server/api/collections_data/views/aggregate-worker-metadata.json +0 -0
  253. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/server/api/static/prefect-logo-mark-gradient.png +0 -0
  254. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/settings.py +0 -0
  255. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/software/__init__.py +0 -0
  256. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/software/base.py +0 -0
  257. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/software/conda.py +0 -0
  258. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/software/pip.py +0 -0
  259. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/software/python.py +0 -0
  260. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/states.py +0 -0
  261. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/task_engine.py +0 -0
  262. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/task_runners.py +0 -0
  263. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/task_server.py +0 -0
  264. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/tasks.py +0 -0
  265. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/types/__init__.py +0 -0
  266. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/__init__.py +0 -0
  267. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/annotations.py +0 -0
  268. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/asyncutils.py +0 -0
  269. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/collections.py +0 -0
  270. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/compat.py +0 -0
  271. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/context.py +0 -0
  272. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/dispatch.py +0 -0
  273. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/dockerutils.py +0 -0
  274. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/engine.py +0 -0
  275. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/filesystem.py +0 -0
  276. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/hashing.py +0 -0
  277. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/math.py +0 -0
  278. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/names.py +0 -0
  279. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/processutils.py +0 -0
  280. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/pydantic.py +0 -0
  281. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/render_swagger.py +0 -0
  282. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/schema_tools/__init__.py +0 -0
  283. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/schema_tools/hydration.py +0 -0
  284. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/schema_tools/validation.py +0 -0
  285. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/services.py +0 -0
  286. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/slugify.py +0 -0
  287. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/templating.py +0 -0
  288. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/text.py +0 -0
  289. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/timeout.py +0 -0
  290. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/utilities/visualization.py +0 -0
  291. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/variables.py +0 -0
  292. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/workers/__init__.py +0 -0
  293. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/workers/base.py +0 -0
  294. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/workers/block.py +0 -0
  295. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/workers/process.py +0 -0
  296. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/workers/server.py +0 -0
  297. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect/workers/utilities.py +0 -0
  298. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect_client.egg-info/SOURCES.txt +0 -0
  299. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect_client.egg-info/dependency_links.txt +0 -0
  300. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect_client.egg-info/requires.txt +0 -0
  301. {prefect-client-2.19.2 → prefect-client-2.19.4}/src/prefect_client.egg-info/top_level.txt +0 -0
  302. {prefect-client-2.19.2 → prefect-client-2.19.4}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.19.2
3
+ Version: 2.19.4
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
@@ -1,5 +1,4 @@
1
1
  [tool:pytest]
2
- testpaths = tests
3
2
  addopts = -rfEs
4
3
  norecursedirs = *.egg-info .git .mypy_cache node_modules .pytest_cache .vscode
5
4
  python_files =
@@ -97,6 +97,10 @@ class WorkPoolStatus(AutoEnum):
97
97
  NOT_READY = AutoEnum.auto()
98
98
  PAUSED = AutoEnum.auto()
99
99
 
100
+ @property
101
+ def display_name(self):
102
+ return self.name.replace("_", " ").capitalize()
103
+
100
104
 
101
105
  class WorkerStatus(AutoEnum):
102
106
  """Enumeration of worker statuses."""
@@ -396,7 +396,13 @@ async def _find_flow_functions_in_file(filename: str) -> List[Dict]:
396
396
  return decorated_functions
397
397
 
398
398
  for node in ast.walk(tree):
399
- if isinstance(node, ast.FunctionDef):
399
+ if isinstance(
400
+ node,
401
+ (
402
+ ast.FunctionDef,
403
+ ast.AsyncFunctionDef,
404
+ ),
405
+ ):
400
406
  for decorator in node.decorator_list:
401
407
  # handles @flow
402
408
  is_name_match = (
@@ -5,7 +5,9 @@ Module containing the base workflow class and decorator - for most use cases, us
5
5
  # This file requires type-checking with pyright because mypy does not yet support PEP612
6
6
  # See https://github.com/python/mypy/issues/8645
7
7
 
8
+ import ast
8
9
  import datetime
10
+ import importlib.util
9
11
  import inspect
10
12
  import os
11
13
  import tempfile
@@ -1640,7 +1642,9 @@ def load_flow_from_script(path: str, flow_name: str = None) -> Flow:
1640
1642
  )
1641
1643
 
1642
1644
 
1643
- def load_flow_from_entrypoint(entrypoint: str) -> Flow:
1645
+ def load_flow_from_entrypoint(
1646
+ entrypoint: str,
1647
+ ) -> Flow:
1644
1648
  """
1645
1649
  Extract a flow object from a script at an entrypoint by running all of the code in the file.
1646
1650
 
@@ -1793,3 +1797,64 @@ async def serve(
1793
1797
  )
1794
1798
 
1795
1799
  await runner.start()
1800
+
1801
+
1802
+ def load_flow_argument_from_entrypoint(
1803
+ entrypoint: str, arg: str = "name"
1804
+ ) -> Optional[str]:
1805
+ """
1806
+ Extract a flow argument from an entrypoint string.
1807
+
1808
+ Loads the source code of the entrypoint and extracts the flow argument from the
1809
+ `flow` decorator.
1810
+
1811
+ Args:
1812
+ entrypoint: a string in the format `<path_to_script>:<flow_func_name>` or a module path
1813
+ to a flow function
1814
+
1815
+ Returns:
1816
+ The flow argument value
1817
+ """
1818
+ if ":" in entrypoint:
1819
+ # split by the last colon once to handle Windows paths with drive letters i.e C:\path\to\file.py:do_stuff
1820
+ path, func_name = entrypoint.rsplit(":", maxsplit=1)
1821
+ source_code = Path(path).read_text()
1822
+ else:
1823
+ path, func_name = entrypoint.rsplit(".", maxsplit=1)
1824
+ spec = importlib.util.find_spec(path)
1825
+ if not spec or not spec.origin:
1826
+ raise ValueError(f"Could not find module {path!r}")
1827
+ source_code = Path(spec.origin).read_text()
1828
+ parsed_code = ast.parse(source_code)
1829
+ func_def = next(
1830
+ (
1831
+ node
1832
+ for node in ast.walk(parsed_code)
1833
+ if isinstance(
1834
+ node,
1835
+ (
1836
+ ast.FunctionDef,
1837
+ ast.AsyncFunctionDef,
1838
+ ),
1839
+ )
1840
+ and node.name == func_name
1841
+ ),
1842
+ None,
1843
+ )
1844
+ if not func_def:
1845
+ raise ValueError(f"Could not find flow {func_name!r} in {path!r}")
1846
+ for decorator in func_def.decorator_list:
1847
+ if (
1848
+ isinstance(decorator, ast.Call)
1849
+ and getattr(decorator.func, "id", "") == "flow"
1850
+ ):
1851
+ for keyword in decorator.keywords:
1852
+ if keyword.arg == arg:
1853
+ return (
1854
+ keyword.value.value
1855
+ ) # Return the string value of the argument
1856
+
1857
+ if arg == "name":
1858
+ return func_name.replace(
1859
+ "_", "-"
1860
+ ) # If no matching decorator or keyword argument is found
@@ -78,9 +78,7 @@ from prefect.deployments.runner import (
78
78
  )
79
79
  from prefect.deployments.schedules import FlexibleScheduleList
80
80
  from prefect.events import DeploymentTriggerTypes, TriggerTypes
81
- from prefect.exceptions import (
82
- Abort,
83
- )
81
+ from prefect.exceptions import Abort, ObjectNotFound
84
82
  from prefect.flows import Flow
85
83
  from prefect.logging.loggers import PrefectLogAdapter, flow_run_logger, get_logger
86
84
  from prefect.runner.server import start_webserver
@@ -1130,12 +1128,18 @@ class Runner:
1130
1128
  Run the hooks for a flow.
1131
1129
  """
1132
1130
  if state.is_cancelling():
1133
- flow = await load_flow_from_flow_run(
1134
- flow_run, client=self._client, storage_base_path=str(self._tmp_dir)
1135
- )
1136
- hooks = flow.on_cancellation or []
1131
+ try:
1132
+ flow = await load_flow_from_flow_run(
1133
+ flow_run, client=self._client, storage_base_path=str(self._tmp_dir)
1134
+ )
1135
+ hooks = flow.on_cancellation or []
1137
1136
 
1138
- await _run_hooks(hooks, flow_run, flow, state)
1137
+ await _run_hooks(hooks, flow_run, flow, state)
1138
+ except ObjectNotFound:
1139
+ run_logger = self._get_flow_run_logger(flow_run)
1140
+ run_logger.warning(
1141
+ f"Runner cannot retrieve flow to execute cancellation hooks for flow run {flow_run.id!r}."
1142
+ )
1139
1143
 
1140
1144
  async def _run_on_crashed_hooks(
1141
1145
  self,
@@ -2,8 +2,11 @@
2
2
  Utilities for working with Python callables.
3
3
  """
4
4
 
5
+ import ast
6
+ import importlib.util
5
7
  import inspect
6
8
  from functools import partial
9
+ from pathlib import Path
7
10
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
8
11
 
9
12
  import cloudpickle
@@ -31,7 +34,10 @@ from prefect.exceptions import (
31
34
  ReservedArgumentError,
32
35
  SignatureMismatchError,
33
36
  )
34
- from prefect.logging.loggers import disable_logger
37
+ from prefect.logging.loggers import disable_logger, get_logger
38
+ from prefect.utilities.importtools import safe_load_namespace
39
+
40
+ logger = get_logger(__name__)
35
41
 
36
42
 
37
43
  def get_call_parameters(
@@ -318,9 +324,62 @@ def parameter_schema(fn: Callable) -> ParameterSchema:
318
324
  # `eval_str` is not available in Python < 3.10
319
325
  signature = inspect.signature(fn)
320
326
 
327
+ docstrings = parameter_docstrings(inspect.getdoc(fn))
328
+
329
+ return generate_parameter_schema(signature, docstrings)
330
+
331
+
332
+ def parameter_schema_from_entrypoint(entrypoint: str) -> ParameterSchema:
333
+ """
334
+ Generate a parameter schema from an entrypoint string.
335
+
336
+ Will load the source code of the function and extract the signature and docstring
337
+ to generate the schema.
338
+
339
+ Useful for generating a schema for a function when instantiating the function may
340
+ not be possible due to missing imports or other issues.
341
+
342
+ Args:
343
+ entrypoint: A string representing the entrypoint to a function. The string
344
+ should be in the format of `module.path.to.function:do_stuff`.
345
+
346
+ Returns:
347
+ ParameterSchema: The parameter schema for the function.
348
+ """
349
+ if ":" in entrypoint:
350
+ # split by the last colon once to handle Windows paths with drive letters i.e C:\path\to\file.py:do_stuff
351
+ path, func_name = entrypoint.rsplit(":", maxsplit=1)
352
+ source_code = Path(path).read_text()
353
+ else:
354
+ path, func_name = entrypoint.rsplit(".", maxsplit=1)
355
+ spec = importlib.util.find_spec(path)
356
+ if not spec or not spec.origin:
357
+ raise ValueError(f"Could not find module {path!r}")
358
+ source_code = Path(spec.origin).read_text()
359
+ signature = _generate_signature_from_source(source_code, func_name)
360
+ docstring = _get_docstring_from_source(source_code, func_name)
361
+ return generate_parameter_schema(signature, parameter_docstrings(docstring))
362
+
363
+
364
+ def generate_parameter_schema(
365
+ signature: inspect.Signature, docstrings: Dict[str, str]
366
+ ) -> ParameterSchema:
367
+ """
368
+ Generate a parameter schema from a function signature and docstrings.
369
+
370
+ To get a signature from a function, use `inspect.signature(fn)` or
371
+ `_generate_signature_from_source(source_code, func_name)`.
372
+
373
+ Args:
374
+ signature: The function signature.
375
+ docstrings: A dictionary mapping parameter names to docstrings.
376
+
377
+ Returns:
378
+ ParameterSchema: The parameter schema.
379
+ """
380
+
321
381
  model_fields = {}
322
382
  aliases = {}
323
- docstrings = parameter_docstrings(inspect.getdoc(fn))
324
383
 
325
384
  class ModelConfig:
326
385
  arbitrary_types_allowed = True
@@ -362,3 +421,203 @@ def raise_for_reserved_arguments(fn: Callable, reserved_arguments: Iterable[str]
362
421
  raise ReservedArgumentError(
363
422
  f"{argument!r} is a reserved argument name and cannot be used."
364
423
  )
424
+
425
+
426
+ def _generate_signature_from_source(
427
+ source_code: str, func_name: str
428
+ ) -> inspect.Signature:
429
+ """
430
+ Extract the signature of a function from its source code.
431
+
432
+ Will ignore missing imports and exceptions while loading local class definitions.
433
+
434
+ Args:
435
+ source_code: The source code where the function named `func_name` is declared.
436
+ func_name: The name of the function.
437
+
438
+ Returns:
439
+ The signature of the function.
440
+ """
441
+ # Load the namespace from the source code. Missing imports and exceptions while
442
+ # loading local class definitions are ignored.
443
+ namespace = safe_load_namespace(source_code)
444
+ # Parse the source code into an AST
445
+ parsed_code = ast.parse(source_code)
446
+
447
+ func_def = next(
448
+ (
449
+ node
450
+ for node in ast.walk(parsed_code)
451
+ if isinstance(
452
+ node,
453
+ (
454
+ ast.FunctionDef,
455
+ ast.AsyncFunctionDef,
456
+ ),
457
+ )
458
+ and node.name == func_name
459
+ ),
460
+ None,
461
+ )
462
+ if func_def is None:
463
+ raise ValueError(f"Function {func_name} not found in source code")
464
+ parameters = []
465
+
466
+ # Handle annotations for positional only args e.g. def func(a, /, b, c)
467
+ for arg in func_def.args.posonlyargs:
468
+ name = arg.arg
469
+ annotation = arg.annotation
470
+ if annotation is not None:
471
+ try:
472
+ ann_code = compile(ast.Expression(annotation), "<string>", "eval")
473
+ annotation = eval(ann_code, namespace)
474
+ except Exception as e:
475
+ logger.debug("Failed to evaluate annotation for %s: %s", name, e)
476
+ annotation = inspect.Parameter.empty
477
+ else:
478
+ annotation = inspect.Parameter.empty
479
+
480
+ param = inspect.Parameter(
481
+ name, inspect.Parameter.POSITIONAL_ONLY, annotation=annotation
482
+ )
483
+ parameters.append(param)
484
+
485
+ # Determine the annotations for args e.g. def func(a: int, b: str, c: float)
486
+ for arg in func_def.args.args:
487
+ name = arg.arg
488
+ annotation = arg.annotation
489
+ if annotation is not None:
490
+ try:
491
+ # Compile and evaluate the annotation
492
+ ann_code = compile(ast.Expression(annotation), "<string>", "eval")
493
+ annotation = eval(ann_code, namespace)
494
+ except Exception as e:
495
+ # Don't raise an error if the annotation evaluation fails. Set the
496
+ # annotation to `inspect.Parameter.empty` instead which is equivalent to
497
+ # not having an annotation.
498
+ logger.debug("Failed to evaluate annotation for %s: %s", name, e)
499
+ annotation = inspect.Parameter.empty
500
+ else:
501
+ annotation = inspect.Parameter.empty
502
+
503
+ param = inspect.Parameter(
504
+ name, inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=annotation
505
+ )
506
+ parameters.append(param)
507
+
508
+ # Handle default values for args e.g. def func(a=1, b="hello", c=3.14)
509
+ defaults = [None] * (
510
+ len(func_def.args.args) - len(func_def.args.defaults)
511
+ ) + func_def.args.defaults
512
+ for param, default in zip(parameters, defaults):
513
+ if default is not None:
514
+ try:
515
+ def_code = compile(ast.Expression(default), "<string>", "eval")
516
+ default = eval(def_code, namespace)
517
+ except Exception as e:
518
+ logger.debug(
519
+ "Failed to evaluate default value for %s: %s", param.name, e
520
+ )
521
+ default = None # Set to None if evaluation fails
522
+ parameters[parameters.index(param)] = param.replace(default=default)
523
+
524
+ # Handle annotations for keyword only args e.g. def func(*, a: int, b: str)
525
+ for kwarg in func_def.args.kwonlyargs:
526
+ name = kwarg.arg
527
+ annotation = kwarg.annotation
528
+ if annotation is not None:
529
+ try:
530
+ ann_code = compile(ast.Expression(annotation), "<string>", "eval")
531
+ annotation = eval(ann_code, namespace)
532
+ except Exception as e:
533
+ logger.debug("Failed to evaluate annotation for %s: %s", name, e)
534
+ annotation = inspect.Parameter.empty
535
+ else:
536
+ annotation = inspect.Parameter.empty
537
+
538
+ param = inspect.Parameter(
539
+ name, inspect.Parameter.KEYWORD_ONLY, annotation=annotation
540
+ )
541
+ parameters.append(param)
542
+
543
+ # Handle default values for keyword only args e.g. def func(*, a=1, b="hello")
544
+ defaults = [None] * (
545
+ len(func_def.args.kwonlyargs) - len(func_def.args.kw_defaults)
546
+ ) + func_def.args.kw_defaults
547
+ for param, default in zip(parameters[-len(func_def.args.kwonlyargs) :], defaults):
548
+ if default is not None:
549
+ try:
550
+ def_code = compile(ast.Expression(default), "<string>", "eval")
551
+ default = eval(def_code, namespace)
552
+ except Exception as e:
553
+ logger.debug(
554
+ "Failed to evaluate default value for %s: %s", param.name, e
555
+ )
556
+ default = None
557
+ parameters[parameters.index(param)] = param.replace(default=default)
558
+
559
+ # Handle annotations for varargs and kwargs e.g. def func(*args: int, **kwargs: str)
560
+ if func_def.args.vararg:
561
+ parameters.append(
562
+ inspect.Parameter(
563
+ func_def.args.vararg.arg, inspect.Parameter.VAR_POSITIONAL
564
+ )
565
+ )
566
+ if func_def.args.kwarg:
567
+ parameters.append(
568
+ inspect.Parameter(func_def.args.kwarg.arg, inspect.Parameter.VAR_KEYWORD)
569
+ )
570
+
571
+ # Handle return annotation e.g. def func() -> int
572
+ return_annotation = func_def.returns
573
+ if return_annotation is not None:
574
+ try:
575
+ ret_ann_code = compile(
576
+ ast.Expression(return_annotation), "<string>", "eval"
577
+ )
578
+ return_annotation = eval(ret_ann_code, namespace)
579
+ except Exception as e:
580
+ logger.debug("Failed to evaluate return annotation: %s", e)
581
+ return_annotation = inspect.Signature.empty
582
+
583
+ return inspect.Signature(parameters, return_annotation=return_annotation)
584
+
585
+
586
+ def _get_docstring_from_source(source_code: str, func_name: str) -> Optional[str]:
587
+ """
588
+ Extract the docstring of a function from its source code.
589
+
590
+ Args:
591
+ source_code (str): The source code of the function.
592
+ func_name (str): The name of the function.
593
+
594
+ Returns:
595
+ The docstring of the function. If the function has no docstring, returns None.
596
+ """
597
+ parsed_code = ast.parse(source_code)
598
+
599
+ func_def = next(
600
+ (
601
+ node
602
+ for node in ast.walk(parsed_code)
603
+ if isinstance(
604
+ node,
605
+ (
606
+ ast.FunctionDef,
607
+ ast.AsyncFunctionDef,
608
+ ),
609
+ )
610
+ and node.name == func_name
611
+ ),
612
+ None,
613
+ )
614
+ if func_def is None:
615
+ raise ValueError(f"Function {func_name} not found in source code")
616
+
617
+ if (
618
+ func_def.body
619
+ and isinstance(func_def.body[0], ast.Expr)
620
+ and isinstance(func_def.body[0].value, ast.Constant)
621
+ ):
622
+ return func_def.body[0].value.value
623
+ return None
@@ -1,3 +1,4 @@
1
+ import ast
1
2
  import importlib
2
3
  import importlib.util
3
4
  import inspect
@@ -14,8 +15,11 @@ from typing import Any, Callable, Dict, Iterable, NamedTuple, Optional, Union
14
15
  import fsspec
15
16
 
16
17
  from prefect.exceptions import ScriptError
18
+ from prefect.logging.loggers import get_logger
17
19
  from prefect.utilities.filesystem import filename, is_local_path, tmpchdir
18
20
 
21
+ logger = get_logger(__name__)
22
+
19
23
 
20
24
  def to_qualified_name(obj: Any) -> str:
21
25
  """
@@ -356,3 +360,70 @@ class AliasedModuleLoader(Loader):
356
360
  if self.callback is not None:
357
361
  self.callback(self.alias)
358
362
  sys.modules[self.alias] = root_module
363
+
364
+
365
+ def safe_load_namespace(source_code: str):
366
+ """
367
+ Safely load a namespace from source code.
368
+
369
+ This function will attempt to import all modules and classes defined in the source
370
+ code. If an import fails, the error is caught and the import is skipped. This function
371
+ will also attempt to compile and evaluate class and function definitions locally.
372
+
373
+ Args:
374
+ source_code: The source code to load
375
+
376
+ Returns:
377
+ The namespace loaded from the source code. Can be used when evaluating source
378
+ code.
379
+ """
380
+ parsed_code = ast.parse(source_code)
381
+
382
+ namespace = {"__name__": "prefect_safe_namespace_loader"}
383
+
384
+ # Walk through the AST and find all import statements
385
+ for node in ast.walk(parsed_code):
386
+ if isinstance(node, ast.Import):
387
+ for alias in node.names:
388
+ module_name = alias.name
389
+ as_name = alias.asname if alias.asname else module_name
390
+ try:
391
+ # Attempt to import the module
392
+ namespace[as_name] = importlib.import_module(module_name)
393
+ logger.debug("Successfully imported %s", module_name)
394
+ except ImportError as e:
395
+ logger.debug(f"Failed to import {module_name}: {e}")
396
+ elif isinstance(node, ast.ImportFrom):
397
+ module_name = node.module
398
+ if module_name is None:
399
+ continue
400
+ try:
401
+ module = importlib.import_module(module_name)
402
+ for alias in node.names:
403
+ name = alias.name
404
+ asname = alias.asname if alias.asname else name
405
+ try:
406
+ # Get the specific attribute from the module
407
+ attribute = getattr(module, name)
408
+ namespace[asname] = attribute
409
+ except AttributeError as e:
410
+ logger.debug(
411
+ "Failed to retrieve %s from %s: %s", name, module_name, e
412
+ )
413
+ except ImportError as e:
414
+ logger.debug("Failed to import from %s: %s", node.module, e)
415
+
416
+ # Handle local definitions
417
+ for node in ast.walk(parsed_code):
418
+ if isinstance(node, (ast.ClassDef, ast.FunctionDef, ast.Assign)):
419
+ try:
420
+ # Compile and execute each class and function definition and assignment
421
+ code = compile(
422
+ ast.Module(body=[node], type_ignores=[]),
423
+ filename="<ast>",
424
+ mode="exec",
425
+ )
426
+ exec(code, namespace)
427
+ except Exception as e:
428
+ logger.debug("Failed to compile: %s", e)
429
+ return namespace
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.19.2
3
+ Version: 2.19.4
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
File without changes