prefect-client 3.3.6.dev3__py3-none-any.whl → 3.3.6.dev4__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/_build_info.py +3 -3
- prefect/_experimental/{bundles.py → bundles/__init__.py} +25 -9
- prefect/_experimental/bundles/execute.py +34 -0
- prefect/server/api/deployments.py +41 -3
- prefect/workers/base.py +19 -1
- {prefect_client-3.3.6.dev3.dist-info → prefect_client-3.3.6.dev4.dist-info}/METADATA +1 -1
- {prefect_client-3.3.6.dev3.dist-info → prefect_client-3.3.6.dev4.dist-info}/RECORD +9 -8
- {prefect_client-3.3.6.dev3.dist-info → prefect_client-3.3.6.dev4.dist-info}/WHEEL +0 -0
- {prefect_client-3.3.6.dev3.dist-info → prefect_client-3.3.6.dev4.dist-info}/licenses/LICENSE +0 -0
prefect/_build_info.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Generated by versioningit
|
2
|
-
__version__ = "3.3.6.
|
3
|
-
__build_date__ = "2025-04-
|
4
|
-
__git_commit__ = "
|
2
|
+
__version__ = "3.3.6.dev4"
|
3
|
+
__build_date__ = "2025-04-24 08:08:45.298549+00:00"
|
4
|
+
__git_commit__ = "cd2bf96d18276663c433a99c1e0f1191c100de5f"
|
5
5
|
__dirty__ = False
|
@@ -11,7 +11,7 @@ import sys
|
|
11
11
|
from pathlib import Path
|
12
12
|
from typing import Any, TypedDict
|
13
13
|
|
14
|
-
import cloudpickle
|
14
|
+
import cloudpickle # pyright: ignore[reportMissingTypeStubs]
|
15
15
|
|
16
16
|
from prefect.client.schemas.objects import FlowRun
|
17
17
|
from prefect.context import SettingsContext, get_settings_context, serialize_context
|
@@ -22,12 +22,18 @@ from prefect.settings.context import get_current_settings
|
|
22
22
|
from prefect.settings.models.root import Settings
|
23
23
|
from prefect.utilities.slugify import slugify
|
24
24
|
|
25
|
-
|
26
|
-
import uv
|
25
|
+
from .execute import execute_bundle_from_file
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
|
28
|
+
def _get_uv_path() -> str:
|
29
|
+
try:
|
30
|
+
import uv
|
31
|
+
|
32
|
+
uv_path = uv.find_uv_bin()
|
33
|
+
except (ImportError, ModuleNotFoundError):
|
34
|
+
uv_path = "uv"
|
35
|
+
|
36
|
+
return uv_path
|
31
37
|
|
32
38
|
|
33
39
|
class SerializedBundle(TypedDict):
|
@@ -46,7 +52,7 @@ def _serialize_bundle_object(obj: Any) -> str:
|
|
46
52
|
"""
|
47
53
|
Serializes an object to a string.
|
48
54
|
"""
|
49
|
-
return base64.b64encode(gzip.compress(cloudpickle.dumps(obj))).decode()
|
55
|
+
return base64.b64encode(gzip.compress(cloudpickle.dumps(obj))).decode() # pyright: ignore[reportUnknownMemberType]
|
50
56
|
|
51
57
|
|
52
58
|
def _deserialize_bundle_object(serialized_obj: str) -> Any:
|
@@ -80,7 +86,7 @@ def create_bundle_for_flow_run(
|
|
80
86
|
"flow_run": flow_run.model_dump(mode="json"),
|
81
87
|
"dependencies": subprocess.check_output(
|
82
88
|
[
|
83
|
-
|
89
|
+
_get_uv_path(),
|
84
90
|
"pip",
|
85
91
|
"freeze",
|
86
92
|
# Exclude editable installs because we won't be able to install them in the execution environment
|
@@ -164,7 +170,7 @@ def execute_bundle_in_subprocess(
|
|
164
170
|
# Install dependencies if necessary
|
165
171
|
if dependencies := bundle.get("dependencies"):
|
166
172
|
subprocess.check_call(
|
167
|
-
[
|
173
|
+
[_get_uv_path(), "pip", "install", *dependencies.split("\n")],
|
168
174
|
# Copy the current environment to ensure we install into the correct venv
|
169
175
|
env=os.environ,
|
170
176
|
)
|
@@ -238,3 +244,13 @@ def convert_step_to_command(
|
|
238
244
|
command.extend(["--key", key])
|
239
245
|
|
240
246
|
return command
|
247
|
+
|
248
|
+
|
249
|
+
__all__ = [
|
250
|
+
"execute_bundle_from_file",
|
251
|
+
"convert_step_to_command",
|
252
|
+
"create_bundle_for_flow_run",
|
253
|
+
"extract_flow_from_bundle",
|
254
|
+
"execute_bundle_in_subprocess",
|
255
|
+
"SerializedBundle",
|
256
|
+
]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
import typer
|
4
|
+
|
5
|
+
from prefect.utilities.asyncutils import run_coro_as_sync
|
6
|
+
|
7
|
+
|
8
|
+
def execute_bundle_from_file(key: str):
|
9
|
+
"""
|
10
|
+
Loads a bundle from a file and executes it.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
key: The key of the bundle to execute.
|
14
|
+
"""
|
15
|
+
with open(key, "r") as f:
|
16
|
+
bundle = json.load(f)
|
17
|
+
|
18
|
+
from prefect.runner.runner import Runner
|
19
|
+
|
20
|
+
run_coro_as_sync(Runner().execute_bundle(bundle))
|
21
|
+
|
22
|
+
|
23
|
+
def _execute_bundle_from_file(key: str = typer.Option(...)):
|
24
|
+
"""
|
25
|
+
Loads a bundle from a file and executes it.
|
26
|
+
|
27
|
+
Args:
|
28
|
+
key: The key of the bundle to execute.
|
29
|
+
"""
|
30
|
+
execute_bundle_from_file(key)
|
31
|
+
|
32
|
+
|
33
|
+
if __name__ == "__main__":
|
34
|
+
typer.run(_execute_bundle_from_file)
|
@@ -98,9 +98,31 @@ async def create_deployment(
|
|
98
98
|
)
|
99
99
|
|
100
100
|
# hydrate the input model into a full model
|
101
|
-
deployment_dict = deployment.model_dump(
|
102
|
-
exclude={"work_pool_name"},
|
101
|
+
deployment_dict: dict = deployment.model_dump(
|
102
|
+
exclude={"work_pool_name"},
|
103
|
+
exclude_unset=True,
|
103
104
|
)
|
105
|
+
|
106
|
+
requested_concurrency_limit = deployment_dict.pop(
|
107
|
+
"global_concurrency_limit_id", "unset"
|
108
|
+
)
|
109
|
+
if requested_concurrency_limit != "unset":
|
110
|
+
if requested_concurrency_limit:
|
111
|
+
concurrency_limit = (
|
112
|
+
await models.concurrency_limits_v2.read_concurrency_limit(
|
113
|
+
session=session,
|
114
|
+
concurrency_limit_id=requested_concurrency_limit,
|
115
|
+
)
|
116
|
+
)
|
117
|
+
|
118
|
+
if not concurrency_limit:
|
119
|
+
raise HTTPException(
|
120
|
+
status_code=status.HTTP_404_NOT_FOUND,
|
121
|
+
detail="Concurrency limit not found",
|
122
|
+
)
|
123
|
+
|
124
|
+
deployment_dict["concurrency_limit_id"] = requested_concurrency_limit
|
125
|
+
|
104
126
|
if deployment.work_pool_name and deployment.work_queue_name:
|
105
127
|
# If a specific pool name/queue name combination was provided, get the
|
106
128
|
# ID for that work pool queue.
|
@@ -300,8 +322,24 @@ async def update_deployment(
|
|
300
322
|
detail="Invalid schema: Unable to validate schema with circular references.",
|
301
323
|
)
|
302
324
|
|
325
|
+
if deployment.global_concurrency_limit_id:
|
326
|
+
concurrency_limit = (
|
327
|
+
await models.concurrency_limits_v2.read_concurrency_limit(
|
328
|
+
session=session,
|
329
|
+
concurrency_limit_id=deployment.global_concurrency_limit_id,
|
330
|
+
)
|
331
|
+
)
|
332
|
+
|
333
|
+
if not concurrency_limit:
|
334
|
+
raise HTTPException(
|
335
|
+
status_code=status.HTTP_404_NOT_FOUND,
|
336
|
+
detail="Concurrency limit not found",
|
337
|
+
)
|
338
|
+
|
303
339
|
result = await models.deployments.update_deployment(
|
304
|
-
session=session,
|
340
|
+
session=session,
|
341
|
+
deployment_id=deployment_id,
|
342
|
+
deployment=deployment,
|
305
343
|
)
|
306
344
|
|
307
345
|
for schedule in schedules_to_patch:
|
prefect/workers/base.py
CHANGED
@@ -48,6 +48,7 @@ from prefect.client.schemas.objects import (
|
|
48
48
|
WorkPool,
|
49
49
|
)
|
50
50
|
from prefect.client.utilities import inject_client
|
51
|
+
from prefect.context import FlowRunContext, TagsContext
|
51
52
|
from prefect.events import Event, RelatedResource, emit_event
|
52
53
|
from prefect.events.related import object_as_related_resource, tags_as_related_resources
|
53
54
|
from prefect.exceptions import (
|
@@ -75,6 +76,7 @@ from prefect.states import (
|
|
75
76
|
Pending,
|
76
77
|
exception_to_failed_state,
|
77
78
|
)
|
79
|
+
from prefect.tasks import Task
|
78
80
|
from prefect.types import KeyValueLabels
|
79
81
|
from prefect.utilities.dispatch import get_registry_for_type, register_base_type
|
80
82
|
from prefect.utilities.engine import propose_state
|
@@ -775,12 +777,28 @@ class BaseWorker(abc.ABC, Generic[C, V, R]):
|
|
775
777
|
)
|
776
778
|
|
777
779
|
job_variables = (job_variables or {}) | {"command": " ".join(execute_command)}
|
780
|
+
parameters = parameters or {}
|
781
|
+
parent_task_run = None
|
782
|
+
|
783
|
+
if flow_run_ctx := FlowRunContext.get():
|
784
|
+
parent_task = Task[Any, Any](
|
785
|
+
name=flow.name,
|
786
|
+
fn=flow.fn,
|
787
|
+
version=flow.version,
|
788
|
+
)
|
789
|
+
parent_task_run = await parent_task.create_run(
|
790
|
+
flow_run_context=flow_run_ctx,
|
791
|
+
parameters=parameters,
|
792
|
+
)
|
793
|
+
|
778
794
|
flow_run = await self.client.create_flow_run(
|
779
795
|
flow,
|
780
|
-
parameters=parameters,
|
796
|
+
parameters=flow.serialize_parameters(parameters),
|
781
797
|
state=Pending(),
|
782
798
|
job_variables=job_variables,
|
783
799
|
work_pool_name=self.work_pool.name,
|
800
|
+
tags=TagsContext.get().current_tags,
|
801
|
+
parent_task_run_id=getattr(parent_task_run, "id", None),
|
784
802
|
)
|
785
803
|
if task_status is not None:
|
786
804
|
# Emit the flow run object to .submit to allow it to return a future as soon as possible
|
@@ -1,7 +1,7 @@
|
|
1
1
|
prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
|
2
2
|
prefect/__init__.py,sha256=iCdcC5ZmeewikCdnPEP6YBAjPNV5dvfxpYCTpw30Hkw,3685
|
3
3
|
prefect/__main__.py,sha256=WFjw3kaYJY6pOTA7WDOgqjsz8zUEUZHCcj3P5wyVa-g,66
|
4
|
-
prefect/_build_info.py,sha256=
|
4
|
+
prefect/_build_info.py,sha256=zUk4_brUMO3gk7qftKtl1X8H2yE2LpC3NTQ0fZgfi9E,185
|
5
5
|
prefect/_result_records.py,sha256=S6QmsODkehGVSzbMm6ig022PYbI6gNKz671p_8kBYx4,7789
|
6
6
|
prefect/_versioning.py,sha256=4zp4Dl9dJWsoItj4AAhRxYtP3CMdo-7nG0dyv3Xz4nU,5361
|
7
7
|
prefect/_waiters.py,sha256=Ia2ITaXdHzevtyWIgJoOg95lrEXQqNEOquHvw3T33UQ,9026
|
@@ -32,8 +32,9 @@ prefect/tasks.py,sha256=EpMw5O1B9pAFVraC0KzytMOKi8iy7ZYnKWRs7WtvogU,74742
|
|
32
32
|
prefect/transactions.py,sha256=uIoPNudzJzH6NrMJhrgr5lyh6JxOJQqT1GvrXt69yNw,26068
|
33
33
|
prefect/variables.py,sha256=dCK3vX7TbkqXZhnNT_v7rcGh3ISRqoR6pJVLpoll3Js,8342
|
34
34
|
prefect/_experimental/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
|
-
prefect/_experimental/bundles.py,sha256=E5nRaLVTbYCrACXZcRJCd4ssOcQU-Z26ewCb_7tPeTM,6687
|
36
35
|
prefect/_experimental/lineage.py,sha256=8LssReoq7eLtQScUCu-7FCtrWoRZstXKRdpO0PxgbKg,9958
|
36
|
+
prefect/_experimental/bundles/__init__.py,sha256=9e7L7drTpHG82fnr6kuABkpk3SdqUNF-8HB2y6vD5U4,7108
|
37
|
+
prefect/_experimental/bundles/execute.py,sha256=xBwk1H1Fui1lt2G7Fgd6yDArqSmqZiYEA7Y7R4f7SDM,699
|
37
38
|
prefect/_experimental/sla/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
39
|
prefect/_experimental/sla/client.py,sha256=XTkYHFZiBy_O7RgUyGEdl9MxaHP-6fEAKBk3ksNQobU,3611
|
39
40
|
prefect/_experimental/sla/objects.py,sha256=Ja1z2XUgkklvtNTumKWWjojEM5I0L_RjdGv61sRbVP0,2834
|
@@ -206,7 +207,7 @@ prefect/server/api/concurrency_limits.py,sha256=E5TB2cJPIZjnxnm1pGxUJnwMDz5CS58g
|
|
206
207
|
prefect/server/api/concurrency_limits_v2.py,sha256=PGjG7W2Z65OojNTP0ezFu2z69plXo1N8paqwHlHAPj0,10183
|
207
208
|
prefect/server/api/csrf_token.py,sha256=BwysSjQAhre7O0OY_LF3ZcIiO53FdMQroNT11Q6OcOM,1344
|
208
209
|
prefect/server/api/dependencies.py,sha256=VujfcIGn41TGJxUunFHVabY5hE-6nY6uSHyhNFj8PdI,6634
|
209
|
-
prefect/server/api/deployments.py,sha256=
|
210
|
+
prefect/server/api/deployments.py,sha256=ppYA3b2csnw32-SbOXz5Dm_IsnmPKczNiSbqCzusFKI,39332
|
210
211
|
prefect/server/api/events.py,sha256=3-Qdt6ORxFv3nLoogQqvd72zEulJSoAmcqZto2OULuk,9907
|
211
212
|
prefect/server/api/flow_run_notification_policies.py,sha256=F8xNm6bgZTC3nFe9xCUJS4NlU9tLXZ8fShtJqmhT2m4,4828
|
212
213
|
prefect/server/api/flow_run_states.py,sha256=lIdxVE9CqLgtDCuH9bTaKkzHNL81FPrr11liPzvONrw,1661
|
@@ -312,13 +313,13 @@ prefect/utilities/schema_tools/__init__.py,sha256=At3rMHd2g_Em2P3_dFQlFgqR_EpBwr
|
|
312
313
|
prefect/utilities/schema_tools/hydration.py,sha256=NkRhWkNfxxFmVGhNDfmxdK_xeKaEhs3a42q83Sg9cT4,9436
|
313
314
|
prefect/utilities/schema_tools/validation.py,sha256=Wix26IVR-ZJ32-6MX2pHhrwm3reB-Q4iB6_phn85OKE,10743
|
314
315
|
prefect/workers/__init__.py,sha256=EaM1F0RZ-XIJaGeTKLsXDnfOPHzVWk5bk0_c4BVS44M,64
|
315
|
-
prefect/workers/base.py,sha256=
|
316
|
+
prefect/workers/base.py,sha256=B3K80V-bZ1oI-5iwM2jw93is9srTSCLNN2lvVtlmB7g,60267
|
316
317
|
prefect/workers/block.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
|
317
318
|
prefect/workers/cloud.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
|
318
319
|
prefect/workers/process.py,sha256=Yi5D0U5AQ51wHT86GdwtImXSefe0gJf3LGq4r4z9zwM,11090
|
319
320
|
prefect/workers/server.py,sha256=2pmVeJZiVbEK02SO6BEZaBIvHMsn6G8LzjW8BXyiTtk,1952
|
320
321
|
prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
|
321
|
-
prefect_client-3.3.6.
|
322
|
-
prefect_client-3.3.6.
|
323
|
-
prefect_client-3.3.6.
|
324
|
-
prefect_client-3.3.6.
|
322
|
+
prefect_client-3.3.6.dev4.dist-info/METADATA,sha256=RsEw_afSzFcD5K033alWN4wcgZBKx3xYewDGIk6R5hE,7471
|
323
|
+
prefect_client-3.3.6.dev4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
324
|
+
prefect_client-3.3.6.dev4.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
|
325
|
+
prefect_client-3.3.6.dev4.dist-info/RECORD,,
|
File without changes
|
{prefect_client-3.3.6.dev3.dist-info → prefect_client-3.3.6.dev4.dist-info}/licenses/LICENSE
RENAMED
File without changes
|