prefect-client 2.16.8__py3-none-any.whl → 2.17.0__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/compatibility/experimental.py +9 -8
- prefect/_internal/concurrency/api.py +23 -42
- prefect/_internal/concurrency/waiters.py +25 -22
- prefect/_internal/pydantic/__init__.py +16 -3
- prefect/_internal/pydantic/_base_model.py +39 -4
- prefect/_internal/pydantic/_compat.py +69 -452
- prefect/_internal/pydantic/_flags.py +5 -0
- prefect/_internal/pydantic/_types.py +8 -0
- prefect/_internal/pydantic/utilities/__init__.py +0 -0
- prefect/_internal/pydantic/utilities/config_dict.py +72 -0
- prefect/_internal/pydantic/utilities/field_validator.py +135 -0
- prefect/_internal/pydantic/utilities/model_construct.py +56 -0
- prefect/_internal/pydantic/utilities/model_copy.py +55 -0
- prefect/_internal/pydantic/utilities/model_dump.py +136 -0
- prefect/_internal/pydantic/utilities/model_dump_json.py +112 -0
- prefect/_internal/pydantic/utilities/model_fields.py +50 -0
- prefect/_internal/pydantic/utilities/model_fields_set.py +29 -0
- prefect/_internal/pydantic/utilities/model_json_schema.py +82 -0
- prefect/_internal/pydantic/utilities/model_rebuild.py +80 -0
- prefect/_internal/pydantic/utilities/model_validate.py +75 -0
- prefect/_internal/pydantic/utilities/model_validate_json.py +68 -0
- prefect/_internal/pydantic/utilities/model_validator.py +79 -0
- prefect/_internal/pydantic/utilities/type_adapter.py +71 -0
- prefect/_internal/schemas/bases.py +1 -17
- prefect/_internal/schemas/validators.py +425 -4
- prefect/agent.py +1 -1
- prefect/blocks/kubernetes.py +7 -3
- prefect/blocks/notifications.py +18 -18
- prefect/blocks/webhook.py +1 -1
- prefect/client/base.py +7 -0
- prefect/client/cloud.py +1 -1
- prefect/client/orchestration.py +51 -11
- prefect/client/schemas/actions.py +367 -297
- prefect/client/schemas/filters.py +28 -28
- prefect/client/schemas/objects.py +78 -147
- prefect/client/schemas/responses.py +240 -60
- prefect/client/schemas/schedules.py +6 -8
- prefect/concurrency/events.py +2 -2
- prefect/context.py +4 -2
- prefect/deployments/base.py +6 -13
- prefect/deployments/deployments.py +34 -9
- prefect/deployments/runner.py +9 -27
- prefect/deprecated/packaging/base.py +5 -6
- prefect/deprecated/packaging/docker.py +19 -25
- prefect/deprecated/packaging/file.py +10 -5
- prefect/deprecated/packaging/orion.py +9 -4
- prefect/deprecated/packaging/serializers.py +8 -58
- prefect/engine.py +55 -618
- prefect/events/actions.py +16 -1
- prefect/events/clients.py +45 -13
- prefect/events/filters.py +19 -2
- prefect/events/related.py +4 -4
- prefect/events/schemas/automations.py +13 -2
- prefect/events/schemas/deployment_triggers.py +73 -5
- prefect/events/schemas/events.py +1 -1
- 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 +7 -3
- prefect/infrastructure/provisioners/ecs.py +1 -0
- prefect/logging/configuration.py +2 -2
- prefect/manifests.py +1 -8
- prefect/profiles.toml +1 -1
- prefect/pydantic/__init__.py +74 -2
- prefect/pydantic/main.py +26 -2
- prefect/serializers.py +6 -31
- prefect/settings.py +72 -26
- prefect/software/python.py +3 -5
- prefect/task_server.py +2 -2
- prefect/utilities/callables.py +1 -1
- prefect/utilities/collections.py +2 -1
- prefect/utilities/dispatch.py +1 -0
- prefect/utilities/engine.py +629 -0
- prefect/utilities/pydantic.py +1 -1
- prefect/utilities/schema_tools/validation.py +2 -2
- prefect/utilities/visualization.py +1 -1
- prefect/variables.py +88 -12
- prefect/workers/base.py +20 -11
- prefect/workers/block.py +4 -8
- prefect/workers/process.py +2 -5
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/METADATA +4 -3
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/RECORD +88 -72
- prefect/_internal/schemas/transformations.py +0 -106
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/LICENSE +0 -0
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/WHEEL +0 -0
- {prefect_client-2.16.8.dist-info → prefect_client-2.17.0.dist-info}/top_level.txt +0 -0
@@ -15,6 +15,9 @@ from uuid import UUID
|
|
15
15
|
import orjson
|
16
16
|
import pendulum
|
17
17
|
|
18
|
+
from prefect._internal.compatibility.deprecated import (
|
19
|
+
DeprecatedInfraOverridesField,
|
20
|
+
)
|
18
21
|
from prefect._internal.pydantic import HAS_PYDANTIC_V2
|
19
22
|
|
20
23
|
if HAS_PYDANTIC_V2:
|
@@ -29,8 +32,16 @@ from prefect._internal.schemas.fields import CreatedBy, DateTimeTZ, UpdatedBy
|
|
29
32
|
from prefect._internal.schemas.validators import (
|
30
33
|
get_or_create_run_name,
|
31
34
|
get_or_create_state_name,
|
35
|
+
list_length_50_or_less,
|
32
36
|
raise_on_name_alphanumeric_dashes_only,
|
33
37
|
raise_on_name_with_banned_characters,
|
38
|
+
set_run_policy_deprecated_fields,
|
39
|
+
validate_default_queue_id_not_none,
|
40
|
+
validate_max_metadata_length,
|
41
|
+
validate_message_template_variables,
|
42
|
+
validate_name_present_on_nonanonymous_blocks,
|
43
|
+
validate_not_negative,
|
44
|
+
validate_parent_and_ref_diff,
|
34
45
|
)
|
35
46
|
from prefect.client.schemas.schedules import SCHEDULE_TYPES
|
36
47
|
from prefect.settings import PREFECT_CLOUD_API_URL, PREFECT_CLOUD_UI_URL
|
@@ -134,7 +145,7 @@ class State(ObjectBaseModel, Generic[R]):
|
|
134
145
|
type: StateType
|
135
146
|
name: Optional[str] = Field(default=None)
|
136
147
|
timestamp: DateTimeTZ = Field(default_factory=lambda: pendulum.now("UTC"))
|
137
|
-
message: Optional[str] = Field(default=None,
|
148
|
+
message: Optional[str] = Field(default=None, examples=["Run started"])
|
138
149
|
state_details: StateDetails = Field(default_factory=StateDetails)
|
139
150
|
data: Union["BaseResult[R]", "DataDocument[R]", Any] = Field(
|
140
151
|
default=None,
|
@@ -296,7 +307,13 @@ class State(ObjectBaseModel, Generic[R]):
|
|
296
307
|
def is_paused(self) -> bool:
|
297
308
|
return self.type == StateType.PAUSED
|
298
309
|
|
299
|
-
def copy(
|
310
|
+
def copy(
|
311
|
+
self,
|
312
|
+
*,
|
313
|
+
update: Optional[Dict[str, Any]] = None,
|
314
|
+
reset_fields: bool = False,
|
315
|
+
**kwargs,
|
316
|
+
):
|
300
317
|
"""
|
301
318
|
Copying API models should return an object that could be inserted into the
|
302
319
|
database again. The 'timestamp' is reset using the default factory.
|
@@ -387,18 +404,7 @@ class FlowRunPolicy(PrefectBaseModel):
|
|
387
404
|
|
388
405
|
@root_validator
|
389
406
|
def populate_deprecated_fields(cls, values):
|
390
|
-
|
391
|
-
If deprecated fields are provided, populate the corresponding new fields
|
392
|
-
to preserve orchestration behavior.
|
393
|
-
"""
|
394
|
-
if not values.get("retries", None) and values.get("max_retries", 0) != 0:
|
395
|
-
values["retries"] = values["max_retries"]
|
396
|
-
if (
|
397
|
-
not values.get("retry_delay", None)
|
398
|
-
and values.get("retry_delay_seconds", 0) != 0
|
399
|
-
):
|
400
|
-
values["retry_delay"] = values["retry_delay_seconds"]
|
401
|
-
return values
|
407
|
+
return set_run_policy_deprecated_fields(values)
|
402
408
|
|
403
409
|
|
404
410
|
class FlowRun(ObjectBaseModel):
|
@@ -407,7 +413,7 @@ class FlowRun(ObjectBaseModel):
|
|
407
413
|
description=(
|
408
414
|
"The name of the flow run. Defaults to a random slug if not specified."
|
409
415
|
),
|
410
|
-
|
416
|
+
examples=["my-flow-run"],
|
411
417
|
)
|
412
418
|
flow_id: UUID = Field(default=..., description="The id of the flow being run.")
|
413
419
|
state_id: Optional[UUID] = Field(
|
@@ -419,15 +425,20 @@ class FlowRun(ObjectBaseModel):
|
|
419
425
|
"The id of the deployment associated with this flow run, if available."
|
420
426
|
),
|
421
427
|
)
|
428
|
+
deployment_version: Optional[str] = Field(
|
429
|
+
default=None,
|
430
|
+
description="The version of the deployment associated with this flow run.",
|
431
|
+
examples=["1.0"],
|
432
|
+
)
|
422
433
|
work_queue_name: Optional[str] = Field(
|
423
434
|
default=None, description="The work queue that handled this flow run."
|
424
435
|
)
|
425
436
|
flow_version: Optional[str] = Field(
|
426
437
|
default=None,
|
427
438
|
description="The version of the flow executed in this flow run.",
|
428
|
-
|
439
|
+
examples=["1.0"],
|
429
440
|
)
|
430
|
-
parameters:
|
441
|
+
parameters: Dict[str, Any] = Field(
|
431
442
|
default_factory=dict, description="Parameters for the flow run."
|
432
443
|
)
|
433
444
|
idempotency_key: Optional[str] = Field(
|
@@ -437,10 +448,10 @@ class FlowRun(ObjectBaseModel):
|
|
437
448
|
" run is not created multiple times."
|
438
449
|
),
|
439
450
|
)
|
440
|
-
context:
|
451
|
+
context: Dict[str, Any] = Field(
|
441
452
|
default_factory=dict,
|
442
453
|
description="Additional context for the flow run.",
|
443
|
-
|
454
|
+
examples=[{"my_var": "my_val"}],
|
444
455
|
)
|
445
456
|
empirical_policy: FlowRunPolicy = Field(
|
446
457
|
default_factory=FlowRunPolicy,
|
@@ -448,7 +459,7 @@ class FlowRun(ObjectBaseModel):
|
|
448
459
|
tags: List[str] = Field(
|
449
460
|
default_factory=list,
|
450
461
|
description="A list of tags on the flow run",
|
451
|
-
|
462
|
+
examples=[["tag-1", "tag-2"]],
|
452
463
|
)
|
453
464
|
parent_task_run_id: Optional[UUID] = Field(
|
454
465
|
default=None,
|
@@ -515,17 +526,27 @@ class FlowRun(ObjectBaseModel):
|
|
515
526
|
work_pool_name: Optional[str] = Field(
|
516
527
|
default=None,
|
517
528
|
description="The name of the flow run's work pool.",
|
518
|
-
|
529
|
+
examples=["my-work-pool"],
|
519
530
|
)
|
520
531
|
state: Optional[State] = Field(
|
521
532
|
default=None,
|
522
533
|
description="The state of the flow run.",
|
523
|
-
|
534
|
+
examples=[State(type=StateType.COMPLETED)],
|
524
535
|
)
|
525
536
|
job_variables: Optional[dict] = Field(
|
526
537
|
default=None, description="Job variables for the flow run."
|
527
538
|
)
|
528
539
|
|
540
|
+
# These are server-side optimizations and should not be present on client models
|
541
|
+
# TODO: Deprecate these fields
|
542
|
+
|
543
|
+
state_type: Optional[StateType] = Field(
|
544
|
+
default=None, description="The type of the current flow run state."
|
545
|
+
)
|
546
|
+
state_name: Optional[str] = Field(
|
547
|
+
default=None, description="The name of the current flow run state."
|
548
|
+
)
|
549
|
+
|
529
550
|
def __eq__(self, other: Any) -> bool:
|
530
551
|
"""
|
531
552
|
Check for "equality" to another flow run schema
|
@@ -544,16 +565,6 @@ class FlowRun(ObjectBaseModel):
|
|
544
565
|
def set_default_name(cls, name):
|
545
566
|
return get_or_create_run_name(name)
|
546
567
|
|
547
|
-
# These are server-side optimizations and should not be present on client models
|
548
|
-
# TODO: Deprecate these fields
|
549
|
-
|
550
|
-
state_type: Optional[StateType] = Field(
|
551
|
-
default=None, description="The type of the current flow run state."
|
552
|
-
)
|
553
|
-
state_name: Optional[str] = Field(
|
554
|
-
default=None, description="The name of the current flow run state."
|
555
|
-
)
|
556
|
-
|
557
568
|
|
558
569
|
class TaskRunPolicy(PrefectBaseModel):
|
559
570
|
"""Defines of how a task run should retry."""
|
@@ -585,32 +596,15 @@ class TaskRunPolicy(PrefectBaseModel):
|
|
585
596
|
|
586
597
|
@root_validator
|
587
598
|
def populate_deprecated_fields(cls, values):
|
588
|
-
|
589
|
-
If deprecated fields are provided, populate the corresponding new fields
|
590
|
-
to preserve orchestration behavior.
|
591
|
-
"""
|
592
|
-
if not values.get("retries", None) and values.get("max_retries", 0) != 0:
|
593
|
-
values["retries"] = values["max_retries"]
|
594
|
-
|
595
|
-
if (
|
596
|
-
not values.get("retry_delay", None)
|
597
|
-
and values.get("retry_delay_seconds", 0) != 0
|
598
|
-
):
|
599
|
-
values["retry_delay"] = values["retry_delay_seconds"]
|
600
|
-
|
601
|
-
return values
|
599
|
+
return set_run_policy_deprecated_fields(values)
|
602
600
|
|
603
601
|
@validator("retry_delay")
|
604
602
|
def validate_configured_retry_delays(cls, v):
|
605
|
-
|
606
|
-
raise ValueError("Can not configure more than 50 retry delays per task.")
|
607
|
-
return v
|
603
|
+
return list_length_50_or_less(v)
|
608
604
|
|
609
605
|
@validator("retry_jitter_factor")
|
610
606
|
def validate_jitter_factor(cls, v):
|
611
|
-
|
612
|
-
raise ValueError("`retry_jitter_factor` must be >= 0.")
|
613
|
-
return v
|
607
|
+
return validate_not_negative(v)
|
614
608
|
|
615
609
|
|
616
610
|
class TaskRunInput(PrefectBaseModel):
|
@@ -648,7 +642,9 @@ class Constant(TaskRunInput):
|
|
648
642
|
|
649
643
|
|
650
644
|
class TaskRun(ObjectBaseModel):
|
651
|
-
name: str = Field(
|
645
|
+
name: str = Field(
|
646
|
+
default_factory=lambda: generate_slug(2), examples=["my-task-run"]
|
647
|
+
)
|
652
648
|
flow_run_id: Optional[UUID] = Field(
|
653
649
|
default=None, description="The flow run id of the task run."
|
654
650
|
)
|
@@ -682,7 +678,7 @@ class TaskRun(ObjectBaseModel):
|
|
682
678
|
tags: List[str] = Field(
|
683
679
|
default_factory=list,
|
684
680
|
description="A list of tags for the task run.",
|
685
|
-
|
681
|
+
examples=[["tag-1", "tag-2"]],
|
686
682
|
)
|
687
683
|
state_id: Optional[UUID] = Field(
|
688
684
|
default=None, description="The id of the current task run state."
|
@@ -745,7 +741,7 @@ class TaskRun(ObjectBaseModel):
|
|
745
741
|
state: Optional[State] = Field(
|
746
742
|
default=None,
|
747
743
|
description="The state of the flow run.",
|
748
|
-
|
744
|
+
examples=[State(type=StateType.COMPLETED)],
|
749
745
|
)
|
750
746
|
|
751
747
|
@validator("name", pre=True)
|
@@ -834,7 +830,7 @@ class BlockSchema(ObjectBaseModel):
|
|
834
830
|
"""A representation of a block schema."""
|
835
831
|
|
836
832
|
checksum: str = Field(default=..., description="The block schema's unique checksum")
|
837
|
-
fields:
|
833
|
+
fields: Dict[str, Any] = Field(
|
838
834
|
default_factory=dict, description="The block schema's field schema"
|
839
835
|
)
|
840
836
|
block_type_id: Optional[UUID] = Field(default=..., description="A block type ID")
|
@@ -860,7 +856,9 @@ class BlockDocument(ObjectBaseModel):
|
|
860
856
|
"The block document's name. Not required for anonymous block documents."
|
861
857
|
),
|
862
858
|
)
|
863
|
-
data:
|
859
|
+
data: Dict[str, Any] = Field(
|
860
|
+
default_factory=dict, description="The block document's data"
|
861
|
+
)
|
864
862
|
block_schema_id: UUID = Field(default=..., description="A block schema ID")
|
865
863
|
block_schema: Optional[BlockSchema] = Field(
|
866
864
|
default=None, description="The associated block schema"
|
@@ -889,23 +887,19 @@ class BlockDocument(ObjectBaseModel):
|
|
889
887
|
|
890
888
|
@root_validator
|
891
889
|
def validate_name_is_present_if_not_anonymous(cls, values):
|
892
|
-
|
893
|
-
# stored in the database
|
894
|
-
if not values.get("is_anonymous") and not values.get("name"):
|
895
|
-
raise ValueError("Names must be provided for block documents.")
|
896
|
-
return values
|
890
|
+
return validate_name_present_on_nonanonymous_blocks(values)
|
897
891
|
|
898
892
|
|
899
893
|
class Flow(ObjectBaseModel):
|
900
894
|
"""An ORM representation of flow data."""
|
901
895
|
|
902
896
|
name: str = Field(
|
903
|
-
default=..., description="The name of the flow",
|
897
|
+
default=..., description="The name of the flow", examples=["my-flow"]
|
904
898
|
)
|
905
899
|
tags: List[str] = Field(
|
906
900
|
default_factory=list,
|
907
901
|
description="A list of flow tags",
|
908
|
-
|
902
|
+
examples=[["tag-1", "tag-2"]],
|
909
903
|
)
|
910
904
|
|
911
905
|
@validator("name", check_fields=False)
|
@@ -913,34 +907,14 @@ class Flow(ObjectBaseModel):
|
|
913
907
|
return raise_on_name_with_banned_characters(v)
|
914
908
|
|
915
909
|
|
916
|
-
class
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
This schema is agnostic to the types and configuration provided by clients
|
921
|
-
"""
|
922
|
-
|
923
|
-
type: Optional[str] = Field(
|
924
|
-
default=None,
|
925
|
-
description=(
|
926
|
-
"The type of the flow runner which can be used by the client for"
|
927
|
-
" dispatching."
|
928
|
-
),
|
910
|
+
class MinimalDeploymentSchedule(PrefectBaseModel):
|
911
|
+
schedule: SCHEDULE_TYPES = Field(
|
912
|
+
default=..., description="The schedule for the deployment."
|
929
913
|
)
|
930
|
-
|
931
|
-
default=
|
914
|
+
active: bool = Field(
|
915
|
+
default=True, description="Whether or not the schedule is active."
|
932
916
|
)
|
933
917
|
|
934
|
-
# The following is required for composite compatibility in the ORM
|
935
|
-
|
936
|
-
def __init__(self, type: str = None, config: dict = None, **kwargs) -> None:
|
937
|
-
# Pydantic does not support positional arguments so they must be converted to
|
938
|
-
# keyword arguments
|
939
|
-
super().__init__(type=type, config=config, **kwargs)
|
940
|
-
|
941
|
-
def __composite_values__(self):
|
942
|
-
return self.type, self.config
|
943
|
-
|
944
918
|
|
945
919
|
class DeploymentSchedule(ObjectBaseModel):
|
946
920
|
deployment_id: Optional[UUID] = Field(
|
@@ -955,16 +929,7 @@ class DeploymentSchedule(ObjectBaseModel):
|
|
955
929
|
)
|
956
930
|
|
957
931
|
|
958
|
-
class
|
959
|
-
schedule: SCHEDULE_TYPES = Field(
|
960
|
-
default=..., description="The schedule for the deployment."
|
961
|
-
)
|
962
|
-
active: bool = Field(
|
963
|
-
default=True, description="Whether or not the schedule is active."
|
964
|
-
)
|
965
|
-
|
966
|
-
|
967
|
-
class Deployment(ObjectBaseModel):
|
932
|
+
class Deployment(DeprecatedInfraOverridesField, ObjectBaseModel):
|
968
933
|
"""An ORM representation of deployment data."""
|
969
934
|
|
970
935
|
name: str = Field(default=..., description="The name of the deployment.")
|
@@ -989,9 +954,9 @@ class Deployment(ObjectBaseModel):
|
|
989
954
|
schedules: List[DeploymentSchedule] = Field(
|
990
955
|
default_factory=list, description="A list of schedules for the deployment."
|
991
956
|
)
|
992
|
-
|
957
|
+
job_variables: Dict[str, Any] = Field(
|
993
958
|
default_factory=dict,
|
994
|
-
description="Overrides to apply to
|
959
|
+
description="Overrides to apply to flow run infrastructure at runtime.",
|
995
960
|
)
|
996
961
|
parameters: Dict[str, Any] = Field(
|
997
962
|
default_factory=dict,
|
@@ -1004,7 +969,7 @@ class Deployment(ObjectBaseModel):
|
|
1004
969
|
tags: List[str] = Field(
|
1005
970
|
default_factory=list,
|
1006
971
|
description="A list of tags for the deployment",
|
1007
|
-
|
972
|
+
examples=[["tag-1", "tag-2"]],
|
1008
973
|
)
|
1009
974
|
work_queue_name: Optional[str] = Field(
|
1010
975
|
default=None,
|
@@ -1091,7 +1056,7 @@ class BlockSchema(ObjectBaseModel):
|
|
1091
1056
|
"""An ORM representation of a block schema."""
|
1092
1057
|
|
1093
1058
|
checksum: str = Field(default=..., description="The block schema's unique checksum")
|
1094
|
-
fields:
|
1059
|
+
fields: Dict[str, Any] = Field(
|
1095
1060
|
default_factory=dict, description="The block schema's field schema"
|
1096
1061
|
)
|
1097
1062
|
block_type_id: Optional[UUID] = Field(default=..., description="A block type ID")
|
@@ -1149,21 +1114,14 @@ class BlockDocumentReference(ObjectBaseModel):
|
|
1149
1114
|
|
1150
1115
|
@root_validator
|
1151
1116
|
def validate_parent_and_ref_are_different(cls, values):
|
1152
|
-
|
1153
|
-
ref_id = values.get("reference_block_document_id")
|
1154
|
-
if parent_id and ref_id and parent_id == ref_id:
|
1155
|
-
raise ValueError(
|
1156
|
-
"`parent_block_document_id` and `reference_block_document_id` cannot be"
|
1157
|
-
" the same"
|
1158
|
-
)
|
1159
|
-
return values
|
1117
|
+
return validate_parent_and_ref_diff(values)
|
1160
1118
|
|
1161
1119
|
|
1162
1120
|
class Configuration(ObjectBaseModel):
|
1163
1121
|
"""An ORM representation of account info."""
|
1164
1122
|
|
1165
1123
|
key: str = Field(default=..., description="Account info key")
|
1166
|
-
value:
|
1124
|
+
value: Dict[str, Any] = Field(default=..., description="Account info")
|
1167
1125
|
|
1168
1126
|
|
1169
1127
|
class SavedSearchFilter(PrefectBaseModel):
|
@@ -1347,20 +1305,15 @@ class FlowRunNotificationPolicy(ObjectBaseModel):
|
|
1347
1305
|
" Valid variables include:"
|
1348
1306
|
f" {listrepr(sorted(FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS), sep=', ')}"
|
1349
1307
|
),
|
1350
|
-
|
1308
|
+
examples=[
|
1351
1309
|
"Flow run {flow_run_name} with id {flow_run_id} entered state"
|
1352
1310
|
" {flow_run_state_name}."
|
1353
|
-
|
1311
|
+
],
|
1354
1312
|
)
|
1355
1313
|
|
1356
1314
|
@validator("message_template")
|
1357
1315
|
def validate_message_template_variables(cls, v):
|
1358
|
-
|
1359
|
-
try:
|
1360
|
-
v.format(**{k: "test" for k in FLOW_RUN_NOTIFICATION_TEMPLATE_KWARGS})
|
1361
|
-
except KeyError as exc:
|
1362
|
-
raise ValueError(f"Invalid template variable provided: '{exc.args[0]}'")
|
1363
|
-
return v
|
1316
|
+
return validate_message_template_variables(v)
|
1364
1317
|
|
1365
1318
|
|
1366
1319
|
class Agent(ObjectBaseModel):
|
@@ -1425,23 +1378,7 @@ class WorkPool(ObjectBaseModel):
|
|
1425
1378
|
|
1426
1379
|
@validator("default_queue_id", always=True)
|
1427
1380
|
def helpful_error_for_missing_default_queue_id(cls, v):
|
1428
|
-
|
1429
|
-
Default queue ID is required because all pools must have a default queue
|
1430
|
-
ID, but it represents a circular foreign key relationship to a
|
1431
|
-
WorkQueue (which can't be created until the work pool exists).
|
1432
|
-
Therefore, while this field can *technically* be null, it shouldn't be.
|
1433
|
-
This should only be an issue when creating new pools, as reading
|
1434
|
-
existing ones will always have this field populated. This custom error
|
1435
|
-
message will help users understand that they should use the
|
1436
|
-
`actions.WorkPoolCreate` model in that case.
|
1437
|
-
"""
|
1438
|
-
if v is None:
|
1439
|
-
raise ValueError(
|
1440
|
-
"`default_queue_id` is a required field. If you are "
|
1441
|
-
"creating a new WorkPool and don't have a queue "
|
1442
|
-
"ID yet, use the `actions.WorkPoolCreate` model instead."
|
1443
|
-
)
|
1444
|
-
return v
|
1381
|
+
return validate_default_queue_id_not_none(v)
|
1445
1382
|
|
1446
1383
|
|
1447
1384
|
class Worker(ObjectBaseModel):
|
@@ -1508,13 +1445,7 @@ class Artifact(ObjectBaseModel):
|
|
1508
1445
|
|
1509
1446
|
@validator("metadata_")
|
1510
1447
|
def validate_metadata_length(cls, v):
|
1511
|
-
|
1512
|
-
if not isinstance(v, dict):
|
1513
|
-
return v
|
1514
|
-
for key in v.keys():
|
1515
|
-
if len(str(v[key])) > max_metadata_length:
|
1516
|
-
v[key] = str(v[key])[:max_metadata_length] + "..."
|
1517
|
-
return v
|
1448
|
+
return validate_max_metadata_length(v)
|
1518
1449
|
|
1519
1450
|
|
1520
1451
|
class ArtifactCollection(ObjectBaseModel):
|
@@ -1558,19 +1489,19 @@ class Variable(ObjectBaseModel):
|
|
1558
1489
|
name: str = Field(
|
1559
1490
|
default=...,
|
1560
1491
|
description="The name of the variable",
|
1561
|
-
|
1492
|
+
examples=["my_variable"],
|
1562
1493
|
max_length=MAX_VARIABLE_NAME_LENGTH,
|
1563
1494
|
)
|
1564
1495
|
value: str = Field(
|
1565
1496
|
default=...,
|
1566
1497
|
description="The value of the variable",
|
1567
|
-
|
1498
|
+
examples=["my_value"],
|
1568
1499
|
max_length=MAX_VARIABLE_VALUE_LENGTH,
|
1569
1500
|
)
|
1570
1501
|
tags: List[str] = Field(
|
1571
1502
|
default_factory=list,
|
1572
1503
|
description="A list of variable tags",
|
1573
|
-
|
1504
|
+
examples=[["tag-1", "tag-2"]],
|
1574
1505
|
)
|
1575
1506
|
|
1576
1507
|
|