prefect-client 3.0.8__py3-none-any.whl → 3.0.9__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/_version.py +3 -3
- prefect/context.py +13 -21
- prefect/runner/runner.py +36 -35
- prefect/settings.py +1 -2
- prefect/task_worker.py +6 -1
- prefect/utilities/dockerutils.py +1 -1
- {prefect_client-3.0.8.dist-info → prefect_client-3.0.9.dist-info}/METADATA +1 -1
- {prefect_client-3.0.8.dist-info → prefect_client-3.0.9.dist-info}/RECORD +11 -11
- {prefect_client-3.0.8.dist-info → prefect_client-3.0.9.dist-info}/LICENSE +0 -0
- {prefect_client-3.0.8.dist-info → prefect_client-3.0.9.dist-info}/WHEEL +0 -0
- {prefect_client-3.0.8.dist-info → prefect_client-3.0.9.dist-info}/top_level.txt +0 -0
prefect/_version.py
CHANGED
@@ -8,11 +8,11 @@ import json
|
|
8
8
|
|
9
9
|
version_json = '''
|
10
10
|
{
|
11
|
-
"date": "2024-10-
|
11
|
+
"date": "2024-10-15T10:11:48-0400",
|
12
12
|
"dirty": true,
|
13
13
|
"error": null,
|
14
|
-
"full-revisionid": "
|
15
|
-
"version": "3.0.
|
14
|
+
"full-revisionid": "fd8cef25431a01f5b6ff2f031c2d53b3094797cb",
|
15
|
+
"version": "3.0.9"
|
16
16
|
}
|
17
17
|
''' # END VERSION_JSON
|
18
18
|
|
prefect/context.py
CHANGED
@@ -453,23 +453,6 @@ class SettingsContext(ContextModel):
|
|
453
453
|
def __hash__(self) -> int:
|
454
454
|
return hash(self.settings)
|
455
455
|
|
456
|
-
def __enter__(self):
|
457
|
-
"""
|
458
|
-
Upon entrance, we ensure the home directory for the profile exists.
|
459
|
-
"""
|
460
|
-
return_value = super().__enter__()
|
461
|
-
|
462
|
-
try:
|
463
|
-
prefect_home = self.settings.home
|
464
|
-
prefect_home.mkdir(mode=0o0700, exist_ok=True)
|
465
|
-
except OSError:
|
466
|
-
warnings.warn(
|
467
|
-
(f"Failed to create the Prefect home directory at {prefect_home}"),
|
468
|
-
stacklevel=2,
|
469
|
-
)
|
470
|
-
|
471
|
-
return return_value
|
472
|
-
|
473
456
|
@classmethod
|
474
457
|
def get(cls) -> "SettingsContext":
|
475
458
|
# Return the global context instead of `None` if no context exists
|
@@ -567,9 +550,9 @@ def tags(*new_tags: str) -> Generator[Set[str], None, None]:
|
|
567
550
|
{"a", "b", "c", "d", "e", "f"}
|
568
551
|
"""
|
569
552
|
current_tags = TagsContext.get().current_tags
|
570
|
-
|
571
|
-
with TagsContext(current_tags=
|
572
|
-
yield
|
553
|
+
_new_tags = current_tags.union(new_tags)
|
554
|
+
with TagsContext(current_tags=_new_tags):
|
555
|
+
yield _new_tags
|
573
556
|
|
574
557
|
|
575
558
|
@contextmanager
|
@@ -659,7 +642,16 @@ def root_settings_context():
|
|
659
642
|
)
|
660
643
|
active_name = "ephemeral"
|
661
644
|
|
662
|
-
|
645
|
+
if not (settings := Settings()).home.exists():
|
646
|
+
try:
|
647
|
+
settings.home.mkdir(mode=0o0700, exist_ok=True)
|
648
|
+
except OSError:
|
649
|
+
warnings.warn(
|
650
|
+
(f"Failed to create the Prefect home directory at {settings.home}"),
|
651
|
+
stacklevel=2,
|
652
|
+
)
|
653
|
+
|
654
|
+
return SettingsContext(profile=profiles[active_name], settings=settings)
|
663
655
|
|
664
656
|
# Note the above context is exited and the global settings context is used by
|
665
657
|
# an override in the `SettingsContext.get` method.
|
prefect/runner/runner.py
CHANGED
@@ -41,6 +41,7 @@ import subprocess
|
|
41
41
|
import sys
|
42
42
|
import tempfile
|
43
43
|
import threading
|
44
|
+
from contextlib import AsyncExitStack
|
44
45
|
from copy import deepcopy
|
45
46
|
from functools import partial
|
46
47
|
from pathlib import Path
|
@@ -185,6 +186,7 @@ class Runner:
|
|
185
186
|
self.query_seconds = query_seconds or PREFECT_RUNNER_POLL_FREQUENCY.value()
|
186
187
|
self._prefetch_seconds = prefetch_seconds
|
187
188
|
|
189
|
+
self._exit_stack = AsyncExitStack()
|
188
190
|
self._limiter: Optional[anyio.CapacityLimiter] = None
|
189
191
|
self._client = get_client()
|
190
192
|
self._submitting_flow_run_ids = set()
|
@@ -398,38 +400,37 @@ class Runner:
|
|
398
400
|
start_client_metrics_server()
|
399
401
|
|
400
402
|
async with self as runner:
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
jitter_range=0.3,
|
411
|
-
)
|
403
|
+
for storage in self._storage_objs:
|
404
|
+
if storage.pull_interval:
|
405
|
+
self._runs_task_group.start_soon(
|
406
|
+
partial(
|
407
|
+
critical_service_loop,
|
408
|
+
workload=storage.pull_code,
|
409
|
+
interval=storage.pull_interval,
|
410
|
+
run_once=run_once,
|
411
|
+
jitter_range=0.3,
|
412
412
|
)
|
413
|
-
else:
|
414
|
-
tg.start_soon(storage.pull_code)
|
415
|
-
tg.start_soon(
|
416
|
-
partial(
|
417
|
-
critical_service_loop,
|
418
|
-
workload=runner._get_and_submit_flow_runs,
|
419
|
-
interval=self.query_seconds,
|
420
|
-
run_once=run_once,
|
421
|
-
jitter_range=0.3,
|
422
413
|
)
|
414
|
+
else:
|
415
|
+
self._runs_task_group.start_soon(storage.pull_code)
|
416
|
+
self._runs_task_group.start_soon(
|
417
|
+
partial(
|
418
|
+
critical_service_loop,
|
419
|
+
workload=runner._get_and_submit_flow_runs,
|
420
|
+
interval=self.query_seconds,
|
421
|
+
run_once=run_once,
|
422
|
+
jitter_range=0.3,
|
423
423
|
)
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
424
|
+
)
|
425
|
+
self._runs_task_group.start_soon(
|
426
|
+
partial(
|
427
|
+
critical_service_loop,
|
428
|
+
workload=runner._check_for_cancelled_flow_runs,
|
429
|
+
interval=self.query_seconds * 2,
|
430
|
+
run_once=run_once,
|
431
|
+
jitter_range=0.3,
|
432
432
|
)
|
433
|
+
)
|
433
434
|
|
434
435
|
def execute_in_background(self, func, *args, **kwargs):
|
435
436
|
"""
|
@@ -1264,14 +1265,16 @@ class Runner:
|
|
1264
1265
|
if not hasattr(self, "_loop") or not self._loop:
|
1265
1266
|
self._loop = asyncio.get_event_loop()
|
1266
1267
|
|
1268
|
+
await self._exit_stack.__aenter__()
|
1269
|
+
|
1270
|
+
await self._exit_stack.enter_async_context(self._client)
|
1267
1271
|
if not hasattr(self, "_runs_task_group") or not self._runs_task_group:
|
1268
1272
|
self._runs_task_group: anyio.abc.TaskGroup = anyio.create_task_group()
|
1273
|
+
await self._exit_stack.enter_async_context(self._runs_task_group)
|
1269
1274
|
|
1270
1275
|
if not hasattr(self, "_loops_task_group") or not self._loops_task_group:
|
1271
1276
|
self._loops_task_group: anyio.abc.TaskGroup = anyio.create_task_group()
|
1272
|
-
|
1273
|
-
await self._client.__aenter__()
|
1274
|
-
await self._runs_task_group.__aenter__()
|
1277
|
+
await self._exit_stack.enter_async_context(self._loops_task_group)
|
1275
1278
|
|
1276
1279
|
self.started = True
|
1277
1280
|
return self
|
@@ -1283,11 +1286,9 @@ class Runner:
|
|
1283
1286
|
self.started = False
|
1284
1287
|
for scope in self._scheduled_task_scopes:
|
1285
1288
|
scope.cancel()
|
1286
|
-
|
1287
|
-
await self._runs_task_group.__aexit__(*exc_info)
|
1288
|
-
if self._client:
|
1289
|
-
await self._client.__aexit__(*exc_info)
|
1289
|
+
await self._exit_stack.__aexit__(*exc_info)
|
1290
1290
|
shutil.rmtree(str(self._tmp_dir))
|
1291
|
+
del self._runs_task_group, self._loops_task_group
|
1291
1292
|
|
1292
1293
|
def __repr__(self):
|
1293
1294
|
return f"Runner(name={self.name!r})"
|
prefect/settings.py
CHANGED
@@ -381,7 +381,6 @@ class ProfileSettingsTomlLoader(PydanticBaseSettingsSource):
|
|
381
381
|
|
382
382
|
if not active_profile or active_profile not in profiles_data:
|
383
383
|
return {}
|
384
|
-
|
385
384
|
return profiles_data[active_profile]
|
386
385
|
|
387
386
|
def get_field_value(
|
@@ -1509,7 +1508,7 @@ class Settings(BaseSettings):
|
|
1509
1508
|
return self
|
1510
1509
|
|
1511
1510
|
@model_validator(mode="after")
|
1512
|
-
def emit_warnings(self):
|
1511
|
+
def emit_warnings(self) -> Self:
|
1513
1512
|
"""More post-hoc validation of settings, including warnings for misconfigurations."""
|
1514
1513
|
values = self.model_dump()
|
1515
1514
|
values = max_log_size_smaller_than_batch_size(values)
|
prefect/task_worker.py
CHANGED
@@ -102,7 +102,7 @@ class TaskWorker:
|
|
102
102
|
"TaskWorker must be initialized within an async context."
|
103
103
|
)
|
104
104
|
|
105
|
-
self._runs_task_group: anyio.abc.TaskGroup =
|
105
|
+
self._runs_task_group: Optional[anyio.abc.TaskGroup] = None
|
106
106
|
self._executor = ThreadPoolExecutor(max_workers=limit if limit else None)
|
107
107
|
self._limiter = anyio.CapacityLimiter(limit) if limit else None
|
108
108
|
|
@@ -230,6 +230,9 @@ class TaskWorker:
|
|
230
230
|
|
231
231
|
token_acquired = await self._acquire_token(task_run.id)
|
232
232
|
if token_acquired:
|
233
|
+
assert (
|
234
|
+
self._runs_task_group is not None
|
235
|
+
), "Task group was not initialized"
|
233
236
|
self._runs_task_group.start_soon(
|
234
237
|
self._safe_submit_scheduled_task_run, task_run
|
235
238
|
)
|
@@ -349,7 +352,9 @@ class TaskWorker:
|
|
349
352
|
|
350
353
|
if self._client._closed:
|
351
354
|
self._client = get_client()
|
355
|
+
self._runs_task_group = anyio.create_task_group()
|
352
356
|
|
357
|
+
await self._exit_stack.__aenter__()
|
353
358
|
await self._exit_stack.enter_async_context(self._client)
|
354
359
|
await self._exit_stack.enter_async_context(self._runs_task_group)
|
355
360
|
self._exit_stack.enter_context(self._executor)
|
prefect/utilities/dockerutils.py
CHANGED
@@ -57,7 +57,7 @@ def get_prefect_image_name(
|
|
57
57
|
flavor: An optional alternative image flavor to build, like 'conda'
|
58
58
|
"""
|
59
59
|
parsed_version = Version(prefect_version or prefect.__version__)
|
60
|
-
is_prod_build = parsed_version.
|
60
|
+
is_prod_build = parsed_version.local is None
|
61
61
|
prefect_version = (
|
62
62
|
parsed_version.base_version
|
63
63
|
if is_prod_build
|
@@ -1,11 +1,11 @@
|
|
1
1
|
prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
|
2
2
|
prefect/__init__.py,sha256=2jnhqiLx5v3iQ2JeTVp4V85uSC_3Yg3HlE05JjjQSGc,3223
|
3
|
-
prefect/_version.py,sha256=
|
3
|
+
prefect/_version.py,sha256=QLTgLPVEvLsYFCm962aIPUtbC_nIkpFEL8GSLFDWi6w,496
|
4
4
|
prefect/agent.py,sha256=BOVVY5z-vUIQ2u8LwMTXDaNys2fjOZSS5YGDwJmTQjI,230
|
5
5
|
prefect/artifacts.py,sha256=dsxFWmdg2r9zbHM3KgKOR5YbJ29_dXUYF9kipJpbxkE,13009
|
6
6
|
prefect/automations.py,sha256=NlQ62GPJzy-gnWQqX7c6CQJKw7p60WLGDAFcy82vtg4,5613
|
7
7
|
prefect/cache_policies.py,sha256=PWUzyJue4h5XHVeIVolfPKhRGrx1hyWJt58AJyHbcqU,9104
|
8
|
-
prefect/context.py,sha256=
|
8
|
+
prefect/context.py,sha256=U-IBDEQsmeZmTcNWjeeELTnYpbKKKUh0thM-S8cXRI8,21381
|
9
9
|
prefect/engine.py,sha256=BpmDbe6miZcTl1vRkxfCPYcWSXADLigGPCagFwucMz0,1976
|
10
10
|
prefect/exceptions.py,sha256=V_nRpS2Z93PvJMoQdXbx8zepVaFb-pWanCqVi7T1ngI,11803
|
11
11
|
prefect/filesystems.py,sha256=CxwMmKY8LBUed_9IqE2jUqxVCWhXa1r2fjKgLbIC2Vg,17893
|
@@ -19,12 +19,12 @@ prefect/profiles.toml,sha256=kTvqDNMzjH3fsm5OEI-NKY4dMmipor5EvQXRB6rPEjY,522
|
|
19
19
|
prefect/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
20
|
prefect/results.py,sha256=-V_JRaWeY2WXWhY2d_zL7KVIro660mIU6F3heNaih0o,47391
|
21
21
|
prefect/serializers.py,sha256=Lo41EM0_qGzcfB_63390Izeo3DdK6cY6VZfxa9hpSGQ,8712
|
22
|
-
prefect/settings.py,sha256=
|
22
|
+
prefect/settings.py,sha256=siuZyTdsiLd9pNXOfGh7HlcIyNEdo7u4e6JZ57GOYLA,73565
|
23
23
|
prefect/states.py,sha256=2lysq6X5AvqPfE3eD3D0HYt-KpFA2OUgA0c4ZQ22A_U,24906
|
24
24
|
prefect/task_engine.py,sha256=gjSpoLecy1gyPavNPOw40DFZonvqXIzLLqiGooqyhM0,57945
|
25
25
|
prefect/task_runners.py,sha256=Ef8JENamKGWGyAGkuB_QwSLGWbWKRsmvemZGDkyRWCQ,15021
|
26
26
|
prefect/task_runs.py,sha256=jkaQOkRKOHS8fgHUijteriFpjMSKv4zldn1D8tZHkUI,8777
|
27
|
-
prefect/task_worker.py,sha256=
|
27
|
+
prefect/task_worker.py,sha256=VfLF0W_RAahAZM-M75vC0zxDFwcHY0V20qsQX4cDKuw,17007
|
28
28
|
prefect/tasks.py,sha256=35eOv7VfhziiC3hL9FxB3spYtG6tpxZBLzk5KP_8Ux8,68371
|
29
29
|
prefect/transactions.py,sha256=NTzflkehGQ5jKmuChpvsUv1-ZPBqLI7OmUeq-nZJGHQ,16558
|
30
30
|
prefect/variables.py,sha256=023cfSj_ydwvz6lyChRKnjHFfkdoYZKK_zdTtuSxrYo,4665
|
@@ -149,7 +149,7 @@ prefect/records/filesystem.py,sha256=X-h7r5deiHH5IaaDk4ugOCmR5ZKnJeU2cLgp0AkMt0E
|
|
149
149
|
prefect/records/memory.py,sha256=YdzQvEfb-CX0sKxAZK5TaNxVvAlyYlZse9qdoer6Xbk,6447
|
150
150
|
prefect/records/result_store.py,sha256=3ZUFNHCCv_qBQhmIFdvlK_GMnPZcFacaI9dVdDKWdwA,2431
|
151
151
|
prefect/runner/__init__.py,sha256=7U-vAOXFkzMfRz1q8Uv6Otsvc0OrPYLLP44srwkJ_8s,89
|
152
|
-
prefect/runner/runner.py,sha256=
|
152
|
+
prefect/runner/runner.py,sha256=MkN_ZAKXlFzEQBf4JdAAwMOrEZLpSzXyVwfxL_HjyeI,48760
|
153
153
|
prefect/runner/server.py,sha256=2o5vhrL7Zbn-HBStWhCjqqViex5Ye9GiQ1EW9RSEzdo,10500
|
154
154
|
prefect/runner/storage.py,sha256=OsBa4nWdFxOTiAMNLFpexBdi5K3iuxidQx4YWZwditE,24734
|
155
155
|
prefect/runner/submit.py,sha256=RuyDr-ved9wjYYarXiehY5oJVFf_HE3XKKACNWpxpPc,8131
|
@@ -170,7 +170,7 @@ prefect/utilities/collections.py,sha256=_YVHZfT49phrXq7aDUmn4pqWwEtJQTPy2nJD0M1s
|
|
170
170
|
prefect/utilities/compat.py,sha256=mNQZDnzyKaOqy-OV-DnmH_dc7CNF5nQgW_EsA4xMr7g,906
|
171
171
|
prefect/utilities/context.py,sha256=BThuUW94-IYgFYTeMIM9KMo8ShT3oiI7w5ajZHzU1j0,1377
|
172
172
|
prefect/utilities/dispatch.py,sha256=EthEmyRwv-4W8z2BJclrsOQHJ_pJoZYL0t2cyYPEa-E,6098
|
173
|
-
prefect/utilities/dockerutils.py,sha256=
|
173
|
+
prefect/utilities/dockerutils.py,sha256=zjqeyE4gK8r0n5l3b2XK2AKviQ2F-pOd1LE2O4qfJt0,20372
|
174
174
|
prefect/utilities/engine.py,sha256=KaGtKWNZ-EaSTTppL7zpqWWjDLpMcPTVK0Gfd4zXpRM,32087
|
175
175
|
prefect/utilities/filesystem.py,sha256=frAyy6qOeYa7c-jVbEUGZQEe6J1yF8I_SvUepPd59gI,4415
|
176
176
|
prefect/utilities/hashing.py,sha256=EOwZLmoIZImuSTxAvVqInabxJ-4RpEfYeg9e2EDQF8o,1752
|
@@ -197,8 +197,8 @@ prefect/workers/cloud.py,sha256=BOVVY5z-vUIQ2u8LwMTXDaNys2fjOZSS5YGDwJmTQjI,230
|
|
197
197
|
prefect/workers/process.py,sha256=tcJ3fbiraLCfpVGpv8dOHwMSfVzeD_kyguUOvPuIz6I,19796
|
198
198
|
prefect/workers/server.py,sha256=lgh2FfSuaNU7b6HPxSFm8JtKvAvHsZGkiOo4y4tW1Cw,2022
|
199
199
|
prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
|
200
|
-
prefect_client-3.0.
|
201
|
-
prefect_client-3.0.
|
202
|
-
prefect_client-3.0.
|
203
|
-
prefect_client-3.0.
|
204
|
-
prefect_client-3.0.
|
200
|
+
prefect_client-3.0.9.dist-info/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
|
201
|
+
prefect_client-3.0.9.dist-info/METADATA,sha256=MRsROVJ93m69z-jP70E1ngKyw75Nrioc7bLMfP34rZE,7332
|
202
|
+
prefect_client-3.0.9.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
203
|
+
prefect_client-3.0.9.dist-info/top_level.txt,sha256=MJZYJgFdbRc2woQCeB4vM6T33tr01TmkEhRcns6H_H4,8
|
204
|
+
prefect_client-3.0.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|