prefect-client 3.1.3__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/_version.py +3 -3
- prefect/client/cloud.py +1 -1
- prefect/client/orchestration.py +32 -12
- prefect/client/schemas/actions.py +17 -12
- prefect/client/schemas/filters.py +5 -0
- prefect/client/schemas/objects.py +5 -31
- prefect/client/schemas/responses.py +3 -0
- prefect/concurrency/services.py +3 -0
- prefect/deployments/runner.py +2 -1
- prefect/flow_engine.py +707 -130
- prefect/settings/sources.py +9 -2
- prefect/types/__init__.py +40 -3
- prefect/workers/base.py +3 -2
- {prefect_client-3.1.3.dist-info → prefect_client-3.1.5.dist-info}/METADATA +2 -4
- {prefect_client-3.1.3.dist-info → prefect_client-3.1.5.dist-info}/RECORD +18 -18
- {prefect_client-3.1.3.dist-info → prefect_client-3.1.5.dist-info}/WHEEL +1 -1
- {prefect_client-3.1.3.dist-info → prefect_client-3.1.5.dist-info}/LICENSE +0 -0
- {prefect_client-3.1.3.dist-info → prefect_client-3.1.5.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-
|
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/cloud.py
CHANGED
@@ -13,7 +13,6 @@ from prefect.client.base import PrefectHttpxAsyncClient
|
|
13
13
|
from prefect.client.schemas.objects import (
|
14
14
|
IPAllowlist,
|
15
15
|
IPAllowlistMyAccessResponse,
|
16
|
-
KeyValueLabels,
|
17
16
|
Workspace,
|
18
17
|
)
|
19
18
|
from prefect.exceptions import ObjectNotFound, PrefectException
|
@@ -23,6 +22,7 @@ from prefect.settings import (
|
|
23
22
|
PREFECT_CLOUD_API_URL,
|
24
23
|
PREFECT_TESTING_UNIT_TEST_MODE,
|
25
24
|
)
|
25
|
+
from prefect.types import KeyValueLabels
|
26
26
|
|
27
27
|
PARSE_API_URL_REGEX = re.compile(r"accounts/(.{36})/workspaces/(.{36})")
|
28
28
|
|
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
|
@@ -3925,13 +3945,13 @@ class SyncPrefectClient:
|
|
3925
3945
|
def read_flow_runs(
|
3926
3946
|
self,
|
3927
3947
|
*,
|
3928
|
-
flow_filter: FlowFilter = None,
|
3929
|
-
flow_run_filter: FlowRunFilter = None,
|
3930
|
-
task_run_filter: TaskRunFilter = None,
|
3931
|
-
deployment_filter: DeploymentFilter = None,
|
3932
|
-
work_pool_filter: WorkPoolFilter = None,
|
3933
|
-
work_queue_filter: WorkQueueFilter = None,
|
3934
|
-
sort: FlowRunSort = None,
|
3948
|
+
flow_filter: Optional[FlowFilter] = None,
|
3949
|
+
flow_run_filter: Optional[FlowRunFilter] = None,
|
3950
|
+
task_run_filter: Optional[TaskRunFilter] = None,
|
3951
|
+
deployment_filter: Optional[DeploymentFilter] = None,
|
3952
|
+
work_pool_filter: Optional[WorkPoolFilter] = None,
|
3953
|
+
work_queue_filter: Optional[WorkQueueFilter] = None,
|
3954
|
+
sort: Optional[FlowRunSort] = None,
|
3935
3955
|
limit: Optional[int] = None,
|
3936
3956
|
offset: int = 0,
|
3937
3957
|
) -> List[FlowRun]:
|
@@ -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
|
)
|
@@ -23,9 +23,6 @@ from pydantic import (
|
|
23
23
|
HttpUrl,
|
24
24
|
IPvAnyNetwork,
|
25
25
|
SerializationInfo,
|
26
|
-
StrictBool,
|
27
|
-
StrictFloat,
|
28
|
-
StrictInt,
|
29
26
|
Tag,
|
30
27
|
field_validator,
|
31
28
|
model_serializer,
|
@@ -56,6 +53,7 @@ from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
|
56
53
|
from prefect.settings import PREFECT_CLOUD_API_URL, PREFECT_CLOUD_UI_URL
|
57
54
|
from prefect.types import (
|
58
55
|
MAX_VARIABLE_NAME_LENGTH,
|
56
|
+
KeyValueLabelsField,
|
59
57
|
Name,
|
60
58
|
NonNegativeInteger,
|
61
59
|
PositiveInteger,
|
@@ -71,8 +69,6 @@ if TYPE_CHECKING:
|
|
71
69
|
|
72
70
|
R = TypeVar("R", default=Any)
|
73
71
|
|
74
|
-
KeyValueLabels = dict[str, Union[StrictBool, StrictInt, StrictFloat, str]]
|
75
|
-
|
76
72
|
|
77
73
|
DEFAULT_BLOCK_SCHEMA_VERSION = "non-versioned"
|
78
74
|
DEFAULT_AGENT_WORK_POOL_NAME = "default-agent-pool"
|
@@ -563,11 +559,7 @@ class FlowRun(ObjectBaseModel):
|
|
563
559
|
description="A list of tags on the flow run",
|
564
560
|
examples=[["tag-1", "tag-2"]],
|
565
561
|
)
|
566
|
-
labels:
|
567
|
-
default_factory=dict,
|
568
|
-
description="Prefect Cloud: A dictionary of key-value labels. Values can be strings, numbers, or booleans.",
|
569
|
-
examples=[{"key": "value1", "key2": 42}],
|
570
|
-
)
|
562
|
+
labels: KeyValueLabelsField
|
571
563
|
parent_task_run_id: Optional[UUID] = Field(
|
572
564
|
default=None,
|
573
565
|
description=(
|
@@ -804,6 +796,7 @@ class TaskRun(ObjectBaseModel):
|
|
804
796
|
description="A list of tags for the task run.",
|
805
797
|
examples=[["tag-1", "tag-2"]],
|
806
798
|
)
|
799
|
+
labels: KeyValueLabelsField
|
807
800
|
state_id: Optional[UUID] = Field(
|
808
801
|
default=None, description="The id of the current task run state."
|
809
802
|
)
|
@@ -1059,6 +1052,7 @@ class Flow(ObjectBaseModel):
|
|
1059
1052
|
description="A list of flow tags",
|
1060
1053
|
examples=[["tag-1", "tag-2"]],
|
1061
1054
|
)
|
1055
|
+
labels: KeyValueLabelsField
|
1062
1056
|
|
1063
1057
|
|
1064
1058
|
class DeploymentSchedule(ObjectBaseModel):
|
@@ -1117,6 +1111,7 @@ class Deployment(ObjectBaseModel):
|
|
1117
1111
|
description="A list of tags for the deployment",
|
1118
1112
|
examples=[["tag-1", "tag-2"]],
|
1119
1113
|
)
|
1114
|
+
labels: KeyValueLabelsField
|
1120
1115
|
work_queue_name: Optional[str] = Field(
|
1121
1116
|
default=None,
|
1122
1117
|
description=(
|
@@ -1188,27 +1183,6 @@ class ConcurrencyLimit(ObjectBaseModel):
|
|
1188
1183
|
)
|
1189
1184
|
|
1190
1185
|
|
1191
|
-
class BlockSchema(ObjectBaseModel):
|
1192
|
-
"""An ORM representation of a block schema."""
|
1193
|
-
|
1194
|
-
checksum: str = Field(default=..., description="The block schema's unique checksum")
|
1195
|
-
fields: Dict[str, Any] = Field(
|
1196
|
-
default_factory=dict, description="The block schema's field schema"
|
1197
|
-
)
|
1198
|
-
block_type_id: Optional[UUID] = Field(default=..., description="A block type ID")
|
1199
|
-
block_type: Optional[BlockType] = Field(
|
1200
|
-
default=None, description="The associated block type"
|
1201
|
-
)
|
1202
|
-
capabilities: List[str] = Field(
|
1203
|
-
default_factory=list,
|
1204
|
-
description="A list of Block capabilities",
|
1205
|
-
)
|
1206
|
-
version: str = Field(
|
1207
|
-
default=DEFAULT_BLOCK_SCHEMA_VERSION,
|
1208
|
-
description="Human readable identifier for the block schema",
|
1209
|
-
)
|
1210
|
-
|
1211
|
-
|
1212
1186
|
class BlockSchemaReference(ObjectBaseModel):
|
1213
1187
|
"""An ORM representation of a block schema reference."""
|
1214
1188
|
|
@@ -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
|
prefect/deployments/runner.py
CHANGED
@@ -77,6 +77,7 @@ from prefect.settings import (
|
|
77
77
|
PREFECT_DEFAULT_WORK_POOL_NAME,
|
78
78
|
PREFECT_UI_URL,
|
79
79
|
)
|
80
|
+
from prefect.types import ListOfNonEmptyStrings
|
80
81
|
from prefect.types.entrypoint import EntrypointType
|
81
82
|
from prefect.utilities.asyncutils import sync_compatible
|
82
83
|
from prefect.utilities.callables import ParameterSchema, parameter_schema
|
@@ -140,7 +141,7 @@ class RunnerDeployment(BaseModel):
|
|
140
141
|
version: Optional[str] = Field(
|
141
142
|
default=None, description="An optional version for the deployment."
|
142
143
|
)
|
143
|
-
tags:
|
144
|
+
tags: ListOfNonEmptyStrings = Field(
|
144
145
|
default_factory=list,
|
145
146
|
description="One of more tags to apply to this deployment.",
|
146
147
|
)
|