prefect-client 3.1.4__py3-none-any.whl → 3.1.5__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/_internal/schemas/bases.py +1 -4
- prefect/_version.py +3 -3
- prefect/client/orchestration.py +25 -5
- prefect/client/schemas/actions.py +17 -12
- prefect/client/schemas/filters.py +5 -0
- prefect/client/schemas/objects.py +5 -6
- prefect/client/schemas/responses.py +3 -0
- prefect/concurrency/services.py +3 -0
- prefect/flow_engine.py +707 -130
- prefect/settings/sources.py +9 -2
- prefect/types/__init__.py +22 -2
- prefect/workers/base.py +3 -2
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.5.dist-info}/METADATA +2 -4
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.5.dist-info}/RECORD +17 -17
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.5.dist-info}/WHEEL +1 -1
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.5.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.4.dist-info → prefect_client-3.1.5.dist-info}/top_level.txt +0 -0
@@ -84,12 +84,9 @@ class PrefectBaseModel(BaseModel):
|
|
84
84
|
Returns:
|
85
85
|
PrefectBaseModel: A new instance of the model with the reset fields.
|
86
86
|
"""
|
87
|
-
data = self.model_dump()
|
88
87
|
return self.model_copy(
|
89
88
|
update={
|
90
|
-
field: self.model_fields[field].get_default(
|
91
|
-
call_default_factory=True, validated_data=data
|
92
|
-
)
|
89
|
+
field: self.model_fields[field].get_default(call_default_factory=True)
|
93
90
|
for field in self._reset_fields
|
94
91
|
}
|
95
92
|
)
|
prefect/_version.py
CHANGED
@@ -8,11 +8,11 @@ import json
|
|
8
8
|
|
9
9
|
version_json = '''
|
10
10
|
{
|
11
|
-
"date": "2024-
|
11
|
+
"date": "2024-12-02T18:57:11-0600",
|
12
12
|
"dirty": true,
|
13
13
|
"error": null,
|
14
|
-
"full-revisionid": "
|
15
|
-
"version": "3.1.
|
14
|
+
"full-revisionid": "3c06654ec8be4f9e9bf5c304814f163b7727d28e",
|
15
|
+
"version": "3.1.5"
|
16
16
|
}
|
17
17
|
''' # END VERSION_JSON
|
18
18
|
|
prefect/client/orchestration.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import asyncio
|
2
2
|
import datetime
|
3
|
+
import ssl
|
3
4
|
import warnings
|
4
5
|
from contextlib import AsyncExitStack
|
5
6
|
from typing import (
|
@@ -283,12 +284,18 @@ class PrefectClient:
|
|
283
284
|
httpx_settings.setdefault("headers", {})
|
284
285
|
|
285
286
|
if PREFECT_API_TLS_INSECURE_SKIP_VERIFY:
|
286
|
-
|
287
|
+
# Create an unverified context for insecure connections
|
288
|
+
ctx = ssl.create_default_context()
|
289
|
+
ctx.check_hostname = False
|
290
|
+
ctx.verify_mode = ssl.CERT_NONE
|
291
|
+
httpx_settings.setdefault("verify", ctx)
|
287
292
|
else:
|
288
293
|
cert_file = PREFECT_API_SSL_CERT_FILE.value()
|
289
294
|
if not cert_file:
|
290
295
|
cert_file = certifi.where()
|
291
|
-
|
296
|
+
# Create a verified context with the certificate file
|
297
|
+
ctx = ssl.create_default_context(cafile=cert_file)
|
298
|
+
httpx_settings.setdefault("verify", ctx)
|
292
299
|
|
293
300
|
if api_version is None:
|
294
301
|
api_version = SERVER_API_VERSION
|
@@ -2209,6 +2216,13 @@ class PrefectClient:
|
|
2209
2216
|
response.json()
|
2210
2217
|
)
|
2211
2218
|
|
2219
|
+
async def set_flow_run_name(self, flow_run_id: UUID, name: str):
|
2220
|
+
flow_run_data = FlowRunUpdate(name=name)
|
2221
|
+
return await self._client.patch(
|
2222
|
+
f"/flow_runs/{flow_run_id}",
|
2223
|
+
json=flow_run_data.model_dump(mode="json", exclude_unset=True),
|
2224
|
+
)
|
2225
|
+
|
2212
2226
|
async def set_task_run_name(self, task_run_id: UUID, name: str):
|
2213
2227
|
task_run_data = TaskRunUpdate(name=name)
|
2214
2228
|
return await self._client.patch(
|
@@ -3534,12 +3548,18 @@ class SyncPrefectClient:
|
|
3534
3548
|
httpx_settings.setdefault("headers", {})
|
3535
3549
|
|
3536
3550
|
if PREFECT_API_TLS_INSECURE_SKIP_VERIFY:
|
3537
|
-
|
3551
|
+
# Create an unverified context for insecure connections
|
3552
|
+
ctx = ssl.create_default_context()
|
3553
|
+
ctx.check_hostname = False
|
3554
|
+
ctx.verify_mode = ssl.CERT_NONE
|
3555
|
+
httpx_settings.setdefault("verify", ctx)
|
3538
3556
|
else:
|
3539
3557
|
cert_file = PREFECT_API_SSL_CERT_FILE.value()
|
3540
3558
|
if not cert_file:
|
3541
3559
|
cert_file = certifi.where()
|
3542
|
-
|
3560
|
+
# Create a verified context with the certificate file
|
3561
|
+
ctx = ssl.create_default_context(cafile=cert_file)
|
3562
|
+
httpx_settings.setdefault("verify", ctx)
|
3543
3563
|
|
3544
3564
|
if api_version is None:
|
3545
3565
|
api_version = SERVER_API_VERSION
|
@@ -4019,7 +4039,7 @@ class SyncPrefectClient:
|
|
4019
4039
|
return OrchestrationResult.model_validate(response.json())
|
4020
4040
|
|
4021
4041
|
def set_flow_run_name(self, flow_run_id: UUID, name: str):
|
4022
|
-
flow_run_data =
|
4042
|
+
flow_run_data = FlowRunUpdate(name=name)
|
4023
4043
|
return self._client.patch(
|
4024
4044
|
f"/flow_runs/{flow_run_id}",
|
4025
4045
|
json=flow_run_data.model_dump(mode="json", exclude_unset=True),
|
@@ -27,6 +27,7 @@ from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
|
27
27
|
from prefect.settings import PREFECT_DEPLOYMENT_SCHEDULE_MAX_SCHEDULED_RUNS
|
28
28
|
from prefect.types import (
|
29
29
|
MAX_VARIABLE_NAME_LENGTH,
|
30
|
+
KeyValueLabelsField,
|
30
31
|
Name,
|
31
32
|
NonEmptyishName,
|
32
33
|
NonNegativeFloat,
|
@@ -66,6 +67,7 @@ class FlowCreate(ActionBaseModel):
|
|
66
67
|
description="A list of flow tags",
|
67
68
|
examples=[["tag-1", "tag-2"]],
|
68
69
|
)
|
70
|
+
labels: KeyValueLabelsField
|
69
71
|
|
70
72
|
|
71
73
|
class FlowUpdate(ActionBaseModel):
|
@@ -159,6 +161,7 @@ class DeploymentCreate(ActionBaseModel):
|
|
159
161
|
description="Parameters for flow runs scheduled by the deployment.",
|
160
162
|
)
|
161
163
|
tags: List[str] = Field(default_factory=list)
|
164
|
+
labels: KeyValueLabelsField
|
162
165
|
pull_steps: Optional[List[dict]] = Field(None)
|
163
166
|
|
164
167
|
work_queue_name: Optional[str] = Field(None)
|
@@ -315,6 +318,7 @@ class TaskRunCreate(ActionBaseModel):
|
|
315
318
|
default_factory=objects.TaskRunPolicy,
|
316
319
|
)
|
317
320
|
tags: List[str] = Field(default_factory=list)
|
321
|
+
labels: KeyValueLabelsField
|
318
322
|
task_inputs: Dict[
|
319
323
|
str,
|
320
324
|
List[
|
@@ -357,6 +361,7 @@ class FlowRunCreate(ActionBaseModel):
|
|
357
361
|
default_factory=objects.FlowRunPolicy
|
358
362
|
)
|
359
363
|
tags: List[str] = Field(default_factory=list)
|
364
|
+
labels: KeyValueLabelsField
|
360
365
|
idempotency_key: Optional[str] = Field(None)
|
361
366
|
|
362
367
|
|
@@ -697,23 +702,23 @@ class FlowRunNotificationPolicyCreate(ActionBaseModel):
|
|
697
702
|
class FlowRunNotificationPolicyUpdate(ActionBaseModel):
|
698
703
|
"""Data used by the Prefect REST API to update a flow run notification policy."""
|
699
704
|
|
700
|
-
is_active: Optional[bool] = Field(None)
|
701
|
-
state_names: Optional[List[str]] = Field(None)
|
702
|
-
tags: Optional[List[str]] = Field(None)
|
703
|
-
block_document_id: Optional[UUID] = Field(None)
|
704
|
-
message_template: Optional[str] = Field(None)
|
705
|
+
is_active: Optional[bool] = Field(default=None)
|
706
|
+
state_names: Optional[List[str]] = Field(default=None)
|
707
|
+
tags: Optional[List[str]] = Field(default=None)
|
708
|
+
block_document_id: Optional[UUID] = Field(default=None)
|
709
|
+
message_template: Optional[str] = Field(default=None)
|
705
710
|
|
706
711
|
|
707
712
|
class ArtifactCreate(ActionBaseModel):
|
708
713
|
"""Data used by the Prefect REST API to create an artifact."""
|
709
714
|
|
710
|
-
key: Optional[str] = Field(None)
|
711
|
-
type: Optional[str] = Field(None)
|
712
|
-
description: Optional[str] = Field(None)
|
713
|
-
data: Optional[Union[Dict[str, Any], Any]] = Field(None)
|
714
|
-
metadata_: Optional[Dict[str, str]] = Field(None)
|
715
|
-
flow_run_id: Optional[UUID] = Field(None)
|
716
|
-
task_run_id: Optional[UUID] = Field(None)
|
715
|
+
key: Optional[str] = Field(default=None)
|
716
|
+
type: Optional[str] = Field(default=None)
|
717
|
+
description: Optional[str] = Field(default=None)
|
718
|
+
data: Optional[Union[Dict[str, Any], Any]] = Field(default=None)
|
719
|
+
metadata_: Optional[Dict[str, str]] = Field(default=None)
|
720
|
+
flow_run_id: Optional[UUID] = Field(default=None)
|
721
|
+
task_run_id: Optional[UUID] = Field(default=None)
|
717
722
|
|
718
723
|
_validate_artifact_format = field_validator("key")(validate_artifact_key)
|
719
724
|
|
@@ -129,6 +129,11 @@ class FlowRunFilterTags(PrefectBaseModel, OperatorMixin):
|
|
129
129
|
" superset of the list"
|
130
130
|
),
|
131
131
|
)
|
132
|
+
any_: Optional[List[str]] = Field(
|
133
|
+
default=None,
|
134
|
+
examples=[["tag-1", "tag-2"]],
|
135
|
+
description="A list of tags to include",
|
136
|
+
)
|
132
137
|
is_null_: Optional[bool] = Field(
|
133
138
|
default=None, description="If true, only include flow runs without tags"
|
134
139
|
)
|
@@ -53,7 +53,7 @@ from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
|
53
53
|
from prefect.settings import PREFECT_CLOUD_API_URL, PREFECT_CLOUD_UI_URL
|
54
54
|
from prefect.types import (
|
55
55
|
MAX_VARIABLE_NAME_LENGTH,
|
56
|
-
|
56
|
+
KeyValueLabelsField,
|
57
57
|
Name,
|
58
58
|
NonNegativeInteger,
|
59
59
|
PositiveInteger,
|
@@ -559,11 +559,7 @@ class FlowRun(ObjectBaseModel):
|
|
559
559
|
description="A list of tags on the flow run",
|
560
560
|
examples=[["tag-1", "tag-2"]],
|
561
561
|
)
|
562
|
-
labels:
|
563
|
-
default_factory=dict,
|
564
|
-
description="Prefect Cloud: A dictionary of key-value labels. Values can be strings, numbers, or booleans.",
|
565
|
-
examples=[{"key": "value1", "key2": 42}],
|
566
|
-
)
|
562
|
+
labels: KeyValueLabelsField
|
567
563
|
parent_task_run_id: Optional[UUID] = Field(
|
568
564
|
default=None,
|
569
565
|
description=(
|
@@ -800,6 +796,7 @@ class TaskRun(ObjectBaseModel):
|
|
800
796
|
description="A list of tags for the task run.",
|
801
797
|
examples=[["tag-1", "tag-2"]],
|
802
798
|
)
|
799
|
+
labels: KeyValueLabelsField
|
803
800
|
state_id: Optional[UUID] = Field(
|
804
801
|
default=None, description="The id of the current task run state."
|
805
802
|
)
|
@@ -1055,6 +1052,7 @@ class Flow(ObjectBaseModel):
|
|
1055
1052
|
description="A list of flow tags",
|
1056
1053
|
examples=[["tag-1", "tag-2"]],
|
1057
1054
|
)
|
1055
|
+
labels: KeyValueLabelsField
|
1058
1056
|
|
1059
1057
|
|
1060
1058
|
class DeploymentSchedule(ObjectBaseModel):
|
@@ -1113,6 +1111,7 @@ class Deployment(ObjectBaseModel):
|
|
1113
1111
|
description="A list of tags for the deployment",
|
1114
1112
|
examples=[["tag-1", "tag-2"]],
|
1115
1113
|
)
|
1114
|
+
labels: KeyValueLabelsField
|
1116
1115
|
work_queue_name: Optional[str] = Field(
|
1117
1116
|
default=None,
|
1118
1117
|
description=(
|
@@ -9,6 +9,7 @@ from typing_extensions import Literal
|
|
9
9
|
import prefect.client.schemas.objects as objects
|
10
10
|
from prefect._internal.schemas.bases import ObjectBaseModel, PrefectBaseModel
|
11
11
|
from prefect._internal.schemas.fields import CreatedBy, UpdatedBy
|
12
|
+
from prefect.types import KeyValueLabelsField
|
12
13
|
from prefect.utilities.collections import AutoEnum
|
13
14
|
from prefect.utilities.names import generate_slug
|
14
15
|
|
@@ -201,6 +202,7 @@ class FlowRunResponse(ObjectBaseModel):
|
|
201
202
|
description="A list of tags on the flow run",
|
202
203
|
examples=[["tag-1", "tag-2"]],
|
203
204
|
)
|
205
|
+
labels: KeyValueLabelsField
|
204
206
|
parent_task_run_id: Optional[UUID] = Field(
|
205
207
|
default=None,
|
206
208
|
description=(
|
@@ -353,6 +355,7 @@ class DeploymentResponse(ObjectBaseModel):
|
|
353
355
|
description="A list of tags for the deployment",
|
354
356
|
examples=[["tag-1", "tag-2"]],
|
355
357
|
)
|
358
|
+
labels: KeyValueLabelsField
|
356
359
|
work_queue_name: Optional[str] = Field(
|
357
360
|
default=None,
|
358
361
|
description=(
|
prefect/concurrency/services.py
CHANGED
@@ -83,6 +83,9 @@ class ConcurrencySlotAcquisitionService(QueueService):
|
|
83
83
|
if max_retries is not None and max_retries <= 0:
|
84
84
|
raise exc
|
85
85
|
retry_after = float(exc.response.headers["Retry-After"])
|
86
|
+
logger.debug(
|
87
|
+
f"Unable to acquire concurrency slot. Retrying in {retry_after} second(s)."
|
88
|
+
)
|
86
89
|
await asyncio.sleep(retry_after)
|
87
90
|
if max_retries is not None:
|
88
91
|
max_retries -= 1
|