prefect-client 3.0.0rc20__py3-none-any.whl → 3.0.2__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/_internal/compatibility/deprecated.py +1 -1
- prefect/_internal/compatibility/migration.py +1 -1
- prefect/artifacts.py +1 -1
- prefect/blocks/core.py +3 -4
- prefect/blocks/notifications.py +31 -10
- prefect/blocks/system.py +4 -4
- prefect/blocks/webhook.py +11 -1
- prefect/client/cloud.py +2 -1
- prefect/client/orchestration.py +93 -21
- prefect/client/schemas/actions.py +2 -2
- prefect/client/schemas/objects.py +24 -6
- prefect/client/types/flexible_schedule_list.py +1 -1
- prefect/concurrency/asyncio.py +45 -6
- prefect/concurrency/services.py +1 -1
- prefect/concurrency/sync.py +21 -27
- prefect/concurrency/v1/asyncio.py +3 -0
- prefect/concurrency/v1/sync.py +4 -5
- prefect/context.py +11 -9
- prefect/deployments/runner.py +4 -3
- prefect/events/actions.py +6 -0
- prefect/exceptions.py +6 -0
- prefect/filesystems.py +5 -3
- prefect/flow_engine.py +22 -11
- prefect/flows.py +0 -2
- prefect/futures.py +2 -1
- prefect/locking/__init__.py +0 -0
- prefect/locking/filesystem.py +243 -0
- prefect/locking/memory.py +213 -0
- prefect/locking/protocol.py +122 -0
- prefect/logging/handlers.py +0 -2
- prefect/logging/loggers.py +0 -18
- prefect/logging/logging.yml +1 -0
- prefect/main.py +19 -5
- prefect/records/base.py +12 -0
- prefect/records/filesystem.py +10 -4
- prefect/records/memory.py +6 -0
- prefect/records/result_store.py +18 -6
- prefect/results.py +702 -205
- prefect/runner/runner.py +74 -5
- prefect/settings.py +11 -4
- prefect/states.py +40 -23
- prefect/task_engine.py +39 -37
- prefect/task_worker.py +6 -4
- prefect/tasks.py +24 -6
- prefect/transactions.py +116 -54
- prefect/utilities/callables.py +1 -3
- prefect/utilities/engine.py +16 -8
- prefect/utilities/importtools.py +1 -0
- prefect/utilities/urls.py +70 -12
- prefect/variables.py +34 -24
- prefect/workers/base.py +14 -6
- prefect/workers/process.py +1 -3
- {prefect_client-3.0.0rc20.dist-info → prefect_client-3.0.2.dist-info}/METADATA +2 -2
- {prefect_client-3.0.0rc20.dist-info → prefect_client-3.0.2.dist-info}/RECORD +57 -53
- {prefect_client-3.0.0rc20.dist-info → prefect_client-3.0.2.dist-info}/LICENSE +0 -0
- {prefect_client-3.0.0rc20.dist-info → prefect_client-3.0.2.dist-info}/WHEEL +0 -0
- {prefect_client-3.0.0rc20.dist-info → prefect_client-3.0.2.dist-info}/top_level.txt +0 -0
prefect/records/filesystem.py
CHANGED
@@ -6,6 +6,7 @@ from typing import Dict, Optional
|
|
6
6
|
import pendulum
|
7
7
|
from typing_extensions import TypedDict
|
8
8
|
|
9
|
+
from prefect._internal.compatibility import deprecated
|
9
10
|
from prefect.logging.loggers import get_logger
|
10
11
|
from prefect.records.base import RecordStore, TransactionRecord
|
11
12
|
from prefect.results import BaseResult
|
@@ -29,6 +30,11 @@ class _LockInfo(TypedDict):
|
|
29
30
|
path: Path
|
30
31
|
|
31
32
|
|
33
|
+
@deprecated.deprecated_class(
|
34
|
+
start_date="Sep 2024",
|
35
|
+
end_date="Nov 2024",
|
36
|
+
help="Use `ResultStore` with a `LocalFileSystem` for `metadata_storage` and a `FileSystemLockManager` instead.",
|
37
|
+
)
|
32
38
|
class FileSystemRecordStore(RecordStore):
|
33
39
|
"""
|
34
40
|
A record store that stores data on the local filesystem.
|
@@ -56,7 +62,6 @@ class FileSystemRecordStore(RecordStore):
|
|
56
62
|
def _get_lock_info(self, key: str, use_cache=True) -> Optional[_LockInfo]:
|
57
63
|
if use_cache:
|
58
64
|
if (lock_info := self._locks.get(key)) is not None:
|
59
|
-
print("Got lock info from cache")
|
60
65
|
return lock_info
|
61
66
|
|
62
67
|
lock_path = self._lock_path_for_key(key)
|
@@ -70,13 +75,12 @@ class FileSystemRecordStore(RecordStore):
|
|
70
75
|
pendulum.parse(expiration) if expiration is not None else None
|
71
76
|
)
|
72
77
|
self._locks[key] = lock_info
|
73
|
-
print("Got lock info from file")
|
74
78
|
return lock_info
|
75
79
|
except FileNotFoundError:
|
76
80
|
return None
|
77
81
|
|
78
82
|
def read(
|
79
|
-
self, key: str, holder: Optional[str] = None
|
83
|
+
self, key: str, holder: Optional[str] = None, timeout: Optional[float] = None
|
80
84
|
) -> Optional[TransactionRecord]:
|
81
85
|
if not self.exists(key):
|
82
86
|
return None
|
@@ -84,7 +88,9 @@ class FileSystemRecordStore(RecordStore):
|
|
84
88
|
holder = holder or self.generate_default_holder()
|
85
89
|
|
86
90
|
if self.is_locked(key) and not self.is_lock_holder(key, holder):
|
87
|
-
self.wait_for_lock(key)
|
91
|
+
unlocked = self.wait_for_lock(key, timeout=timeout)
|
92
|
+
if not unlocked:
|
93
|
+
return None
|
88
94
|
record_data = self.records_directory.joinpath(key).read_text()
|
89
95
|
return TransactionRecord(
|
90
96
|
key=key, result=BaseResult.model_validate_json(record_data)
|
prefect/records/memory.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import threading
|
2
2
|
from typing import Dict, Optional, TypedDict
|
3
3
|
|
4
|
+
from prefect._internal.compatibility import deprecated
|
4
5
|
from prefect.results import BaseResult
|
5
6
|
from prefect.transactions import IsolationLevel
|
6
7
|
|
@@ -22,6 +23,11 @@ class _LockInfo(TypedDict):
|
|
22
23
|
expiration_timer: Optional[threading.Timer]
|
23
24
|
|
24
25
|
|
26
|
+
@deprecated.deprecated_class(
|
27
|
+
start_date="Sep 2024",
|
28
|
+
end_date="Nov 2024",
|
29
|
+
help="Use `ResultStore` with a `MemoryLockManager` instead.",
|
30
|
+
)
|
25
31
|
class MemoryRecordStore(RecordStore):
|
26
32
|
"""
|
27
33
|
A record store that stores data in memory.
|
prefect/records/result_store.py
CHANGED
@@ -3,16 +3,28 @@ from typing import Any, Optional
|
|
3
3
|
|
4
4
|
import pendulum
|
5
5
|
|
6
|
-
from prefect.
|
6
|
+
from prefect._internal.compatibility import deprecated
|
7
|
+
from prefect.results import BaseResult, PersistedResult, ResultStore
|
7
8
|
from prefect.transactions import IsolationLevel
|
8
9
|
from prefect.utilities.asyncutils import run_coro_as_sync
|
9
10
|
|
10
11
|
from .base import RecordStore, TransactionRecord
|
11
12
|
|
12
13
|
|
14
|
+
@deprecated.deprecated_class(
|
15
|
+
start_date="Sep 2024",
|
16
|
+
end_date="Nov 2024",
|
17
|
+
help="Use `ResultStore` directly instead.",
|
18
|
+
)
|
13
19
|
@dataclass
|
14
|
-
class
|
15
|
-
|
20
|
+
class ResultRecordStore(RecordStore):
|
21
|
+
"""
|
22
|
+
A record store for result records.
|
23
|
+
|
24
|
+
Collocates result metadata with result data.
|
25
|
+
"""
|
26
|
+
|
27
|
+
result_store: ResultStore
|
16
28
|
cache: Optional[PersistedResult] = None
|
17
29
|
|
18
30
|
def exists(self, key: str) -> bool:
|
@@ -38,8 +50,8 @@ class ResultFactoryStore(RecordStore):
|
|
38
50
|
return TransactionRecord(key=key, result=self.cache)
|
39
51
|
try:
|
40
52
|
result = PersistedResult(
|
41
|
-
serializer_type=self.
|
42
|
-
storage_block_id=self.
|
53
|
+
serializer_type=self.result_store.serializer.type,
|
54
|
+
storage_block_id=self.result_store.result_storage_block_id,
|
43
55
|
storage_key=key,
|
44
56
|
)
|
45
57
|
return TransactionRecord(key=key, result=result)
|
@@ -52,7 +64,7 @@ class ResultFactoryStore(RecordStore):
|
|
52
64
|
# if the value is already a persisted result, write it
|
53
65
|
result.write(_sync=True)
|
54
66
|
elif not isinstance(result, BaseResult):
|
55
|
-
run_coro_as_sync(self.
|
67
|
+
run_coro_as_sync(self.result_store.create_result(obj=result, key=key))
|
56
68
|
|
57
69
|
def supports_isolation_level(self, isolation_level: IsolationLevel) -> bool:
|
58
70
|
return isolation_level == IsolationLevel.READ_COMMITTED
|