prefect-client 2.16.9__py3-none-any.whl → 2.17.1__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/__init__.py +0 -18
- prefect/_internal/compatibility/deprecated.py +108 -5
- prefect/_internal/pydantic/__init__.py +4 -0
- prefect/_internal/pydantic/_base_model.py +36 -4
- prefect/_internal/pydantic/_compat.py +33 -2
- prefect/_internal/pydantic/_flags.py +3 -0
- prefect/_internal/pydantic/utilities/config_dict.py +72 -0
- prefect/_internal/pydantic/utilities/field_validator.py +135 -0
- prefect/_internal/pydantic/utilities/model_fields_set.py +29 -0
- prefect/_internal/pydantic/utilities/model_validator.py +79 -0
- prefect/agent.py +1 -1
- prefect/blocks/notifications.py +18 -18
- prefect/blocks/webhook.py +1 -1
- prefect/client/base.py +7 -0
- prefect/client/orchestration.py +44 -4
- prefect/client/schemas/actions.py +27 -20
- prefect/client/schemas/filters.py +28 -28
- prefect/client/schemas/objects.py +31 -21
- prefect/client/schemas/responses.py +17 -11
- prefect/client/schemas/schedules.py +6 -8
- prefect/context.py +2 -1
- prefect/deployments/base.py +2 -10
- prefect/deployments/deployments.py +34 -9
- prefect/deployments/runner.py +2 -2
- prefect/engine.py +32 -596
- prefect/events/clients.py +45 -13
- prefect/events/filters.py +19 -2
- prefect/events/utilities.py +12 -4
- prefect/events/worker.py +26 -8
- prefect/exceptions.py +3 -8
- prefect/filesystems.py +7 -7
- prefect/flows.py +4 -3
- prefect/manifests.py +1 -8
- prefect/profiles.toml +1 -1
- prefect/pydantic/__init__.py +27 -1
- prefect/pydantic/main.py +26 -2
- prefect/settings.py +33 -10
- prefect/task_server.py +2 -2
- prefect/utilities/dispatch.py +1 -0
- prefect/utilities/engine.py +629 -0
- prefect/utilities/pydantic.py +1 -1
- prefect/utilities/visualization.py +1 -1
- prefect/variables.py +88 -12
- prefect/workers/base.py +1 -1
- prefect/workers/block.py +1 -1
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/METADATA +3 -3
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/RECORD +50 -45
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/LICENSE +0 -0
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/WHEEL +0 -0
- {prefect_client-2.16.9.dist-info → prefect_client-2.17.1.dist-info}/top_level.txt +0 -0
@@ -17,8 +17,11 @@ import pendulum
|
|
17
17
|
import yaml
|
18
18
|
|
19
19
|
from prefect._internal.compatibility.deprecated import (
|
20
|
+
DeprecatedInfraOverridesField,
|
20
21
|
deprecated_callable,
|
21
22
|
deprecated_class,
|
23
|
+
deprecated_parameter,
|
24
|
+
handle_deprecated_infra_overrides_parameter,
|
22
25
|
)
|
23
26
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
24
27
|
from prefect._internal.schemas.validators import (
|
@@ -71,6 +74,11 @@ logger = get_logger("deployments")
|
|
71
74
|
|
72
75
|
|
73
76
|
@sync_compatible
|
77
|
+
@deprecated_parameter(
|
78
|
+
"infra_overrides",
|
79
|
+
start_date="Apr 2024",
|
80
|
+
help="Use `job_variables` instead.",
|
81
|
+
)
|
74
82
|
@inject_client
|
75
83
|
async def run_deployment(
|
76
84
|
name: Union[str, UUID],
|
@@ -84,6 +92,7 @@ async def run_deployment(
|
|
84
92
|
idempotency_key: Optional[str] = None,
|
85
93
|
work_queue_name: Optional[str] = None,
|
86
94
|
as_subflow: Optional[bool] = True,
|
95
|
+
infra_overrides: Optional[dict] = None,
|
87
96
|
job_variables: Optional[dict] = None,
|
88
97
|
) -> FlowRun:
|
89
98
|
"""
|
@@ -103,7 +112,7 @@ async def run_deployment(
|
|
103
112
|
|
104
113
|
Args:
|
105
114
|
name: The deployment id or deployment name in the form:
|
106
|
-
|
115
|
+
`"flow name/deployment name"`
|
107
116
|
parameters: Parameter overrides for this flow run. Merged with the deployment
|
108
117
|
defaults.
|
109
118
|
scheduled_time: The time to schedule the flow run for, defaults to scheduling
|
@@ -122,6 +131,9 @@ async def run_deployment(
|
|
122
131
|
the default work queue for the deployment.
|
123
132
|
as_subflow: Whether to link the flow run as a subflow of the current
|
124
133
|
flow or task run.
|
134
|
+
job_variables: A dictionary of dot delimited infrastructure overrides that
|
135
|
+
will be applied at runtime; for example `env.CONFIG_KEY=config_value` or
|
136
|
+
`namespace='prefect'`
|
125
137
|
"""
|
126
138
|
if timeout is not None and timeout < 0:
|
127
139
|
raise ValueError("`timeout` cannot be negative")
|
@@ -129,6 +141,8 @@ async def run_deployment(
|
|
129
141
|
if scheduled_time is None:
|
130
142
|
scheduled_time = pendulum.now("UTC")
|
131
143
|
|
144
|
+
jv = handle_deprecated_infra_overrides_parameter(job_variables, infra_overrides)
|
145
|
+
|
132
146
|
parameters = parameters or {}
|
133
147
|
|
134
148
|
deployment_id = None
|
@@ -204,7 +218,7 @@ async def run_deployment(
|
|
204
218
|
idempotency_key=idempotency_key,
|
205
219
|
parent_task_run_id=parent_task_run_id,
|
206
220
|
work_queue_name=work_queue_name,
|
207
|
-
job_variables=
|
221
|
+
job_variables=jv,
|
208
222
|
)
|
209
223
|
|
210
224
|
flow_run_id = flow_run.id
|
@@ -334,7 +348,7 @@ def load_deployments_from_yaml(
|
|
334
348
|
" Refer to the upgrade guide for more information:"
|
335
349
|
" https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.",
|
336
350
|
)
|
337
|
-
class Deployment(BaseModel):
|
351
|
+
class Deployment(DeprecatedInfraOverridesField, BaseModel):
|
338
352
|
"""
|
339
353
|
DEPRECATION WARNING:
|
340
354
|
|
@@ -363,7 +377,7 @@ class Deployment(BaseModel):
|
|
363
377
|
infrastructure: An optional infrastructure block used to configure
|
364
378
|
infrastructure for runs; if not provided, will default to running this
|
365
379
|
deployment in Agent subprocesses
|
366
|
-
|
380
|
+
job_variables: A dictionary of dot delimited infrastructure overrides that
|
367
381
|
will be applied at runtime; for example `env.CONFIG_KEY=config_value` or
|
368
382
|
`namespace='prefect'`
|
369
383
|
storage: An optional remote storage block used to store and retrieve this
|
@@ -405,7 +419,7 @@ class Deployment(BaseModel):
|
|
405
419
|
... version="2",
|
406
420
|
... tags=["aws"],
|
407
421
|
... storage=storage,
|
408
|
-
...
|
422
|
+
... job_variables=dict("env.PREFECT_LOGGING_LEVEL"="DEBUG"),
|
409
423
|
>>> )
|
410
424
|
>>> deployment.apply()
|
411
425
|
|
@@ -429,6 +443,11 @@ class Deployment(BaseModel):
|
|
429
443
|
"schedule",
|
430
444
|
"schedules",
|
431
445
|
"is_schedule_active",
|
446
|
+
# The `infra_overrides` field has been renamed to `job_variables`.
|
447
|
+
# We will continue writing it in the YAML file as `infra_overrides`
|
448
|
+
# instead of `job_variables` for better backwards compat, but we'll
|
449
|
+
# accept either `job_variables` or `infra_overrides` when we read
|
450
|
+
# the file.
|
432
451
|
"infra_overrides",
|
433
452
|
]
|
434
453
|
|
@@ -478,10 +497,16 @@ class Deployment(BaseModel):
|
|
478
497
|
# write the field
|
479
498
|
yaml.dump({field: yaml_dict[field]}, f, sort_keys=False)
|
480
499
|
|
481
|
-
# write non-editable fields
|
500
|
+
# write non-editable fields, excluding `job_variables` because we'll
|
501
|
+
# continue writing it as `infra_overrides` for better backwards compat
|
502
|
+
# with the existing file format.
|
482
503
|
f.write("\n###\n### DO NOT EDIT BELOW THIS LINE\n###\n")
|
483
504
|
yaml.dump(
|
484
|
-
{
|
505
|
+
{
|
506
|
+
k: v
|
507
|
+
for k, v in yaml_dict.items()
|
508
|
+
if k not in self._editable_fields and k != "job_variables"
|
509
|
+
},
|
485
510
|
f,
|
486
511
|
sort_keys=False,
|
487
512
|
)
|
@@ -558,7 +583,7 @@ class Deployment(BaseModel):
|
|
558
583
|
),
|
559
584
|
)
|
560
585
|
infrastructure: Infrastructure = Field(default_factory=Process)
|
561
|
-
|
586
|
+
job_variables: Dict[str, Any] = Field(
|
562
587
|
default_factory=dict,
|
563
588
|
description="Overrides to apply to the base infrastructure block at runtime.",
|
564
589
|
)
|
@@ -869,7 +894,7 @@ class Deployment(BaseModel):
|
|
869
894
|
manifest_path=self.manifest_path, # allows for backwards YAML compat
|
870
895
|
path=self.path,
|
871
896
|
entrypoint=self.entrypoint,
|
872
|
-
|
897
|
+
job_variables=self.job_variables,
|
873
898
|
storage_document_id=storage_document_id,
|
874
899
|
infrastructure_document_id=infrastructure_document_id,
|
875
900
|
parameter_openapi_schema=self.parameter_openapi_schema.dict(),
|
prefect/deployments/runner.py
CHANGED
@@ -306,9 +306,9 @@ class RunnerDeployment(BaseModel):
|
|
306
306
|
)
|
307
307
|
|
308
308
|
if work_pool_name:
|
309
|
-
create_payload["
|
309
|
+
create_payload["job_variables"] = self.job_variables
|
310
310
|
if image:
|
311
|
-
create_payload["
|
311
|
+
create_payload["job_variables"]["image"] = image
|
312
312
|
create_payload["path"] = None if self.storage else self._path
|
313
313
|
create_payload["pull_steps"] = (
|
314
314
|
[self.storage.to_pull_step()] if self.storage else []
|