prefect-client 2.16.3__py3-none-any.whl → 2.16.5__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.
Files changed (48) hide show
  1. prefect/__init__.py +4 -1
  2. prefect/_internal/compatibility/deprecated.py +28 -0
  3. prefect/_internal/concurrency/calls.py +3 -2
  4. prefect/_internal/pydantic/__init__.py +2 -0
  5. prefect/_internal/pydantic/_compat.py +180 -0
  6. prefect/agent.py +14 -6
  7. prefect/artifacts.py +185 -0
  8. prefect/client/base.py +80 -10
  9. prefect/client/cloud.py +1 -1
  10. prefect/client/orchestration.py +62 -1
  11. prefect/client/schemas/actions.py +2 -0
  12. prefect/client/schemas/objects.py +16 -0
  13. prefect/client/schemas/responses.py +1 -0
  14. prefect/client/subscriptions.py +13 -7
  15. prefect/client/utilities.py +55 -28
  16. prefect/deployments/deployments.py +49 -23
  17. prefect/deployments/schedules.py +13 -0
  18. prefect/deprecated/data_documents.py +2 -2
  19. prefect/deprecated/packaging/__init__.py +12 -0
  20. prefect/{packaging → deprecated/packaging}/base.py +21 -0
  21. prefect/{packaging → deprecated/packaging}/docker.py +18 -2
  22. prefect/{packaging → deprecated/packaging}/file.py +21 -3
  23. prefect/{packaging → deprecated/packaging}/orion.py +21 -3
  24. prefect/{packaging → deprecated/packaging}/serializers.py +22 -1
  25. prefect/engine.py +10 -6
  26. prefect/events/clients.py +9 -3
  27. prefect/events/related.py +1 -1
  28. prefect/events/schemas.py +45 -1
  29. prefect/filesystems.py +39 -1
  30. prefect/flows.py +12 -4
  31. prefect/infrastructure/base.py +15 -0
  32. prefect/infrastructure/container.py +23 -0
  33. prefect/infrastructure/kubernetes.py +17 -0
  34. prefect/infrastructure/process.py +16 -0
  35. prefect/server/api/collections_data/views/aggregate-worker-metadata.json +14 -2
  36. prefect/settings.py +62 -8
  37. prefect/task_server.py +28 -5
  38. prefect/tasks.py +44 -3
  39. prefect/utilities/callables.py +3 -1
  40. prefect/utilities/schema_tools/__init__.py +11 -0
  41. prefect/variables.py +4 -4
  42. prefect/workers/base.py +6 -1
  43. {prefect_client-2.16.3.dist-info → prefect_client-2.16.5.dist-info}/METADATA +2 -1
  44. {prefect_client-2.16.3.dist-info → prefect_client-2.16.5.dist-info}/RECORD +47 -45
  45. {prefect_client-2.16.3.dist-info → prefect_client-2.16.5.dist-info}/WHEEL +1 -1
  46. prefect/packaging/__init__.py +0 -8
  47. {prefect_client-2.16.3.dist-info → prefect_client-2.16.5.dist-info}/LICENSE +0 -0
  48. {prefect_client-2.16.3.dist-info → prefect_client-2.16.5.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,11 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+ This module is deprecated as of March 2024 and will not be available after September 2024.
4
+ """
5
+
1
6
  from uuid import UUID
2
7
 
8
+ from prefect._internal.compatibility.deprecated import deprecated_class
3
9
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
4
10
 
5
11
  if HAS_PYDANTIC_V2:
@@ -12,15 +18,22 @@ from typing_extensions import Literal
12
18
  from prefect.blocks.core import Block
13
19
  from prefect.client.orchestration import PrefectClient
14
20
  from prefect.client.utilities import inject_client
21
+ from prefect.deprecated.packaging.base import PackageManifest, Packager, Serializer
22
+ from prefect.deprecated.packaging.serializers import SourceSerializer
15
23
  from prefect.filesystems import LocalFileSystem, ReadableFileSystem, WritableFileSystem
16
24
  from prefect.flows import Flow
17
- from prefect.packaging.base import PackageManifest, Packager, Serializer
18
- from prefect.packaging.serializers import SourceSerializer
19
25
  from prefect.settings import PREFECT_HOME
20
26
  from prefect.utilities.hashing import stable_hash
21
27
 
22
28
 
29
+ @deprecated_class(start_date="Mar 2024")
23
30
  class FilePackageManifest(PackageManifest):
31
+ """
32
+ DEPRECATION WARNING:
33
+
34
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
35
+ """
36
+
24
37
  type: Literal["file"] = "file"
25
38
  serializer: Serializer
26
39
  key: str
@@ -34,12 +47,17 @@ class FilePackageManifest(PackageManifest):
34
47
  return self.serializer.loads(content)
35
48
 
36
49
 
50
+ @deprecated_class(start_date="Mar 2024")
37
51
  class FilePackager(Packager):
38
52
  """
53
+ DEPRECATION WARNING:
54
+
55
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
56
+
39
57
  This packager stores the flow as a single file.
40
58
 
41
59
  By default, the file is the source code of the module the flow is defined in.
42
- Alternative serialization modes are available in `prefect.packaging.serializers`.
60
+ Alternative serialization modes are available in `prefect.deprecated.packaging.serializers`.
43
61
  """
44
62
 
45
63
  type: Literal["file"] = "file"
@@ -1,5 +1,11 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+ This module is deprecated as of March 2024 and will not be available after September 2024.
4
+ """
5
+
1
6
  from uuid import UUID
2
7
 
8
+ from prefect._internal.compatibility.deprecated import deprecated_class
3
9
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
4
10
 
5
11
  if HAS_PYDANTIC_V2:
@@ -12,12 +18,19 @@ from typing_extensions import Literal
12
18
  from prefect.blocks.system import JSON
13
19
  from prefect.client.orchestration import PrefectClient
14
20
  from prefect.client.utilities import inject_client
21
+ from prefect.deprecated.packaging.base import PackageManifest, Packager, Serializer
22
+ from prefect.deprecated.packaging.serializers import SourceSerializer
15
23
  from prefect.flows import Flow
16
- from prefect.packaging.base import PackageManifest, Packager, Serializer
17
- from prefect.packaging.serializers import SourceSerializer
18
24
 
19
25
 
26
+ @deprecated_class(start_date="Mar 2024")
20
27
  class OrionPackageManifest(PackageManifest):
28
+ """
29
+ DEPRECATION WARNING:
30
+
31
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
32
+ """
33
+
21
34
  type: Literal["orion"] = "orion"
22
35
  serializer: Serializer
23
36
  block_document_id: UUID
@@ -31,13 +44,18 @@ class OrionPackageManifest(PackageManifest):
31
44
  return self.serializer.loads(serialized_flow.encode())
32
45
 
33
46
 
47
+ @deprecated_class(start_date="Mar 2024")
34
48
  class OrionPackager(Packager):
35
49
  """
50
+ DEPRECATION WARNING:
51
+
52
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
53
+
36
54
  This packager stores the flow as an anonymous JSON block in the Prefect database.
37
55
  The content of the block are encrypted at rest.
38
56
 
39
57
  By default, the content is the source code of the module the flow is defined in.
40
- Alternative serialization modes are available in `prefect.packaging.serializers`.
58
+ Alternative serialization modes are available in `prefect.deprecated.packaging.serializers`.
41
59
  """
42
60
 
43
61
  type: Literal["orion"] = "orion"
@@ -1,3 +1,8 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+ This module is deprecated as of March 2024 and will not be available after September 2024.
4
+ """
5
+
1
6
  import base64
2
7
  import inspect
3
8
  import json
@@ -7,6 +12,7 @@ from pathlib import Path
7
12
  from tempfile import TemporaryDirectory
8
13
  from typing import Any, List
9
14
 
15
+ from prefect._internal.compatibility.deprecated import deprecated_class
10
16
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
11
17
 
12
18
  if HAS_PYDANTIC_V2:
@@ -16,7 +22,7 @@ else:
16
22
 
17
23
  from typing_extensions import Literal
18
24
 
19
- from prefect.packaging.base import Serializer
25
+ from prefect.deprecated.packaging.base import Serializer
20
26
  from prefect.utilities.importtools import (
21
27
  from_qualified_name,
22
28
  load_script_as_module,
@@ -24,8 +30,13 @@ from prefect.utilities.importtools import (
24
30
  )
25
31
 
26
32
 
33
+ @deprecated_class(start_date="Mar 2024")
27
34
  class PickleSerializer(Serializer):
28
35
  """
36
+ DEPRECATION WARNING:
37
+
38
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
39
+
29
40
  Serializes objects using the pickle protocol.
30
41
 
31
42
  If using cloudpickle, you may specify a list of 'pickle_modules'. These modules will
@@ -127,8 +138,13 @@ class PickleSerializer(Serializer):
127
138
  return pickler.loads(base64.decodebytes(blob))
128
139
 
129
140
 
141
+ @deprecated_class(start_date="Mar 2024")
130
142
  class SourceSerializer(Serializer):
131
143
  """
144
+ DEPRECATION WARNING:
145
+
146
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
147
+
132
148
  Serializes objects by retrieving the source code of the module they are defined in.
133
149
 
134
150
  Creates a JSON blob with keys:
@@ -185,8 +201,13 @@ class SourceSerializer(Serializer):
185
201
  return getattr(module, document["symbol_name"])
186
202
 
187
203
 
204
+ @deprecated_class(start_date="Mar 2024")
188
205
  class ImportSerializer(Serializer):
189
206
  """
207
+ DEPRECATION WARNING:
208
+
209
+ This class is deprecated as of version March 2024 and will not be available after September 2024.
210
+
190
211
  Serializes objects by storing their importable path.
191
212
  """
192
213
 
prefect/engine.py CHANGED
@@ -2002,10 +2002,14 @@ async def orchestrate_task_run(
2002
2002
  )
2003
2003
 
2004
2004
  # Emit an event to capture that the task run was in the `PENDING` state.
2005
- last_event = _emit_task_run_state_change_event(
2005
+ last_event = emit_task_run_state_change_event(
2006
2006
  task_run=task_run, initial_state=None, validated_state=task_run.state
2007
2007
  )
2008
- last_state = task_run.state
2008
+ last_state = (
2009
+ Pending()
2010
+ if flow_run_context and flow_run_context.autonomous_task_run
2011
+ else task_run.state
2012
+ )
2009
2013
 
2010
2014
  # Completed states with persisted results should have result data. If it's missing,
2011
2015
  # this could be a manual state transition, so we should use the Unknown result type
@@ -2094,7 +2098,7 @@ async def orchestrate_task_run(
2094
2098
  break
2095
2099
 
2096
2100
  # Emit an event to capture the result of proposing a `RUNNING` state.
2097
- last_event = _emit_task_run_state_change_event(
2101
+ last_event = emit_task_run_state_change_event(
2098
2102
  task_run=task_run,
2099
2103
  initial_state=last_state,
2100
2104
  validated_state=state,
@@ -2187,7 +2191,7 @@ async def orchestrate_task_run(
2187
2191
  await _check_task_failure_retriable(task, task_run, terminal_state)
2188
2192
  )
2189
2193
  state = await propose_state(client, terminal_state, task_run_id=task_run.id)
2190
- last_event = _emit_task_run_state_change_event(
2194
+ last_event = emit_task_run_state_change_event(
2191
2195
  task_run=task_run,
2192
2196
  initial_state=last_state,
2193
2197
  validated_state=state,
@@ -2220,7 +2224,7 @@ async def orchestrate_task_run(
2220
2224
  )
2221
2225
  # Attempt to enter a running state again
2222
2226
  state = await propose_state(client, Running(), task_run_id=task_run.id)
2223
- last_event = _emit_task_run_state_change_event(
2227
+ last_event = emit_task_run_state_change_event(
2224
2228
  task_run=task_run,
2225
2229
  initial_state=last_state,
2226
2230
  validated_state=state,
@@ -2896,7 +2900,7 @@ async def check_api_reachable(client: PrefectClient, fail_message: str):
2896
2900
  API_HEALTHCHECKS[api_url] = get_deadline(60 * 10)
2897
2901
 
2898
2902
 
2899
- def _emit_task_run_state_change_event(
2903
+ def emit_task_run_state_change_event(
2900
2904
  task_run: TaskRun,
2901
2905
  initial_state: Optional[State],
2902
2906
  validated_state: State,
prefect/events/clients.py CHANGED
@@ -330,14 +330,20 @@ class PrefectCloudEventSubscriber:
330
330
  )
331
331
 
332
332
  try:
333
- message = orjson.loads(await self._websocket.recv())
333
+ message: Dict[str, Any] = orjson.loads(await self._websocket.recv())
334
334
  logger.debug(" auth result %s", message)
335
- assert message["type"] == "auth_success"
335
+ assert message["type"] == "auth_success", message.get("reason", "")
336
336
  except (AssertionError, ConnectionClosedError) as e:
337
337
  if isinstance(e, AssertionError) or e.code == WS_1008_POLICY_VIOLATION:
338
+ if isinstance(e, AssertionError):
339
+ reason = e.args[0]
340
+ elif isinstance(e, ConnectionClosedError):
341
+ reason = e.reason
342
+
338
343
  raise Exception(
339
344
  "Unable to authenticate to the event stream. Please ensure the "
340
- "provided api_key you are using is valid for this environment."
345
+ "provided api_key you are using is valid for this environment. "
346
+ f"Reason: {reason}"
341
347
  ) from e
342
348
  raise
343
349
 
prefect/events/related.py CHANGED
@@ -74,7 +74,7 @@ async def related_resources_from_run_context(
74
74
  if flow_run_id is None:
75
75
  return []
76
76
 
77
- related_objects: list[ResourceCacheEntry] = []
77
+ related_objects: List[ResourceCacheEntry] = []
78
78
 
79
79
  async with get_client() as client:
80
80
 
prefect/events/schemas.py CHANGED
@@ -372,9 +372,53 @@ class MetricTrigger(ResourceTrigger):
372
372
  )
373
373
 
374
374
 
375
- TriggerTypes: TypeAlias = Union[EventTrigger, MetricTrigger]
375
+ class CompositeTrigger(Trigger, abc.ABC):
376
+ """
377
+ Requires some number of triggers to have fired within the given time period.
378
+ """
379
+
380
+ type: Literal["compound", "sequence"]
381
+ triggers: List["TriggerTypes"]
382
+ within: Optional[timedelta]
383
+
384
+
385
+ class CompoundTrigger(CompositeTrigger):
386
+ """A composite trigger that requires some number of triggers to have
387
+ fired within the given time period"""
388
+
389
+ type: Literal["compound"] = "compound"
390
+ require: Union[int, Literal["any", "all"]]
391
+
392
+ @root_validator
393
+ def validate_require(cls, values: Dict[str, Any]) -> Dict[str, Any]:
394
+ require = values.get("require")
395
+
396
+ if isinstance(require, int):
397
+ if require < 1:
398
+ raise ValueError("required must be at least 1")
399
+ if require > len(values["triggers"]):
400
+ raise ValueError(
401
+ "required must be less than or equal to the number of triggers"
402
+ )
403
+
404
+ return values
405
+
406
+
407
+ class SequenceTrigger(CompositeTrigger):
408
+ """A composite trigger that requires some number of triggers to have fired
409
+ within the given time period in a specific order"""
410
+
411
+ type: Literal["sequence"] = "sequence"
412
+
413
+
414
+ TriggerTypes: TypeAlias = Union[
415
+ EventTrigger, MetricTrigger, CompoundTrigger, SequenceTrigger
416
+ ]
376
417
  """The union of all concrete trigger types that a user may actually create"""
377
418
 
419
+ CompoundTrigger.update_forward_refs()
420
+ SequenceTrigger.update_forward_refs()
421
+
378
422
 
379
423
  class Automation(PrefectBaseModel):
380
424
  """Defines an action a user wants to take when a certain number of events
prefect/filesystems.py CHANGED
@@ -10,6 +10,7 @@ from typing import Any, Dict, Optional, Tuple, Union
10
10
  import anyio
11
11
  import fsspec
12
12
 
13
+ from prefect._internal.compatibility.deprecated import deprecated_class
13
14
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
14
15
 
15
16
  if HAS_PYDANTIC_V2:
@@ -435,8 +436,17 @@ class RemoteFileSystem(WritableFileSystem, WritableDeploymentStorage):
435
436
  return self._filesystem
436
437
 
437
438
 
439
+ @deprecated_class(
440
+ start_date="Mar 2024", help="Use the `S3Bucket` block from prefect-aws instead."
441
+ )
438
442
  class S3(WritableFileSystem, WritableDeploymentStorage):
439
443
  """
444
+ DEPRECATION WARNING:
445
+
446
+ This class is deprecated as of March 2024 and will not be available after September 2024.
447
+ It has been replaced by `S3Bucket` from the `prefect-aws` package, which offers enhanced functionality
448
+ and better a better user experience.
449
+
440
450
  Store data as a file on AWS S3.
441
451
 
442
452
  Example:
@@ -526,8 +536,16 @@ class S3(WritableFileSystem, WritableDeploymentStorage):
526
536
  return await self.filesystem.write_path(path=path, content=content)
527
537
 
528
538
 
539
+ @deprecated_class(
540
+ start_date="Mar 2024", help="Use the `GcsBucket` block from prefect-gcp instead."
541
+ )
529
542
  class GCS(WritableFileSystem, WritableDeploymentStorage):
530
543
  """
544
+ DEPRECATION WARNING:
545
+
546
+ This class is deprecated as of March 2024 and will not be available after September 2024.
547
+ It has been replaced by `GcsBucket` from the `prefect-gcp` package, which offers enhanced functionality
548
+ and better a better user experience.
531
549
  Store data as a file on Google Cloud Storage.
532
550
 
533
551
  Example:
@@ -619,8 +637,18 @@ class GCS(WritableFileSystem, WritableDeploymentStorage):
619
637
  return await self.filesystem.write_path(path=path, content=content)
620
638
 
621
639
 
640
+ @deprecated_class(
641
+ start_date="Mar 2024",
642
+ help="Use the `AzureBlobStorageContainer` block from prefect-azure instead.",
643
+ )
622
644
  class Azure(WritableFileSystem, WritableDeploymentStorage):
623
645
  """
646
+ DEPRECATION WARNING:
647
+
648
+ This class is deprecated as of March 2024 and will not be available after September 2024.
649
+ It has been replaced by `AzureBlobStorageContainer` from the `prefect-azure` package, which
650
+ offers enhanced functionality and better a better user experience.
651
+
624
652
  Store data as a file on Azure Datalake and Azure Blob Storage.
625
653
 
626
654
  Example:
@@ -869,9 +897,19 @@ class SMB(WritableFileSystem, WritableDeploymentStorage):
869
897
  return await self.filesystem.write_path(path=path, content=content)
870
898
 
871
899
 
900
+ @deprecated_class(
901
+ start_date="Mar 2024",
902
+ help="Use the `GitHubRepository` block from prefect-github instead.",
903
+ )
872
904
  class GitHub(ReadableDeploymentStorage):
873
905
  """
874
- Interact with files stored on GitHub repositories.
906
+ DEPRECATION WARNING:
907
+
908
+ This class is deprecated as of March 2024 and will not be available after September 2024.
909
+ It has been replaced by `GitHubRepository` from the `prefect-github` package, which offers
910
+ enhanced functionality and better a better user experience.
911
+ q
912
+ Interact with files stored on GitHub repositories.
875
913
  """
876
914
 
877
915
  _block_type_name = "GitHub"
prefect/flows.py CHANGED
@@ -1345,8 +1345,12 @@ def flow(
1345
1345
  result_serializer: Optional[ResultSerializer] = None,
1346
1346
  cache_result_in_memory: bool = True,
1347
1347
  log_prints: Optional[bool] = None,
1348
- on_completion: Optional[List[Callable[[FlowSchema, FlowRun, State], None]]] = None,
1349
- on_failure: Optional[List[Callable[[FlowSchema, FlowRun, State], None]]] = None,
1348
+ on_completion: Optional[
1349
+ List[Callable[[FlowSchema, FlowRun, State], Union[Awaitable[None], None]]]
1350
+ ] = None,
1351
+ on_failure: Optional[
1352
+ List[Callable[[FlowSchema, FlowRun, State], Union[Awaitable[None], None]]]
1353
+ ] = None,
1350
1354
  on_cancellation: Optional[
1351
1355
  List[Callable[[FlowSchema, FlowRun, State], None]]
1352
1356
  ] = None,
@@ -1373,8 +1377,12 @@ def flow(
1373
1377
  result_serializer: Optional[ResultSerializer] = None,
1374
1378
  cache_result_in_memory: bool = True,
1375
1379
  log_prints: Optional[bool] = None,
1376
- on_completion: Optional[List[Callable[[FlowSchema, FlowRun, State], None]]] = None,
1377
- on_failure: Optional[List[Callable[[FlowSchema, FlowRun, State], None]]] = None,
1380
+ on_completion: Optional[
1381
+ List[Callable[[FlowSchema, FlowRun, State], Union[Awaitable[None], None]]]
1382
+ ] = None,
1383
+ on_failure: Optional[
1384
+ List[Callable[[FlowSchema, FlowRun, State], Union[Awaitable[None], None]]]
1385
+ ] = None,
1378
1386
  on_cancellation: Optional[
1379
1387
  List[Callable[[FlowSchema, FlowRun, State], None]]
1380
1388
  ] = None,
@@ -1,3 +1,11 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+
4
+ This module is deprecated as of March 2024 and will not be available after September 2024.
5
+ Infrastructure blocks have been replaced by workers, which offer enhanced functionality and better performance.
6
+
7
+ For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.
8
+ """
1
9
  import abc
2
10
  import shlex
3
11
  import warnings
@@ -5,6 +13,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional
5
13
 
6
14
  import anyio.abc
7
15
 
16
+ from prefect._internal.compatibility.deprecated import deprecated_class
8
17
  from prefect._internal.compatibility.experimental import (
9
18
  EXPERIMENTAL_WARNING,
10
19
  ExperimentalFeature,
@@ -48,6 +57,12 @@ class InfrastructureResult(pydantic.BaseModel, abc.ABC):
48
57
  return self.status_code == 0
49
58
 
50
59
 
60
+ @deprecated_class(
61
+ start_date="Mar 2024",
62
+ help="Use the `BaseWorker` class to create custom infrastructure integrations instead."
63
+ " Refer to the upgrade guide for more information:"
64
+ " https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.",
65
+ )
51
66
  class Infrastructure(Block, abc.ABC):
52
67
  _block_schema_capabilities = ["run-infrastructure"]
53
68
 
@@ -1,3 +1,11 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+
4
+ This module is deprecated as of March 2024 and will not be available after September 2024.
5
+ It has been replaced by the Docker worker from the prefect-docker package, which offers enhanced functionality and better performance.
6
+
7
+ For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.
8
+ """
1
9
  import json
2
10
  import re
3
11
  import shlex
@@ -10,6 +18,7 @@ from typing import TYPE_CHECKING, Dict, Generator, List, Optional, Tuple, Union
10
18
  import anyio.abc
11
19
  import packaging.version
12
20
 
21
+ from prefect._internal.compatibility.deprecated import deprecated_class
13
22
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
14
23
 
15
24
  if HAS_PYDANTIC_V2:
@@ -54,6 +63,10 @@ class ImagePullPolicy(AutoEnum):
54
63
  NEVER = AutoEnum.auto()
55
64
 
56
65
 
66
+ @deprecated_class(
67
+ start_date="Mar 2024",
68
+ help="Use the `DockerRegistryCredentials` class from prefect-docker instead.",
69
+ )
57
70
  class BaseDockerLogin(Block, ABC):
58
71
  _logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/14a315b79990200db7341e42553e23650b34bb96-250x250.png"
59
72
  _block_schema_capabilities = ["docker-login"]
@@ -105,6 +118,10 @@ class BaseDockerLogin(Block, ABC):
105
118
  return docker_client
106
119
 
107
120
 
121
+ @deprecated_class(
122
+ start_date="Mar 2024",
123
+ help="Use the `DockerRegistryCredentials` class from prefect-docker instead.",
124
+ )
108
125
  class DockerRegistry(BaseDockerLogin):
109
126
  """
110
127
  Connects to a Docker registry.
@@ -170,6 +187,12 @@ class DockerContainerResult(InfrastructureResult):
170
187
  """Contains information about a completed Docker container"""
171
188
 
172
189
 
190
+ @deprecated_class(
191
+ start_date="Mar 2024",
192
+ help="Use the Docker worker from prefect-docker instead."
193
+ " Refer to the upgrade guide for more information:"
194
+ " https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.",
195
+ )
173
196
  class DockerContainer(Infrastructure):
174
197
  """
175
198
  Runs a command in a container.
@@ -1,3 +1,11 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+
4
+ This module is deprecated as of March 2024 and will not be available after September 2024.
5
+ It has been replaced by the Kubernetes worker from the prefect-kubernetes package, which offers enhanced functionality and better performance.
6
+
7
+ For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.
8
+ """
1
9
  import copy
2
10
  import enum
3
11
  import json
@@ -11,6 +19,9 @@ from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Tuple, U
11
19
  import anyio.abc
12
20
  import yaml
13
21
 
22
+ from prefect._internal.compatibility.deprecated import (
23
+ deprecated_class,
24
+ )
14
25
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
15
26
 
16
27
  if HAS_PYDANTIC_V2:
@@ -58,6 +69,12 @@ class KubernetesJobResult(InfrastructureResult):
58
69
  """Contains information about the final state of a completed Kubernetes Job"""
59
70
 
60
71
 
72
+ @deprecated_class(
73
+ start_date="Mar 2024",
74
+ help="Use the Kubernetes worker from prefect-kubernetes instead."
75
+ " Refer to the upgrade guide for more information:"
76
+ " https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.",
77
+ )
61
78
  class KubernetesJob(Infrastructure):
62
79
  """
63
80
  Runs a command as a Kubernetes Job.
@@ -1,3 +1,12 @@
1
+ """
2
+ DEPRECATION WARNING:
3
+
4
+ This module is deprecated as of March 2024 and will not be available after September 2024.
5
+ It has been replaced by the process worker from the `prefect.workers` module, which offers enhanced functionality and better performance.
6
+
7
+ For upgrade instructions, see https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.
8
+ """
9
+
1
10
  import asyncio
2
11
  import contextlib
3
12
  import os
@@ -14,6 +23,7 @@ import anyio
14
23
  import anyio.abc
15
24
  import sniffio
16
25
 
26
+ from prefect._internal.compatibility.deprecated import deprecated_class
17
27
  from prefect._internal.pydantic import HAS_PYDANTIC_V2
18
28
 
19
29
  if HAS_PYDANTIC_V2:
@@ -57,6 +67,12 @@ def _parse_infrastructure_pid(infrastructure_pid: str) -> Tuple[str, int]:
57
67
  return hostname, int(pid)
58
68
 
59
69
 
70
+ @deprecated_class(
71
+ start_date="Mar 2024",
72
+ help="Use the process worker instead."
73
+ " Refer to the upgrade guide for more information:"
74
+ " https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/.",
75
+ )
60
76
  class Process(Infrastructure):
61
77
  """
62
78
  Run a command in a new process.
@@ -912,8 +912,7 @@
912
912
  "metadata": {
913
913
  "name": "{{ name }}",
914
914
  "annotations": {
915
- "run.googleapis.com/launch-stage": "BETA",
916
- "run.googleapis.com/vpc-access-connector": "{{ vpc_connector_name }}"
915
+ "run.googleapis.com/launch-stage": "BETA"
917
916
  }
918
917
  },
919
918
  "spec": {
@@ -941,6 +940,11 @@
941
940
  "serviceAccountName": "{{ service_account_name }}"
942
941
  }
943
942
  }
943
+ },
944
+ "metadata": {
945
+ "annotations": {
946
+ "run.googleapis.com/vpc-access-connector": "{{ vpc_connector_name }}"
947
+ }
944
948
  }
945
949
  }
946
950
  }
@@ -1093,8 +1097,10 @@
1093
1097
  "launchStage": "{{ launch_stage }}",
1094
1098
  "template": {
1095
1099
  "template": {
1100
+ "serviceAccount": "{{ service_account_name }}",
1096
1101
  "maxRetries": "{{ max_retries }}",
1097
1102
  "timeout": "{{ timeout }}",
1103
+ "vpcAccess": "{{ vpc_connector_name }}",
1098
1104
  "containers": [
1099
1105
  {
1100
1106
  "env": [],
@@ -1229,6 +1235,12 @@
1229
1235
  "title": "VPC Connector Name",
1230
1236
  "description": "The name of the VPC connector to use for the Cloud Run job.",
1231
1237
  "type": "string"
1238
+ },
1239
+ "service_account_name": {
1240
+ "title": "Service Account Name",
1241
+ "description": "The name of the service account to use for the task execution of Cloud Run Job. By default Cloud Run jobs run as the default Compute Engine Service Account.",
1242
+ "example": "service-account@example.iam.gserviceaccount.com",
1243
+ "type": "string"
1232
1244
  }
1233
1245
  },
1234
1246
  "definitions": {