prefect-client 3.0.0rc3__py3-none-any.whl → 3.0.0rc4__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 -1
- prefect/client/subscriptions.py +3 -3
- prefect/flow_engine.py +82 -2
- prefect/flows.py +12 -2
- prefect/futures.py +9 -1
- prefect/results.py +33 -31
- prefect/settings.py +1 -1
- prefect/task_engine.py +5 -6
- prefect/task_runs.py +23 -9
- prefect/task_worker.py +128 -19
- prefect/tasks.py +20 -14
- prefect/transactions.py +6 -8
- prefect/types/__init__.py +10 -3
- prefect/utilities/collections.py +120 -57
- prefect/utilities/urls.py +5 -5
- {prefect_client-3.0.0rc3.dist-info → prefect_client-3.0.0rc4.dist-info}/METADATA +2 -2
- {prefect_client-3.0.0rc3.dist-info → prefect_client-3.0.0rc4.dist-info}/RECORD +20 -21
- prefect/blocks/kubernetes.py +0 -115
- {prefect_client-3.0.0rc3.dist-info → prefect_client-3.0.0rc4.dist-info}/LICENSE +0 -0
- {prefect_client-3.0.0rc3.dist-info → prefect_client-3.0.0rc4.dist-info}/WHEEL +0 -0
- {prefect_client-3.0.0rc3.dist-info → prefect_client-3.0.0rc4.dist-info}/top_level.txt +0 -0
prefect/blocks/kubernetes.py
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
from pathlib import Path
|
2
|
-
from typing import TYPE_CHECKING, Dict, Optional, Type
|
3
|
-
|
4
|
-
import yaml
|
5
|
-
from pydantic import Field, field_validator
|
6
|
-
from typing_extensions import Self
|
7
|
-
|
8
|
-
from prefect._internal.compatibility.deprecated import deprecated_class
|
9
|
-
from prefect._internal.schemas.validators import validate_yaml
|
10
|
-
from prefect.blocks.core import Block
|
11
|
-
from prefect.utilities.collections import listrepr
|
12
|
-
from prefect.utilities.importtools import lazy_import
|
13
|
-
|
14
|
-
if TYPE_CHECKING:
|
15
|
-
import kubernetes
|
16
|
-
from kubernetes.client.api_client import ApiClient
|
17
|
-
else:
|
18
|
-
kubernetes = lazy_import("kubernetes")
|
19
|
-
|
20
|
-
|
21
|
-
@deprecated_class(
|
22
|
-
start_date="Mar 2024",
|
23
|
-
help="Use the KubernetesClusterConfig block from prefect-kubernetes instead.",
|
24
|
-
)
|
25
|
-
class KubernetesClusterConfig(Block):
|
26
|
-
"""
|
27
|
-
Stores configuration for interaction with Kubernetes clusters.
|
28
|
-
|
29
|
-
See `from_file` for creation.
|
30
|
-
|
31
|
-
Attributes:
|
32
|
-
config: The entire loaded YAML contents of a kubectl config file
|
33
|
-
context_name: The name of the kubectl context to use
|
34
|
-
|
35
|
-
Example:
|
36
|
-
Load a saved Kubernetes cluster config:
|
37
|
-
```python
|
38
|
-
from prefect.blocks.kubernetes import KubernetesClusterConfig
|
39
|
-
|
40
|
-
cluster_config_block = KubernetesClusterConfig.load("BLOCK_NAME")
|
41
|
-
```
|
42
|
-
"""
|
43
|
-
|
44
|
-
_block_type_name = "Kubernetes Cluster Config"
|
45
|
-
_logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/2d0b896006ad463b49c28aaac14f31e00e32cfab-250x250.png"
|
46
|
-
_documentation_url = "https://docs.prefect.io/api-ref/prefect/blocks/kubernetes/#prefect.blocks.kubernetes.KubernetesClusterConfig"
|
47
|
-
|
48
|
-
config: Dict = Field(
|
49
|
-
default=..., description="The entire contents of a kubectl config file."
|
50
|
-
)
|
51
|
-
context_name: str = Field(
|
52
|
-
default=..., description="The name of the kubectl context to use."
|
53
|
-
)
|
54
|
-
|
55
|
-
@field_validator("config", mode="before")
|
56
|
-
@classmethod
|
57
|
-
def parse_yaml_config(cls, value):
|
58
|
-
return validate_yaml(value)
|
59
|
-
|
60
|
-
@classmethod
|
61
|
-
def from_file(
|
62
|
-
cls: Type[Self], path: Optional[Path] = None, context_name: Optional[str] = None
|
63
|
-
) -> Self:
|
64
|
-
"""
|
65
|
-
Create a cluster config from the a Kubernetes config file.
|
66
|
-
|
67
|
-
By default, the current context in the default Kubernetes config file will be
|
68
|
-
used.
|
69
|
-
|
70
|
-
An alternative file or context may be specified.
|
71
|
-
|
72
|
-
The entire config file will be loaded and stored.
|
73
|
-
"""
|
74
|
-
kube_config = kubernetes.config.kube_config
|
75
|
-
|
76
|
-
path = Path(path or kube_config.KUBE_CONFIG_DEFAULT_LOCATION)
|
77
|
-
path = path.expanduser().resolve()
|
78
|
-
|
79
|
-
# Determine the context
|
80
|
-
existing_contexts, current_context = kube_config.list_kube_config_contexts(
|
81
|
-
config_file=str(path)
|
82
|
-
)
|
83
|
-
context_names = {ctx["name"] for ctx in existing_contexts}
|
84
|
-
if context_name:
|
85
|
-
if context_name not in context_names:
|
86
|
-
raise ValueError(
|
87
|
-
f"Context {context_name!r} not found. "
|
88
|
-
f"Specify one of: {listrepr(context_names, sep=', ')}."
|
89
|
-
)
|
90
|
-
else:
|
91
|
-
context_name = current_context["name"]
|
92
|
-
|
93
|
-
# Load the entire config file
|
94
|
-
config_file_contents = path.read_text()
|
95
|
-
config_dict = yaml.safe_load(config_file_contents)
|
96
|
-
|
97
|
-
return cls(config=config_dict, context_name=context_name)
|
98
|
-
|
99
|
-
def get_api_client(self) -> "ApiClient":
|
100
|
-
"""
|
101
|
-
Returns a Kubernetes API client for this cluster config.
|
102
|
-
"""
|
103
|
-
return kubernetes.config.kube_config.new_client_from_config_dict(
|
104
|
-
config_dict=self.config, context=self.context_name
|
105
|
-
)
|
106
|
-
|
107
|
-
def configure_client(self) -> None:
|
108
|
-
"""
|
109
|
-
Activates this cluster configuration by loading the configuration into the
|
110
|
-
Kubernetes Python client. After calling this, Kubernetes API clients can use
|
111
|
-
this config's context.
|
112
|
-
"""
|
113
|
-
kubernetes.config.kube_config.load_kube_config_from_dict(
|
114
|
-
config_dict=self.config, context=self.context_name
|
115
|
-
)
|
File without changes
|
File without changes
|
File without changes
|