prefect-client 2.20.5__py3-none-any.whl → 2.20.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
prefect/engine.py CHANGED
@@ -167,6 +167,7 @@ from prefect.results import ResultFactory, UnknownResult
167
167
  from prefect.settings import (
168
168
  PREFECT_DEBUG_MODE,
169
169
  PREFECT_EXPERIMENTAL_ENABLE_NEW_ENGINE,
170
+ PREFECT_RUN_ON_COMPLETION_HOOKS_ON_CACHED,
170
171
  PREFECT_TASK_INTROSPECTION_WARN_THRESHOLD,
171
172
  PREFECT_TASKS_REFRESH_CACHE,
172
173
  PREFECT_UI_URL,
@@ -2117,6 +2118,19 @@ async def orchestrate_task_run(
2117
2118
  # flag to ensure we only update the task run name once
2118
2119
  run_name_set = False
2119
2120
 
2121
+ run_on_completion_hooks_on_cached = (
2122
+ PREFECT_RUN_ON_COMPLETION_HOOKS_ON_CACHED
2123
+ and state.is_completed()
2124
+ and state.name == "Cached"
2125
+ )
2126
+
2127
+ if run_on_completion_hooks_on_cached:
2128
+ await _run_task_hooks(
2129
+ task=task,
2130
+ task_run=task_run,
2131
+ state=state,
2132
+ )
2133
+
2120
2134
  # Only run the task if we enter a `RUNNING` state
2121
2135
  while state.is_running():
2122
2136
  # Retrieve the latest metadata for the task run context
@@ -2326,9 +2340,16 @@ async def _run_task_hooks(task: Task, task_run: TaskRun, state: State) -> None:
2326
2340
  catch and log any errors that occur.
2327
2341
  """
2328
2342
  hooks = None
2343
+ run_on_completion_hooks_on_cached = (
2344
+ PREFECT_RUN_ON_COMPLETION_HOOKS_ON_CACHED
2345
+ and state.is_completed()
2346
+ and state.name == "Cached"
2347
+ )
2329
2348
  if state.is_failed() and task.on_failure:
2330
2349
  hooks = task.on_failure
2331
- elif state.is_completed() and task.on_completion:
2350
+ elif (
2351
+ state.is_completed() or run_on_completion_hooks_on_cached
2352
+ ) and task.on_completion:
2332
2353
  hooks = task.on_completion
2333
2354
 
2334
2355
  if hooks:
@@ -77,6 +77,7 @@ loggers:
77
77
  prefect.extra:
78
78
  level: "${PREFECT_LOGGING_LEVEL}"
79
79
  handlers: [api]
80
+ propagate: false
80
81
 
81
82
  prefect.flow_runs:
82
83
  level: NOTSET
prefect/settings.py CHANGED
@@ -649,7 +649,7 @@ PREFECT_API_KEY = Setting(
649
649
  )
650
650
  """API key used to authenticate with a the Prefect API. Defaults to `None`."""
651
651
 
652
- PREFECT_API_ENABLE_HTTP2 = Setting(bool, default=True)
652
+ PREFECT_API_ENABLE_HTTP2 = Setting(bool, default=False)
653
653
  """
654
654
  If true, enable support for HTTP/2 for communicating with an API.
655
655
 
@@ -1759,6 +1759,11 @@ PREFECT_API_EVENTS_RELATED_RESOURCE_CACHE_TTL = Setting(
1759
1759
  How long to cache related resource data for emitting server-side vents
1760
1760
  """
1761
1761
 
1762
+ PREFECT_RUN_ON_COMPLETION_HOOKS_ON_CACHED = Setting(bool, default=False)
1763
+ """
1764
+ Whether or not to run on_completion hooks on cached task runs.
1765
+ """
1766
+
1762
1767
 
1763
1768
  def automation_settings_enabled() -> bool:
1764
1769
  """
@@ -399,6 +399,7 @@ def safe_load_namespace(
399
399
  # Save original sys.path and modify it
400
400
  original_sys_path = sys.path.copy()
401
401
  sys.path.insert(0, parent_dir)
402
+ sys.path.insert(0, file_dir)
402
403
 
403
404
  # Create a temporary module for import context
404
405
  temp_module = ModuleType(package_name)
prefect/workers/base.py CHANGED
@@ -139,6 +139,12 @@ class BaseJobConfiguration(BaseModel):
139
139
  )
140
140
  variables.update(values)
141
141
 
142
+ # deep merge `env`
143
+ if isinstance(job_config.get("env"), dict) and (
144
+ hardcoded_env := variables.get("env")
145
+ ):
146
+ job_config["env"] = {**hardcoded_env, **job_config.get("env", {})}
147
+
142
148
  populated_configuration = apply_values(template=job_config, values=variables)
143
149
  populated_configuration = await resolve_block_document_references(
144
150
  template=populated_configuration, client=client
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefect-client
3
- Version: 2.20.5
3
+ Version: 2.20.7
4
4
  Summary: Workflow orchestration and management.
5
5
  Home-page: https://www.prefect.io
6
6
  Author: Prefect Technologies, Inc.
@@ -40,7 +40,7 @@ Requires-Dist: jsonschema<5.0.0,>=4.0.0
40
40
  Requires-Dist: orjson<4.0,>=3.7
41
41
  Requires-Dist: packaging<24.3,>=21.3
42
42
  Requires-Dist: pathspec>=0.8.0
43
- Requires-Dist: pydantic[email]!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.10.0
43
+ Requires-Dist: pydantic[email]!=2.0.0,!=2.0.1,!=2.1.0,<2.9.0,>=1.10.0
44
44
  Requires-Dist: pydantic-core<3.0.0,>=2.12.0
45
45
  Requires-Dist: python-dateutil<3.0.0,>=2.8.2
46
46
  Requires-Dist: python-slugify<9.0,>=5.0
@@ -5,7 +5,7 @@ prefect/agent.py,sha256=HaGT0yh3fciluYpO99dVHo_LHq7N2cYLuWNrEV_kPV8,27789
5
5
  prefect/artifacts.py,sha256=mreaBE4qMoXkjc9YI-5cAxoye7ixraHB_zr8GTK9xPU,8694
6
6
  prefect/automations.py,sha256=rjVtQblBlKhD_q24bG6zbxJeb_XQJnodMlhr565aZJY,4853
7
7
  prefect/context.py,sha256=Hgn3rIjCbqfCmGnZzV_eZ2FwxGjEhaZjUw_nppqNQSA,18189
8
- prefect/engine.py,sha256=yw6LVoaEUCTR-NkSJXRau2gB9jNCspMw83ELaxmwpnE,92291
8
+ prefect/engine.py,sha256=i68gM-ZZ2x9D4aIwaLmApWeHqpMb2U2QWNJjX3aPmZM,92887
9
9
  prefect/exceptions.py,sha256=ElqC81_w6XbTaxLYANLMIPK8Fz46NmJZCRKL4NZ-JIg,10907
10
10
  prefect/filesystems.py,sha256=XniPSdBAqywj43X7GyfuWJQIbz07QJ5Y3cVNLhIF3lQ,35260
11
11
  prefect/flow_runs.py,sha256=mFHLavZk1yZ62H3UazuNDBZWAF7AqKttA4rMcHgsVSw,3119
@@ -19,7 +19,7 @@ prefect/profiles.toml,sha256=Fs8hD_BdWHZgAijgk8pK_Zx-Pm-YFixqDIfEP6fM-qU,38
19
19
  prefect/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  prefect/results.py,sha256=JXuySIfJb9weg49A2YsI3ZxoPoAAYcXn7ajui_8vMbE,25502
21
21
  prefect/serializers.py,sha256=MsMTPgo6APq-pN1pcLD9COdVFnBS9E3WaMuaKgpeJdQ,8821
22
- prefect/settings.py,sha256=U4nySdke3t_TyQRJtcgkv5x4LLzwUwWPFrYMFh-QJB8,75227
22
+ prefect/settings.py,sha256=hQw2VtosFrWG_Q1w8WbodS6MIZBtX-QcGZz-hZfhp-g,75373
23
23
  prefect/states.py,sha256=B38zIXnqc8cmw3GPxmMQ4thX6pXb6UtG4PoTZ5thGQs,21036
24
24
  prefect/task_engine.py,sha256=_2I7XLwoT_nNhpzTMa_52aQKjsDoaW6WpzwIHYEWZS0,2598
25
25
  prefect/task_runners.py,sha256=HXUg5UqhZRN2QNBqMdGE1lKhwFhT8TaRN75ScgLbnw8,11012
@@ -234,7 +234,7 @@ prefect/logging/formatters.py,sha256=EPppQgqvbsIoSDGZFUqHJj1XdL-dvXGZe4TEcuRtfOI
234
234
  prefect/logging/handlers.py,sha256=zypWVA9EbaKMimRnZWxjmYYmZE04pB7OP5zKwkrOYHQ,10685
235
235
  prefect/logging/highlighters.py,sha256=BpSXOy0n3lFVvlKWa7jC-HetAiClFi9jnQtEq5-rgok,1681
236
236
  prefect/logging/loggers.py,sha256=kfTpM0RIcWm87UBYKggzcv0xeFfbuSIjH_i4pXdAZlo,11485
237
- prefect/logging/logging.yml,sha256=UkEewf0c3_dURI2uCU4RrxkhI5Devoa1s93fl7hilcg,3160
237
+ prefect/logging/logging.yml,sha256=ALNY_E1i3E7tkagCB3Qg35IvuRBHt-t9QqVJvsSq5xA,3185
238
238
  prefect/pydantic/__init__.py,sha256=BsW32X7fvl44J1JQer1tkEpfleMtL2kL5Uy1KmwWvso,2714
239
239
  prefect/pydantic/main.py,sha256=ups_UULBhCPhB-E7X7-Qgbpor1oJdqChRzpD0ZYQH8A,839
240
240
  prefect/runner/__init__.py,sha256=7U-vAOXFkzMfRz1q8Uv6Otsvc0OrPYLLP44srwkJ_8s,89
@@ -267,7 +267,7 @@ prefect/utilities/dockerutils.py,sha256=O5lIgCej5KGRYU2TC1NzNuIK595uOIWJilhZXYEV
267
267
  prefect/utilities/engine.py,sha256=6O7zYZQfpo6FtsI6n9DUNs-MB7_xLs3iXiCnSukR8qI,26046
268
268
  prefect/utilities/filesystem.py,sha256=M_TeZ1MftjBf7hDLWk-Iphir369TpJ1binMsBKiO9YE,4449
269
269
  prefect/utilities/hashing.py,sha256=EOwZLmoIZImuSTxAvVqInabxJ-4RpEfYeg9e2EDQF8o,1752
270
- prefect/utilities/importtools.py,sha256=JteP9zFz-oJyxSVYr63kJ-RpDL2jjTfJMqgYaBst19M,19518
270
+ prefect/utilities/importtools.py,sha256=r1Ii7CfUJr50y4WktUcBcKMBS9qyL5i6dCpBWuG-D9c,19555
271
271
  prefect/utilities/math.py,sha256=wLwcKVidpNeWQi1TUIWWLHGjlz9UgboX9FUGhx_CQzo,2821
272
272
  prefect/utilities/names.py,sha256=x-stHcF7_tebJPvB1dz-5FvdXJXNBTg2kFZXSnIBBmk,1657
273
273
  prefect/utilities/processutils.py,sha256=yo_GO48pZzgn4A0IK5irTAoqyUCYvWKDSqHXCrtP8c4,14547
@@ -283,13 +283,13 @@ prefect/utilities/schema_tools/__init__.py,sha256=KsFsTEHQqgp89TkDpjggkgBBywoHQP
283
283
  prefect/utilities/schema_tools/hydration.py,sha256=RNuJK4Vd__V69gdQbaWSVhSkV0AUISfGzH_xd0p6Zh0,8291
284
284
  prefect/utilities/schema_tools/validation.py,sha256=zZHL_UFxAlgaUzi-qsEOrhWtZ7EkFQvPkX_YN1EJNTo,8414
285
285
  prefect/workers/__init__.py,sha256=6el2Q856CuRPa5Hdrbm9QyAWB_ovcT2bImSFsoWI46k,66
286
- prefect/workers/base.py,sha256=wCCxTUuU5fIyLOkfjCIFIKi7T60B3-UQsyrq0kJuHjg,45351
286
+ prefect/workers/base.py,sha256=LNcVu0FIDBYv2XnWH1a2uV2Yyngtlyq8_pvLC4dxbrc,45576
287
287
  prefect/workers/block.py,sha256=aYY__uq3v1eq1kkbVukxyhQNbkknaKYo6-_3tcrfKKA,8067
288
288
  prefect/workers/process.py,sha256=pPtCdA7fKQ4OsvoitT-cayZeh5HgLX4xBUYlb2Zad-Q,9475
289
289
  prefect/workers/server.py,sha256=WVZJxR8nTMzK0ov0BD0xw5OyQpT26AxlXbsGQ1OrxeQ,1551
290
290
  prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
291
- prefect_client-2.20.5.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
292
- prefect_client-2.20.5.dist-info/METADATA,sha256=PZ764AcFU5kh5nhJhvBVRy_LuNtwBUHB5Yrk0pKPm8A,7391
293
- prefect_client-2.20.5.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
294
- prefect_client-2.20.5.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
295
- prefect_client-2.20.5.dist-info/RECORD,,
291
+ prefect_client-2.20.7.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
292
+ prefect_client-2.20.7.dist-info/METADATA,sha256=mnKbnE3cWEP7Xg2LBPLGtlhfD66cWK7JB3oclffDEWI,7391
293
+ prefect_client-2.20.7.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
294
+ prefect_client-2.20.7.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
295
+ prefect_client-2.20.7.dist-info/RECORD,,