Skip to content

Commit 5231a99

Browse files
desertaxleclaude
andauthored
Remove deprecated code Runner functionality and system Blocks (#19307)
Co-authored-by: Claude <[email protected]>
1 parent 79232b9 commit 5231a99

File tree

20 files changed

+52
-1602
lines changed

20 files changed

+52
-1602
lines changed

.github/workflows/integration-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ jobs:
161161
pytest-xdist \
162162
pytest-timeout \
163163
pytest-env
164-
pytest --ignore=integration-tests/test_task_worker.py --ignore=integration-tests/test_concurrency_leases.py integration-tests/ -n auto -vv
164+
pytest --ignore=integration-tests/test_task_worker.py --ignore=integration-tests/test_concurrency_leases.py --ignore=integration-tests/test_deploy.py integration-tests/ -n auto -vv
165165
166166
sqlite-3-24-0:
167167
name: Test SQLite 3.24.0 Compatibility

integration-tests/test_deploy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ async def read_flow_run(flow_run_id):
1919

2020
def test_deploy():
2121
tmp_dir = Path(tempfile.mkdtemp())
22+
runner_dir = tmp_dir / "runner"
23+
runner_dir.mkdir()
2224

2325
try:
2426
subprocess.check_call(
@@ -40,13 +42,13 @@ def test_deploy():
4042
# Create GitRepository and set base path to temp directory
4143
# to avoid race conditions with parallel tests
4244
git_repo = GitRepository(
43-
url="https://github.com/PrefectHQ/prefect-recipes.git",
45+
url="https://github.com/PrefectHQ/examples.git",
4446
)
4547
git_repo.set_base_path(tmp_dir)
4648

4749
flow_instance = prefect.flow.from_source(
4850
source=git_repo,
49-
entrypoint="flows-starter/hello.py:hello",
51+
entrypoint="flows/hello_world.py:hello",
5052
)
5153

5254
flow_instance.deploy(
@@ -69,6 +71,7 @@ def test_deploy():
6971
],
7072
stdout=sys.stdout,
7173
stderr=sys.stderr,
74+
cwd=runner_dir,
7275
)
7376

7477
flow_run = anyio.run(read_flow_run, flow_run.id)

integration-tests/test_load_flows_concurrently.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
import asyncio
2+
import tempfile
3+
from pathlib import Path
24
from typing import Any
35

46
from prefect import Flow
57
from prefect.runner.storage import GitRepository
68

79

8-
async def load_flow(entrypoint: str) -> Flow[..., Any]:
10+
async def load_flow(entrypoint: str, base_dir: Path) -> Flow[..., Any]:
11+
source = GitRepository(
12+
url="https://github.com/PrefectHQ/examples.git",
13+
)
14+
source.set_base_path(base_dir)
915
return await Flow.from_source( # type: ignore # sync_compatible causes issues
10-
source=GitRepository(
11-
url="https://github.com/PrefectHQ/examples.git",
12-
),
16+
source=source,
1317
entrypoint=entrypoint,
1418
)
1519

1620

17-
async def test_iteration():
18-
entrypoints = [
19-
"flows/hello_world.py:hello",
20-
"flows/whoami.py:whoami",
21-
] * 5 # Load each flow 5 times concurrently
22-
futures = [load_flow(entrypoint) for entrypoint in entrypoints]
23-
flows = await asyncio.gather(*futures)
24-
return len(flows)
21+
async def run_iteration():
22+
with tempfile.TemporaryDirectory() as tmpdir:
23+
entrypoints = [
24+
"flows/hello_world.py:hello",
25+
"flows/whoami.py:whoami",
26+
] * 5 # Load each flow 5 times concurrently
27+
futures = [load_flow(entrypoint, Path(tmpdir)) for entrypoint in entrypoints]
28+
flows = await asyncio.gather(*futures)
29+
return len(flows)
2530

2631

2732
async def test_load_flows_concurrently():
2833
for i in range(10): # Run 10 iterations
2934
try:
30-
count = await test_iteration()
35+
count = await run_iteration()
3136
print(f"Iteration {i + 1}: Successfully loaded {count} flows")
3237
except Exception as e:
3338
print(f"Iteration {i + 1}: Failed with error: {str(e)}")

src/prefect/blocks/system.py

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from __future__ import annotations
22

33
import json
4-
from datetime import datetime
5-
from typing import Annotated, Any, Generic, TypeVar, Union
4+
from typing import Annotated, Generic, TypeVar, Union
65

76
from pydantic import (
87
Field,
@@ -14,9 +13,7 @@
1413
)
1514
from pydantic import Secret as PydanticSecret
1615

17-
from prefect._internal.compatibility.deprecated import deprecated_class
1816
from prefect.blocks.core import Block
19-
from prefect.types import DateTime as PydanticDateTime
2017

2118
_SecretValueType = Union[
2219
Annotated[StrictStr, Field(title="string")],
@@ -26,97 +23,6 @@
2623
T = TypeVar("T", bound=_SecretValueType)
2724

2825

29-
@deprecated_class(
30-
start_date=datetime(2024, 6, 1),
31-
end_date=datetime(2025, 6, 1),
32-
help="Use Variables to store json data instead.",
33-
)
34-
class JSON(Block):
35-
"""
36-
A block that represents JSON. Deprecated, please use Variables to store JSON data instead.
37-
38-
Attributes:
39-
value: A JSON-compatible value.
40-
41-
Example:
42-
Load a stored JSON value:
43-
```python
44-
from prefect.blocks.system import JSON
45-
46-
json_block = JSON.load("BLOCK_NAME")
47-
```
48-
"""
49-
50-
_logo_url = HttpUrl(
51-
"https://cdn.sanity.io/images/3ugk85nk/production/4fcef2294b6eeb423b1332d1ece5156bf296ff96-48x48.png"
52-
)
53-
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
54-
55-
value: Any = Field(default=..., description="A JSON-compatible value.")
56-
57-
58-
@deprecated_class(
59-
start_date=datetime(2024, 6, 1),
60-
end_date=datetime(2025, 6, 1),
61-
help="Use Variables to store string data instead.",
62-
)
63-
class String(Block):
64-
"""
65-
A block that represents a string. Deprecated, please use Variables to store string data instead.
66-
67-
Attributes:
68-
value: A string value.
69-
70-
Example:
71-
Load a stored string value:
72-
```python
73-
from prefect.blocks.system import String
74-
75-
string_block = String.load("BLOCK_NAME")
76-
```
77-
"""
78-
79-
_logo_url = HttpUrl(
80-
"https://cdn.sanity.io/images/3ugk85nk/production/c262ea2c80a2c043564e8763f3370c3db5a6b3e6-48x48.png"
81-
)
82-
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
83-
84-
value: str = Field(default=..., description="A string value.")
85-
86-
87-
@deprecated_class(
88-
start_date=datetime(2024, 6, 1),
89-
end_date=datetime(2025, 6, 1),
90-
help="Use Variables to store datetime data instead.",
91-
)
92-
class DateTime(Block):
93-
"""
94-
A block that represents a datetime. Deprecated, please use Variables to store datetime data instead.
95-
96-
Attributes:
97-
value: An ISO 8601-compatible datetime value.
98-
99-
Example:
100-
Load a stored JSON value:
101-
```python
102-
from prefect.blocks.system import DateTime
103-
104-
data_time_block = DateTime.load("BLOCK_NAME")
105-
```
106-
"""
107-
108-
_block_type_name = "Date Time"
109-
_logo_url = HttpUrl(
110-
"https://cdn.sanity.io/images/3ugk85nk/production/8b3da9a6621e92108b8e6a75b82e15374e170ff7-48x48.png"
111-
)
112-
_documentation_url = HttpUrl("https://docs.prefect.io/latest/develop/blocks")
113-
114-
value: PydanticDateTime = Field(
115-
default=...,
116-
description="An ISO 8601-compatible datetime value.",
117-
)
118-
119-
12026
class Secret(Block, Generic[T]):
12127
"""
12228
A block that represents a secret value. The value stored in this block will be obfuscated when

src/prefect/cli/cloud/__init__.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import warnings
1212
import webbrowser
1313
from contextlib import asynccontextmanager
14-
from datetime import datetime
1514
from typing import (
1615
TYPE_CHECKING,
1716
Iterable,
@@ -615,34 +614,6 @@ async def logout():
615614
exit_with_success("Logged out from Prefect Cloud.")
616615

617616

618-
@cloud_app.command(
619-
deprecated=True,
620-
deprecated_name="prefect cloud open",
621-
deprecated_start_date=datetime(2024, 10, 1),
622-
deprecated_help="Use `prefect dashboard open` to open the Prefect UI.",
623-
)
624-
async def open():
625-
"""
626-
Open the Prefect Cloud UI in the browser.
627-
"""
628-
confirm_logged_in()
629-
630-
async with get_cloud_client() as client:
631-
try:
632-
current_workspace = await client.read_current_workspace()
633-
except ValueError:
634-
exit_with_error(
635-
"There is no current workspace set - set one with `prefect cloud workspace"
636-
" set --workspace <workspace>`."
637-
)
638-
639-
ui_url = current_workspace.ui_url()
640-
641-
await run_sync_in_worker_thread(webbrowser.open_new_tab, ui_url)
642-
643-
exit_with_success(f"Opened {current_workspace.handle!r} in browser.")
644-
645-
646617
@workspace_app.command()
647618
async def ls():
648619
"""List available workspaces."""

src/prefect/results.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import socket
66
import threading
77
import uuid
8-
from datetime import datetime
98
from functools import partial
109
from operator import methodcaller
1110
from pathlib import Path
@@ -35,7 +34,6 @@
3534
import prefect.types._datetime
3635
from prefect._internal.compatibility.async_dispatch import async_dispatch
3736
from prefect._internal.compatibility.blocks import call_explicitly_async_block_method
38-
from prefect._internal.compatibility.deprecated import deprecated_callable
3937
from prefect._internal.concurrency.event_loop import get_running_loop
4038
from prefect._result_records import R, ResultRecord, ResultRecordMetadata
4139
from prefect.blocks.core import Block
@@ -965,50 +963,6 @@ async def await_for_lock(self, key: str, timeout: float | None = None) -> bool:
965963
)
966964
return await self.lock_manager.await_for_lock(key, timeout)
967965

968-
# TODO: These two methods need to find a new home
969-
970-
@deprecated_callable(
971-
start_date=datetime(2025, 5, 10),
972-
end_date=datetime(2025, 11, 10),
973-
help="Use `store_parameters` from `prefect.task_worker` instead.",
974-
)
975-
@sync_compatible
976-
async def store_parameters(self, identifier: UUID, parameters: dict[str, Any]):
977-
record = ResultRecord(
978-
result=parameters,
979-
metadata=ResultRecordMetadata(
980-
serializer=self.serializer, storage_key=str(identifier)
981-
),
982-
)
983-
984-
await call_explicitly_async_block_method(
985-
self.result_storage,
986-
"write_path",
987-
(f"parameters/{identifier}",),
988-
{"content": record.serialize()},
989-
)
990-
991-
@deprecated_callable(
992-
start_date=datetime(2025, 5, 10),
993-
end_date=datetime(2025, 11, 10),
994-
help="Use `read_parameters` from `prefect.task_worker` instead.",
995-
)
996-
@sync_compatible
997-
async def read_parameters(self, identifier: UUID) -> dict[str, Any]:
998-
if self.result_storage is None:
999-
raise ValueError(
1000-
"Result store is not configured - must have a result storage block to read parameters"
1001-
)
1002-
record: ResultRecord[Any] = ResultRecord[Any].deserialize(
1003-
await call_explicitly_async_block_method(
1004-
self.result_storage,
1005-
"read_path",
1006-
(f"parameters/{identifier}",),
1007-
{},
1008-
)
1009-
)
1010-
return record.result
1011-
1012966

1013967
def get_result_store() -> ResultStore:
1014968
"""

src/prefect/runner/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from .runner import Runner
2-
from .submit import submit_to_runner, wait_for_submitted_runs
32

4-
__all__ = ["Runner", "submit_to_runner", "wait_for_submitted_runs"]
3+
__all__ = ["Runner"]

0 commit comments

Comments
 (0)