prefect-client 3.3.6.dev2__py3-none-any.whl → 3.3.6.dev4__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/_build_info.py +3 -3
- prefect/_experimental/{bundles.py → bundles/__init__.py} +25 -9
- prefect/_experimental/bundles/execute.py +34 -0
- prefect/_versioning.py +175 -0
- prefect/client/orchestration/_deployments/client.py +49 -22
- prefect/deployments/runner.py +22 -6
- prefect/server/api/deployments.py +41 -3
- prefect/workers/base.py +28 -1
- {prefect_client-3.3.6.dev2.dist-info → prefect_client-3.3.6.dev4.dist-info}/METADATA +1 -1
- {prefect_client-3.3.6.dev2.dist-info → prefect_client-3.3.6.dev4.dist-info}/RECORD +12 -10
- {prefect_client-3.3.6.dev2.dist-info → prefect_client-3.3.6.dev4.dist-info}/WHEEL +0 -0
- {prefect_client-3.3.6.dev2.dist-info → prefect_client-3.3.6.dev4.dist-info}/licenses/LICENSE +0 -0
prefect/_build_info.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Generated by versioningit
|
2
|
-
__version__ = "3.3.6.
|
3
|
-
__build_date__ = "2025-04-
|
4
|
-
__git_commit__ = "
|
2
|
+
__version__ = "3.3.6.dev4"
|
3
|
+
__build_date__ = "2025-04-24 08:08:45.298549+00:00"
|
4
|
+
__git_commit__ = "cd2bf96d18276663c433a99c1e0f1191c100de5f"
|
5
5
|
__dirty__ = False
|
@@ -11,7 +11,7 @@ import sys
|
|
11
11
|
from pathlib import Path
|
12
12
|
from typing import Any, TypedDict
|
13
13
|
|
14
|
-
import cloudpickle
|
14
|
+
import cloudpickle # pyright: ignore[reportMissingTypeStubs]
|
15
15
|
|
16
16
|
from prefect.client.schemas.objects import FlowRun
|
17
17
|
from prefect.context import SettingsContext, get_settings_context, serialize_context
|
@@ -22,12 +22,18 @@ from prefect.settings.context import get_current_settings
|
|
22
22
|
from prefect.settings.models.root import Settings
|
23
23
|
from prefect.utilities.slugify import slugify
|
24
24
|
|
25
|
-
|
26
|
-
import uv
|
25
|
+
from .execute import execute_bundle_from_file
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
|
28
|
+
def _get_uv_path() -> str:
|
29
|
+
try:
|
30
|
+
import uv
|
31
|
+
|
32
|
+
uv_path = uv.find_uv_bin()
|
33
|
+
except (ImportError, ModuleNotFoundError):
|
34
|
+
uv_path = "uv"
|
35
|
+
|
36
|
+
return uv_path
|
31
37
|
|
32
38
|
|
33
39
|
class SerializedBundle(TypedDict):
|
@@ -46,7 +52,7 @@ def _serialize_bundle_object(obj: Any) -> str:
|
|
46
52
|
"""
|
47
53
|
Serializes an object to a string.
|
48
54
|
"""
|
49
|
-
return base64.b64encode(gzip.compress(cloudpickle.dumps(obj))).decode()
|
55
|
+
return base64.b64encode(gzip.compress(cloudpickle.dumps(obj))).decode() # pyright: ignore[reportUnknownMemberType]
|
50
56
|
|
51
57
|
|
52
58
|
def _deserialize_bundle_object(serialized_obj: str) -> Any:
|
@@ -80,7 +86,7 @@ def create_bundle_for_flow_run(
|
|
80
86
|
"flow_run": flow_run.model_dump(mode="json"),
|
81
87
|
"dependencies": subprocess.check_output(
|
82
88
|
[
|
83
|
-
|
89
|
+
_get_uv_path(),
|
84
90
|
"pip",
|
85
91
|
"freeze",
|
86
92
|
# Exclude editable installs because we won't be able to install them in the execution environment
|
@@ -164,7 +170,7 @@ def execute_bundle_in_subprocess(
|
|
164
170
|
# Install dependencies if necessary
|
165
171
|
if dependencies := bundle.get("dependencies"):
|
166
172
|
subprocess.check_call(
|
167
|
-
[
|
173
|
+
[_get_uv_path(), "pip", "install", *dependencies.split("\n")],
|
168
174
|
# Copy the current environment to ensure we install into the correct venv
|
169
175
|
env=os.environ,
|
170
176
|
)
|
@@ -238,3 +244,13 @@ def convert_step_to_command(
|
|
238
244
|
command.extend(["--key", key])
|
239
245
|
|
240
246
|
return command
|
247
|
+
|
248
|
+
|
249
|
+
__all__ = [
|
250
|
+
"execute_bundle_from_file",
|
251
|
+
"convert_step_to_command",
|
252
|
+
"create_bundle_for_flow_run",
|
253
|
+
"extract_flow_from_bundle",
|
254
|
+
"execute_bundle_in_subprocess",
|
255
|
+
"SerializedBundle",
|
256
|
+
]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
import typer
|
4
|
+
|
5
|
+
from prefect.utilities.asyncutils import run_coro_as_sync
|
6
|
+
|
7
|
+
|
8
|
+
def execute_bundle_from_file(key: str):
|
9
|
+
"""
|
10
|
+
Loads a bundle from a file and executes it.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
key: The key of the bundle to execute.
|
14
|
+
"""
|
15
|
+
with open(key, "r") as f:
|
16
|
+
bundle = json.load(f)
|
17
|
+
|
18
|
+
from prefect.runner.runner import Runner
|
19
|
+
|
20
|
+
run_coro_as_sync(Runner().execute_bundle(bundle))
|
21
|
+
|
22
|
+
|
23
|
+
def _execute_bundle_from_file(key: str = typer.Option(...)):
|
24
|
+
"""
|
25
|
+
Loads a bundle from a file and executes it.
|
26
|
+
|
27
|
+
Args:
|
28
|
+
key: The key of the bundle to execute.
|
29
|
+
"""
|
30
|
+
execute_bundle_from_file(key)
|
31
|
+
|
32
|
+
|
33
|
+
if __name__ == "__main__":
|
34
|
+
typer.run(_execute_bundle_from_file)
|
prefect/_versioning.py
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import os
|
4
|
+
from enum import Enum
|
5
|
+
from typing import Any, Callable, Coroutine, Dict, Literal, Optional
|
6
|
+
|
7
|
+
from anyio import run_process
|
8
|
+
from pydantic import Field, model_validator
|
9
|
+
|
10
|
+
from prefect.client.schemas.objects import VersionInfo
|
11
|
+
|
12
|
+
|
13
|
+
class SimpleVersionInfo(VersionInfo):
|
14
|
+
type: Literal["prefect:simple"] = "prefect:simple"
|
15
|
+
version: str = Field(default="")
|
16
|
+
branch: Optional[str] = Field(default=None)
|
17
|
+
url: Optional[str] = Field(default=None)
|
18
|
+
|
19
|
+
|
20
|
+
class GithubVersionInfo(VersionInfo):
|
21
|
+
type: Literal["vcs:github"] = "vcs:github"
|
22
|
+
version: str
|
23
|
+
branch: str
|
24
|
+
url: str
|
25
|
+
repository: str
|
26
|
+
|
27
|
+
@model_validator(mode="after")
|
28
|
+
def validate_branch(self):
|
29
|
+
if not self.branch:
|
30
|
+
raise ValueError("branch is required when type is 'vcs:github'")
|
31
|
+
return self
|
32
|
+
|
33
|
+
|
34
|
+
class GitVersionInfo(VersionInfo):
|
35
|
+
type: Literal["vcs:git"] = "vcs:git"
|
36
|
+
version: str
|
37
|
+
branch: str
|
38
|
+
url: str
|
39
|
+
repository: str
|
40
|
+
|
41
|
+
|
42
|
+
async def get_github_version_info(
|
43
|
+
version: Optional[str] = None,
|
44
|
+
branch: Optional[str] = None,
|
45
|
+
repository: Optional[str] = None,
|
46
|
+
url: Optional[str] = None,
|
47
|
+
) -> GithubVersionInfo:
|
48
|
+
"""Create a GithubVersionInfo object from provided values or environment variables.
|
49
|
+
|
50
|
+
Args:
|
51
|
+
version: The commit SHA, falls back to GITHUB_SHA env var
|
52
|
+
branch: The git branch, falls back to GITHUB_REF env var
|
53
|
+
repository: The repository name, falls back to GITHUB_REPOSITORY env var
|
54
|
+
url: The repository URL, constructed from GITHUB_SERVER_URL/GITHUB_REPOSITORY if not provided
|
55
|
+
|
56
|
+
Returns:
|
57
|
+
A GithubVersionInfo
|
58
|
+
|
59
|
+
Raises:
|
60
|
+
ValueError: If any required fields cannot be determined
|
61
|
+
"""
|
62
|
+
version = version or os.getenv("GITHUB_SHA")
|
63
|
+
branch = branch or os.getenv("GITHUB_REF")
|
64
|
+
repository = repository or os.getenv("GITHUB_REPOSITORY")
|
65
|
+
url = url or f"{os.getenv('GITHUB_SERVER_URL')}/{repository}"
|
66
|
+
|
67
|
+
if not version:
|
68
|
+
raise ValueError("version is required - must be provided or set in GITHUB_SHA")
|
69
|
+
if not branch:
|
70
|
+
raise ValueError("branch is required - must be provided or set in GITHUB_REF")
|
71
|
+
if not repository:
|
72
|
+
raise ValueError(
|
73
|
+
"repository is required - must be provided or set in GITHUB_REPOSITORY"
|
74
|
+
)
|
75
|
+
|
76
|
+
return GithubVersionInfo(
|
77
|
+
type="vcs:github",
|
78
|
+
version=version,
|
79
|
+
branch=branch,
|
80
|
+
repository=repository,
|
81
|
+
url=url,
|
82
|
+
)
|
83
|
+
|
84
|
+
|
85
|
+
async def get_git_version_info(
|
86
|
+
version: Optional[str] = None,
|
87
|
+
branch: Optional[str] = None,
|
88
|
+
url: Optional[str] = None,
|
89
|
+
repository: Optional[str] = None,
|
90
|
+
) -> GitVersionInfo:
|
91
|
+
try:
|
92
|
+
if not version:
|
93
|
+
# Run git command and get stdout
|
94
|
+
result = await run_process(["git", "rev-parse", "HEAD"])
|
95
|
+
# Decode bytes to string and strip whitespace
|
96
|
+
version = result.stdout.decode().strip()
|
97
|
+
|
98
|
+
if not branch:
|
99
|
+
result = await run_process(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
100
|
+
branch = result.stdout.decode().strip()
|
101
|
+
|
102
|
+
if not repository:
|
103
|
+
result = await run_process(["git", "config", "--get", "remote.origin.url"])
|
104
|
+
remote_url = result.stdout.decode().strip()
|
105
|
+
|
106
|
+
# Extract just the repository name (last part of the path)
|
107
|
+
repo_name = os.path.basename(remote_url.split(":")[1].rstrip(".git"))
|
108
|
+
repository = repo_name
|
109
|
+
|
110
|
+
if not url and repository:
|
111
|
+
# Use the full remote URL as the URL
|
112
|
+
result = await run_process(["git", "config", "--get", "remote.origin.url"])
|
113
|
+
url = result.stdout.decode().strip()
|
114
|
+
except Exception as e:
|
115
|
+
raise ValueError(
|
116
|
+
f"Error getting git version info: {e}. You may not be in a git repository."
|
117
|
+
)
|
118
|
+
|
119
|
+
if not url:
|
120
|
+
raise ValueError("Could not determine git repository URL")
|
121
|
+
|
122
|
+
return GitVersionInfo(
|
123
|
+
type="vcs:git", version=version, branch=branch, url=url, repository=repository
|
124
|
+
)
|
125
|
+
|
126
|
+
|
127
|
+
class VersionType(str, Enum):
|
128
|
+
SIMPLE = "prefect:simple"
|
129
|
+
GITHUB = "vcs:github"
|
130
|
+
GIT = "vcs:git"
|
131
|
+
DOCKER = "container:docker"
|
132
|
+
|
133
|
+
|
134
|
+
async def get_inferred_version_info(
|
135
|
+
version_type: Optional[str] = None,
|
136
|
+
) -> VersionInfo | None:
|
137
|
+
"""
|
138
|
+
Attempts to infer version information from the environment.
|
139
|
+
|
140
|
+
Args:
|
141
|
+
version_type: Optional type of version info to get. If provided, only that
|
142
|
+
type will be attempted.
|
143
|
+
|
144
|
+
Returns:
|
145
|
+
VersionInfo: The inferred version information
|
146
|
+
|
147
|
+
Raises:
|
148
|
+
ValueError: If unable to infer version info from any source
|
149
|
+
"""
|
150
|
+
# Map version types to their getter functions
|
151
|
+
type_to_getter: Dict[str, Callable[..., Coroutine[Any, Any, Any]]] = {
|
152
|
+
VersionType.GITHUB: get_github_version_info,
|
153
|
+
VersionType.GIT: get_git_version_info,
|
154
|
+
}
|
155
|
+
|
156
|
+
# Default order of getters to try
|
157
|
+
default_getters = [
|
158
|
+
get_github_version_info,
|
159
|
+
get_git_version_info,
|
160
|
+
]
|
161
|
+
|
162
|
+
if version_type:
|
163
|
+
if version_type not in type_to_getter:
|
164
|
+
raise ValueError(f"Unknown version type: {version_type}")
|
165
|
+
getters = [type_to_getter[version_type]]
|
166
|
+
else:
|
167
|
+
getters = default_getters
|
168
|
+
|
169
|
+
for getter in getters:
|
170
|
+
try:
|
171
|
+
return await getter()
|
172
|
+
except ValueError:
|
173
|
+
continue
|
174
|
+
|
175
|
+
return None
|
@@ -153,13 +153,14 @@ class DeploymentClient(BaseClient):
|
|
153
153
|
if getattr(deployment_create, field) is None:
|
154
154
|
exclude.add(field)
|
155
155
|
|
156
|
-
|
156
|
+
payload = deployment_create.model_dump(mode="json", exclude=exclude)
|
157
|
+
if deployment_create.version_info:
|
158
|
+
payload["version_info"] = deployment_create.version_info.model_dump(
|
159
|
+
mode="json"
|
160
|
+
)
|
161
|
+
|
162
|
+
response = self.request("POST", "/deployments/", json=payload)
|
157
163
|
|
158
|
-
response = self.request(
|
159
|
-
"POST",
|
160
|
-
"/deployments/",
|
161
|
-
json=json,
|
162
|
-
)
|
163
164
|
deployment_id = response.json().get("id")
|
164
165
|
if not deployment_id:
|
165
166
|
raise RequestError(f"Malformed response: {response}")
|
@@ -179,15 +180,28 @@ class DeploymentClient(BaseClient):
|
|
179
180
|
deployment_id: UUID,
|
180
181
|
deployment: "DeploymentUpdate",
|
181
182
|
) -> None:
|
183
|
+
exclude_if_none = [
|
184
|
+
"version_info",
|
185
|
+
]
|
186
|
+
|
187
|
+
exclude = {"name", "flow_name", "triggers"}
|
188
|
+
for field in exclude_if_none:
|
189
|
+
if getattr(deployment, field) is None:
|
190
|
+
exclude.add(field)
|
191
|
+
|
192
|
+
payload = deployment.model_dump(
|
193
|
+
mode="json",
|
194
|
+
exclude_unset=True,
|
195
|
+
exclude=exclude,
|
196
|
+
)
|
197
|
+
if deployment.version_info:
|
198
|
+
payload["version_info"] = deployment.version_info.model_dump(mode="json")
|
199
|
+
|
182
200
|
self.request(
|
183
201
|
"PATCH",
|
184
202
|
"/deployments/{id}",
|
185
203
|
path_params={"id": deployment_id},
|
186
|
-
json=
|
187
|
-
mode="json",
|
188
|
-
exclude_unset=True,
|
189
|
-
exclude={"name", "flow_name", "triggers"},
|
190
|
-
),
|
204
|
+
json=payload,
|
191
205
|
)
|
192
206
|
|
193
207
|
def _create_deployment_from_schema(self, schema: "DeploymentCreate") -> UUID:
|
@@ -733,13 +747,13 @@ class DeploymentAsyncClient(BaseAsyncClient):
|
|
733
747
|
if getattr(deployment_create, field) is None:
|
734
748
|
exclude.add(field)
|
735
749
|
|
736
|
-
|
750
|
+
payload = deployment_create.model_dump(mode="json", exclude=exclude)
|
751
|
+
if deployment_create.version_info:
|
752
|
+
payload["version_info"] = deployment_create.version_info.model_dump(
|
753
|
+
mode="json"
|
754
|
+
)
|
737
755
|
|
738
|
-
response = await self.request(
|
739
|
-
"POST",
|
740
|
-
"/deployments/",
|
741
|
-
json=json,
|
742
|
-
)
|
756
|
+
response = await self.request("POST", "/deployments/", json=payload)
|
743
757
|
deployment_id = response.json().get("id")
|
744
758
|
if not deployment_id:
|
745
759
|
raise RequestError(f"Malformed response: {response}")
|
@@ -761,15 +775,28 @@ class DeploymentAsyncClient(BaseAsyncClient):
|
|
761
775
|
deployment_id: UUID,
|
762
776
|
deployment: "DeploymentUpdate",
|
763
777
|
) -> None:
|
778
|
+
exclude_if_none = [
|
779
|
+
"version_info",
|
780
|
+
]
|
781
|
+
|
782
|
+
exclude = {"name", "flow_name", "triggers"}
|
783
|
+
for field in exclude_if_none:
|
784
|
+
if getattr(deployment, field) is None:
|
785
|
+
exclude.add(field)
|
786
|
+
|
787
|
+
payload = deployment.model_dump(
|
788
|
+
mode="json",
|
789
|
+
exclude_unset=True,
|
790
|
+
exclude=exclude,
|
791
|
+
)
|
792
|
+
if deployment.version_info:
|
793
|
+
payload["version_info"] = deployment.version_info.model_dump(mode="json")
|
794
|
+
|
764
795
|
await self.request(
|
765
796
|
"PATCH",
|
766
797
|
"/deployments/{id}",
|
767
798
|
path_params={"id": deployment_id},
|
768
|
-
json=
|
769
|
-
mode="json",
|
770
|
-
exclude_unset=True,
|
771
|
-
exclude={"name", "flow_name", "triggers"},
|
772
|
-
),
|
799
|
+
json=payload,
|
773
800
|
)
|
774
801
|
|
775
802
|
async def _create_deployment_from_schema(self, schema: "DeploymentCreate") -> UUID:
|
prefect/deployments/runner.py
CHANGED
@@ -29,6 +29,8 @@ Example:
|
|
29
29
|
|
30
30
|
"""
|
31
31
|
|
32
|
+
from __future__ import annotations
|
33
|
+
|
32
34
|
import importlib
|
33
35
|
import tempfile
|
34
36
|
from datetime import datetime, timedelta
|
@@ -63,6 +65,7 @@ from prefect.client.schemas.filters import WorkerFilter, WorkerFilterStatus
|
|
63
65
|
from prefect.client.schemas.objects import (
|
64
66
|
ConcurrencyLimitConfig,
|
65
67
|
ConcurrencyOptions,
|
68
|
+
VersionInfo,
|
66
69
|
)
|
67
70
|
from prefect.client.schemas.schedules import (
|
68
71
|
SCHEDULE_TYPES,
|
@@ -281,7 +284,10 @@ class RunnerDeployment(BaseModel):
|
|
281
284
|
return reconcile_schedules_runner(values)
|
282
285
|
|
283
286
|
async def _create(
|
284
|
-
self,
|
287
|
+
self,
|
288
|
+
work_pool_name: Optional[str] = None,
|
289
|
+
image: Optional[str] = None,
|
290
|
+
version_info: VersionInfo | None = None,
|
285
291
|
) -> UUID:
|
286
292
|
work_pool_name = work_pool_name or self.work_pool_name
|
287
293
|
|
@@ -312,6 +318,7 @@ class RunnerDeployment(BaseModel):
|
|
312
318
|
work_queue_name=self.work_queue_name,
|
313
319
|
work_pool_name=work_pool_name,
|
314
320
|
version=self.version,
|
321
|
+
version_info=version_info,
|
315
322
|
paused=self.paused,
|
316
323
|
schedules=self.schedules,
|
317
324
|
concurrency_limit=self.concurrency_limit,
|
@@ -367,7 +374,12 @@ class RunnerDeployment(BaseModel):
|
|
367
374
|
|
368
375
|
return deployment_id
|
369
376
|
|
370
|
-
async def _update(
|
377
|
+
async def _update(
|
378
|
+
self,
|
379
|
+
deployment_id: UUID,
|
380
|
+
client: PrefectClient,
|
381
|
+
version_info: VersionInfo | None,
|
382
|
+
):
|
371
383
|
parameter_openapi_schema = self._parameter_openapi_schema.model_dump(
|
372
384
|
exclude_unset=True
|
373
385
|
)
|
@@ -388,6 +400,7 @@ class RunnerDeployment(BaseModel):
|
|
388
400
|
deployment_id,
|
389
401
|
deployment=DeploymentUpdate(
|
390
402
|
**update_payload,
|
403
|
+
version_info=version_info,
|
391
404
|
parameter_openapi_schema=parameter_openapi_schema,
|
392
405
|
),
|
393
406
|
)
|
@@ -428,7 +441,10 @@ class RunnerDeployment(BaseModel):
|
|
428
441
|
|
429
442
|
@sync_compatible
|
430
443
|
async def apply(
|
431
|
-
self,
|
444
|
+
self,
|
445
|
+
work_pool_name: Optional[str] = None,
|
446
|
+
image: Optional[str] = None,
|
447
|
+
version_info: VersionInfo | None = None,
|
432
448
|
) -> UUID:
|
433
449
|
"""
|
434
450
|
Registers this deployment with the API and returns the deployment's ID.
|
@@ -439,7 +455,7 @@ class RunnerDeployment(BaseModel):
|
|
439
455
|
image: The registry, name, and tag of the Docker image to
|
440
456
|
use for this deployment. Only used when the deployment is
|
441
457
|
deployed to a work pool.
|
442
|
-
|
458
|
+
version_info: Version information for the deployment.
|
443
459
|
Returns:
|
444
460
|
The ID of the created deployment.
|
445
461
|
"""
|
@@ -448,13 +464,13 @@ class RunnerDeployment(BaseModel):
|
|
448
464
|
try:
|
449
465
|
deployment = await client.read_deployment_by_name(self.full_name)
|
450
466
|
except ObjectNotFound:
|
451
|
-
return await self._create(work_pool_name, image)
|
467
|
+
return await self._create(work_pool_name, image, version_info)
|
452
468
|
else:
|
453
469
|
if image:
|
454
470
|
self.job_variables["image"] = image
|
455
471
|
if work_pool_name:
|
456
472
|
self.work_pool_name = work_pool_name
|
457
|
-
return await self._update(deployment.id, client)
|
473
|
+
return await self._update(deployment.id, client, version_info)
|
458
474
|
|
459
475
|
async def _create_slas(self, deployment_id: UUID, client: PrefectClient):
|
460
476
|
if not isinstance(self._sla, list):
|
@@ -98,9 +98,31 @@ async def create_deployment(
|
|
98
98
|
)
|
99
99
|
|
100
100
|
# hydrate the input model into a full model
|
101
|
-
deployment_dict = deployment.model_dump(
|
102
|
-
exclude={"work_pool_name"},
|
101
|
+
deployment_dict: dict = deployment.model_dump(
|
102
|
+
exclude={"work_pool_name"},
|
103
|
+
exclude_unset=True,
|
103
104
|
)
|
105
|
+
|
106
|
+
requested_concurrency_limit = deployment_dict.pop(
|
107
|
+
"global_concurrency_limit_id", "unset"
|
108
|
+
)
|
109
|
+
if requested_concurrency_limit != "unset":
|
110
|
+
if requested_concurrency_limit:
|
111
|
+
concurrency_limit = (
|
112
|
+
await models.concurrency_limits_v2.read_concurrency_limit(
|
113
|
+
session=session,
|
114
|
+
concurrency_limit_id=requested_concurrency_limit,
|
115
|
+
)
|
116
|
+
)
|
117
|
+
|
118
|
+
if not concurrency_limit:
|
119
|
+
raise HTTPException(
|
120
|
+
status_code=status.HTTP_404_NOT_FOUND,
|
121
|
+
detail="Concurrency limit not found",
|
122
|
+
)
|
123
|
+
|
124
|
+
deployment_dict["concurrency_limit_id"] = requested_concurrency_limit
|
125
|
+
|
104
126
|
if deployment.work_pool_name and deployment.work_queue_name:
|
105
127
|
# If a specific pool name/queue name combination was provided, get the
|
106
128
|
# ID for that work pool queue.
|
@@ -300,8 +322,24 @@ async def update_deployment(
|
|
300
322
|
detail="Invalid schema: Unable to validate schema with circular references.",
|
301
323
|
)
|
302
324
|
|
325
|
+
if deployment.global_concurrency_limit_id:
|
326
|
+
concurrency_limit = (
|
327
|
+
await models.concurrency_limits_v2.read_concurrency_limit(
|
328
|
+
session=session,
|
329
|
+
concurrency_limit_id=deployment.global_concurrency_limit_id,
|
330
|
+
)
|
331
|
+
)
|
332
|
+
|
333
|
+
if not concurrency_limit:
|
334
|
+
raise HTTPException(
|
335
|
+
status_code=status.HTTP_404_NOT_FOUND,
|
336
|
+
detail="Concurrency limit not found",
|
337
|
+
)
|
338
|
+
|
303
339
|
result = await models.deployments.update_deployment(
|
304
|
-
session=session,
|
340
|
+
session=session,
|
341
|
+
deployment_id=deployment_id,
|
342
|
+
deployment=deployment,
|
305
343
|
)
|
306
344
|
|
307
345
|
for schedule in schedules_to_patch:
|
prefect/workers/base.py
CHANGED
@@ -48,6 +48,7 @@ from prefect.client.schemas.objects import (
|
|
48
48
|
WorkPool,
|
49
49
|
)
|
50
50
|
from prefect.client.utilities import inject_client
|
51
|
+
from prefect.context import FlowRunContext, TagsContext
|
51
52
|
from prefect.events import Event, RelatedResource, emit_event
|
52
53
|
from prefect.events.related import object_as_related_resource, tags_as_related_resources
|
53
54
|
from prefect.exceptions import (
|
@@ -75,6 +76,7 @@ from prefect.states import (
|
|
75
76
|
Pending,
|
76
77
|
exception_to_failed_state,
|
77
78
|
)
|
79
|
+
from prefect.tasks import Task
|
78
80
|
from prefect.types import KeyValueLabels
|
79
81
|
from prefect.utilities.dispatch import get_registry_for_type, register_base_type
|
80
82
|
from prefect.utilities.engine import propose_state
|
@@ -720,6 +722,15 @@ class BaseWorker(abc.ABC, Generic[C, V, R]):
|
|
720
722
|
if self._runs_task_group is None:
|
721
723
|
raise RuntimeError("Worker not properly initialized")
|
722
724
|
|
725
|
+
from prefect.results import get_result_store
|
726
|
+
|
727
|
+
current_result_store = get_result_store()
|
728
|
+
if current_result_store.result_storage is None and flow.result_storage is None:
|
729
|
+
self._logger.warning(
|
730
|
+
f"Flow {flow.name!r} has no result storage configured. Please configure "
|
731
|
+
"result storage for the flow if you want to retrieve the result for the flow run."
|
732
|
+
)
|
733
|
+
|
723
734
|
flow_run = await self._runs_task_group.start(
|
724
735
|
partial(
|
725
736
|
self._submit_adhoc_run,
|
@@ -766,12 +777,28 @@ class BaseWorker(abc.ABC, Generic[C, V, R]):
|
|
766
777
|
)
|
767
778
|
|
768
779
|
job_variables = (job_variables or {}) | {"command": " ".join(execute_command)}
|
780
|
+
parameters = parameters or {}
|
781
|
+
parent_task_run = None
|
782
|
+
|
783
|
+
if flow_run_ctx := FlowRunContext.get():
|
784
|
+
parent_task = Task[Any, Any](
|
785
|
+
name=flow.name,
|
786
|
+
fn=flow.fn,
|
787
|
+
version=flow.version,
|
788
|
+
)
|
789
|
+
parent_task_run = await parent_task.create_run(
|
790
|
+
flow_run_context=flow_run_ctx,
|
791
|
+
parameters=parameters,
|
792
|
+
)
|
793
|
+
|
769
794
|
flow_run = await self.client.create_flow_run(
|
770
795
|
flow,
|
771
|
-
parameters=parameters,
|
796
|
+
parameters=flow.serialize_parameters(parameters),
|
772
797
|
state=Pending(),
|
773
798
|
job_variables=job_variables,
|
774
799
|
work_pool_name=self.work_pool.name,
|
800
|
+
tags=TagsContext.get().current_tags,
|
801
|
+
parent_task_run_id=getattr(parent_task_run, "id", None),
|
775
802
|
)
|
776
803
|
if task_status is not None:
|
777
804
|
# Emit the flow run object to .submit to allow it to return a future as soon as possible
|
@@ -1,8 +1,9 @@
|
|
1
1
|
prefect/.prefectignore,sha256=awSprvKT0vI8a64mEOLrMxhxqcO-b0ERQeYpA2rNKVQ,390
|
2
2
|
prefect/__init__.py,sha256=iCdcC5ZmeewikCdnPEP6YBAjPNV5dvfxpYCTpw30Hkw,3685
|
3
3
|
prefect/__main__.py,sha256=WFjw3kaYJY6pOTA7WDOgqjsz8zUEUZHCcj3P5wyVa-g,66
|
4
|
-
prefect/_build_info.py,sha256=
|
4
|
+
prefect/_build_info.py,sha256=zUk4_brUMO3gk7qftKtl1X8H2yE2LpC3NTQ0fZgfi9E,185
|
5
5
|
prefect/_result_records.py,sha256=S6QmsODkehGVSzbMm6ig022PYbI6gNKz671p_8kBYx4,7789
|
6
|
+
prefect/_versioning.py,sha256=4zp4Dl9dJWsoItj4AAhRxYtP3CMdo-7nG0dyv3Xz4nU,5361
|
6
7
|
prefect/_waiters.py,sha256=Ia2ITaXdHzevtyWIgJoOg95lrEXQqNEOquHvw3T33UQ,9026
|
7
8
|
prefect/agent.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
|
8
9
|
prefect/artifacts.py,sha256=dMBUOAWnUamzjb5HSqwB5-GR2Qb-Gxee26XG5NDCUuw,22720
|
@@ -31,8 +32,9 @@ prefect/tasks.py,sha256=EpMw5O1B9pAFVraC0KzytMOKi8iy7ZYnKWRs7WtvogU,74742
|
|
31
32
|
prefect/transactions.py,sha256=uIoPNudzJzH6NrMJhrgr5lyh6JxOJQqT1GvrXt69yNw,26068
|
32
33
|
prefect/variables.py,sha256=dCK3vX7TbkqXZhnNT_v7rcGh3ISRqoR6pJVLpoll3Js,8342
|
33
34
|
prefect/_experimental/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
|
-
prefect/_experimental/bundles.py,sha256=E5nRaLVTbYCrACXZcRJCd4ssOcQU-Z26ewCb_7tPeTM,6687
|
35
35
|
prefect/_experimental/lineage.py,sha256=8LssReoq7eLtQScUCu-7FCtrWoRZstXKRdpO0PxgbKg,9958
|
36
|
+
prefect/_experimental/bundles/__init__.py,sha256=9e7L7drTpHG82fnr6kuABkpk3SdqUNF-8HB2y6vD5U4,7108
|
37
|
+
prefect/_experimental/bundles/execute.py,sha256=xBwk1H1Fui1lt2G7Fgd6yDArqSmqZiYEA7Y7R4f7SDM,699
|
36
38
|
prefect/_experimental/sla/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
39
|
prefect/_experimental/sla/client.py,sha256=XTkYHFZiBy_O7RgUyGEdl9MxaHP-6fEAKBk3ksNQobU,3611
|
38
40
|
prefect/_experimental/sla/objects.py,sha256=Ja1z2XUgkklvtNTumKWWjojEM5I0L_RjdGv61sRbVP0,2834
|
@@ -98,7 +100,7 @@ prefect/client/orchestration/_blocks_types/client.py,sha256=alA4xD-yp3mycAbzMyRu
|
|
98
100
|
prefect/client/orchestration/_concurrency_limits/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
99
101
|
prefect/client/orchestration/_concurrency_limits/client.py,sha256=r_oyY7hQbgyG1rntwe7WWcsraQHBKhk6MOPFUAHWiVc,23678
|
100
102
|
prefect/client/orchestration/_deployments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
101
|
-
prefect/client/orchestration/_deployments/client.py,sha256=
|
103
|
+
prefect/client/orchestration/_deployments/client.py,sha256=a_sUmznQC3lBLxXfu4hIIbszbUc28sWXtCioQoNgZPk,43876
|
102
104
|
prefect/client/orchestration/_flow_runs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
103
105
|
prefect/client/orchestration/_flow_runs/client.py,sha256=fjh5J-LG8tsny7BGYEvynbuGuHDAudYHpx-PamL0GYQ,32220
|
104
106
|
prefect/client/orchestration/_flows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -136,7 +138,7 @@ prefect/deployments/__init__.py,sha256=_wb7NxDKhq11z9MjYsPckmT3o6MRhGLRgCV9TmvYt
|
|
136
138
|
prefect/deployments/base.py,sha256=YY7g8MN6qzjNEjEA8wQXPxCrd47WnACIUeSRtI4nrEk,11849
|
137
139
|
prefect/deployments/deployments.py,sha256=K3Rgnpjxo_T8I8LMwlq24OKqZiZBTE8-YnPg-YGUStM,171
|
138
140
|
prefect/deployments/flow_runs.py,sha256=NYe-Bphsy6ENLqSSfywQuX5cRZt-uVgzqGmOsf3Sqw4,7643
|
139
|
-
prefect/deployments/runner.py,sha256=
|
141
|
+
prefect/deployments/runner.py,sha256=_VqbkXvPVvdyFVkRsr5emi26cJmu5-2uhtVUoE0EkNA,54805
|
140
142
|
prefect/deployments/schedules.py,sha256=2eL1-w8qXtwKVkgfUK7cuamwpKK3X6tN1QYTDa_gWxU,2190
|
141
143
|
prefect/deployments/steps/__init__.py,sha256=Dlz9VqMRyG1Gal8dj8vfGpPr0LyQhZdvcciozkK8WoY,206
|
142
144
|
prefect/deployments/steps/core.py,sha256=ulSgBFSx1lhBt1fP-UxebrernkumBDlympR6IPffV1g,6900
|
@@ -205,7 +207,7 @@ prefect/server/api/concurrency_limits.py,sha256=E5TB2cJPIZjnxnm1pGxUJnwMDz5CS58g
|
|
205
207
|
prefect/server/api/concurrency_limits_v2.py,sha256=PGjG7W2Z65OojNTP0ezFu2z69plXo1N8paqwHlHAPj0,10183
|
206
208
|
prefect/server/api/csrf_token.py,sha256=BwysSjQAhre7O0OY_LF3ZcIiO53FdMQroNT11Q6OcOM,1344
|
207
209
|
prefect/server/api/dependencies.py,sha256=VujfcIGn41TGJxUunFHVabY5hE-6nY6uSHyhNFj8PdI,6634
|
208
|
-
prefect/server/api/deployments.py,sha256=
|
210
|
+
prefect/server/api/deployments.py,sha256=ppYA3b2csnw32-SbOXz5Dm_IsnmPKczNiSbqCzusFKI,39332
|
209
211
|
prefect/server/api/events.py,sha256=3-Qdt6ORxFv3nLoogQqvd72zEulJSoAmcqZto2OULuk,9907
|
210
212
|
prefect/server/api/flow_run_notification_policies.py,sha256=F8xNm6bgZTC3nFe9xCUJS4NlU9tLXZ8fShtJqmhT2m4,4828
|
211
213
|
prefect/server/api/flow_run_states.py,sha256=lIdxVE9CqLgtDCuH9bTaKkzHNL81FPrr11liPzvONrw,1661
|
@@ -311,13 +313,13 @@ prefect/utilities/schema_tools/__init__.py,sha256=At3rMHd2g_Em2P3_dFQlFgqR_EpBwr
|
|
311
313
|
prefect/utilities/schema_tools/hydration.py,sha256=NkRhWkNfxxFmVGhNDfmxdK_xeKaEhs3a42q83Sg9cT4,9436
|
312
314
|
prefect/utilities/schema_tools/validation.py,sha256=Wix26IVR-ZJ32-6MX2pHhrwm3reB-Q4iB6_phn85OKE,10743
|
313
315
|
prefect/workers/__init__.py,sha256=EaM1F0RZ-XIJaGeTKLsXDnfOPHzVWk5bk0_c4BVS44M,64
|
314
|
-
prefect/workers/base.py,sha256=
|
316
|
+
prefect/workers/base.py,sha256=B3K80V-bZ1oI-5iwM2jw93is9srTSCLNN2lvVtlmB7g,60267
|
315
317
|
prefect/workers/block.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
|
316
318
|
prefect/workers/cloud.py,sha256=dPvG1jDGD5HSH7aM2utwtk6RaJ9qg13XjkA0lAIgQmY,287
|
317
319
|
prefect/workers/process.py,sha256=Yi5D0U5AQ51wHT86GdwtImXSefe0gJf3LGq4r4z9zwM,11090
|
318
320
|
prefect/workers/server.py,sha256=2pmVeJZiVbEK02SO6BEZaBIvHMsn6G8LzjW8BXyiTtk,1952
|
319
321
|
prefect/workers/utilities.py,sha256=VfPfAlGtTuDj0-Kb8WlMgAuOfgXCdrGAnKMapPSBrwc,2483
|
320
|
-
prefect_client-3.3.6.
|
321
|
-
prefect_client-3.3.6.
|
322
|
-
prefect_client-3.3.6.
|
323
|
-
prefect_client-3.3.6.
|
322
|
+
prefect_client-3.3.6.dev4.dist-info/METADATA,sha256=RsEw_afSzFcD5K033alWN4wcgZBKx3xYewDGIk6R5hE,7471
|
323
|
+
prefect_client-3.3.6.dev4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
324
|
+
prefect_client-3.3.6.dev4.dist-info/licenses/LICENSE,sha256=MCxsn8osAkzfxKC4CC_dLcUkU8DZLkyihZ8mGs3Ah3Q,11357
|
325
|
+
prefect_client-3.3.6.dev4.dist-info/RECORD,,
|
File without changes
|
{prefect_client-3.3.6.dev2.dist-info → prefect_client-3.3.6.dev4.dist-info}/licenses/LICENSE
RENAMED
File without changes
|