flyteplugins-dask 2.0.0b22__py3-none-any.whl → 2.0.0b24__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.
flyteplugins/dask/task.py CHANGED
@@ -2,10 +2,10 @@ from dataclasses import dataclass, field
2
2
  from typing import Any, Dict, Optional
3
3
 
4
4
  import flyte
5
+ from distributed import Client, WorkerPlugin
5
6
  from flyte import Resources
6
- from flyte._internal.runtime.resources_serde import get_proto_resources
7
- from flyte.extend import AsyncFunctionTaskTemplate, TaskPluginRegistry
8
- from flyte.models import SerializationContext
7
+ from flyte.extend import AsyncFunctionTaskTemplate, TaskPluginRegistry, download_code_bundle, get_proto_resources
8
+ from flyte.models import CodeBundle, SerializationContext
9
9
  from flyteidl.plugins.dask_pb2 import DaskJob, DaskScheduler, DaskWorkerGroup
10
10
  from google.protobuf.json_format import MessageToDict
11
11
 
@@ -55,6 +55,21 @@ class Dask:
55
55
  workers: WorkerGroup = field(default_factory=lambda: WorkerGroup())
56
56
 
57
57
 
58
+ class DownloadCodeBundlePlugin(WorkerPlugin):
59
+ """
60
+ A Dask plugin to download and set up the code bundle on each worker.
61
+ """
62
+
63
+ def __init__(self, code_bundle: CodeBundle):
64
+ self.code_bundle = code_bundle
65
+
66
+ def setup(self, worker):
67
+ """
68
+ Runs on each worker as it is initialized.
69
+ """
70
+ download_code_bundle(self.code_bundle)
71
+
72
+
58
73
  @dataclass(kw_only=True)
59
74
  class DaskTask(AsyncFunctionTaskTemplate):
60
75
  """
@@ -65,12 +80,11 @@ class DaskTask(AsyncFunctionTaskTemplate):
65
80
  task_type: str = "dask"
66
81
 
67
82
  async def pre(self, *args, **kwargs) -> Dict[str, Any]:
68
- from distributed import Client
69
- from distributed.diagnostics.plugin import UploadDirectory
70
-
71
- if flyte.ctx().is_in_cluster() and flyte.ctx().code_bundle:
83
+ ctx = flyte.ctx()
84
+ code_bundle = ctx.code_bundle
85
+ if ctx.is_in_cluster() and code_bundle:
72
86
  client = Client()
73
- client.register_plugin(UploadDirectory(flyte.ctx().code_bundle.destination))
87
+ client.register_plugin(DownloadCodeBundlePlugin(code_bundle))
74
88
 
75
89
  return {}
76
90
 
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyteplugins-dask
3
- Version: 2.0.0b22
3
+ Version: 2.0.0b24
4
4
  Summary: Dask plugin for flyte
5
5
  Author-email: Kevin Su <pingsutw@users.noreply.github.com>
6
6
  Requires-Python: >=3.10
7
7
  Description-Content-Type: text/markdown
8
8
  Requires-Dist: dask[distributed]>=2022.10.2
9
- Requires-Dist: flyte
9
+ Requires-Dist: flyte>v2.0.0b23
10
10
  Requires-Dist: bokeh
11
11
 
12
12
  # Union Dask Plugin
@@ -0,0 +1,6 @@
1
+ flyteplugins/dask/__init__.py,sha256=UwmJjPRVqDyCTobQlT5a2g2oZJvK0vlDiv6rwugNs-g,112
2
+ flyteplugins/dask/task.py,sha256=giAaSDZb0cIedzJ2ij8LRq7u8WvtB75l2lgLyeKwKQI,3634
3
+ flyteplugins_dask-2.0.0b24.dist-info/METADATA,sha256=IDPjmHMoQ8iCirFQE3-eFb_n18ISB9J-J4ti7DYU8Cg,948
4
+ flyteplugins_dask-2.0.0b24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ flyteplugins_dask-2.0.0b24.dist-info/top_level.txt,sha256=cgd779rPu9EsvdtuYgUxNHHgElaQvPn74KhB5XSeMBE,13
6
+ flyteplugins_dask-2.0.0b24.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- flyteplugins/dask/__init__.py,sha256=UwmJjPRVqDyCTobQlT5a2g2oZJvK0vlDiv6rwugNs-g,112
2
- flyteplugins/dask/task.py,sha256=5jYtNY0wHE_EwoTYZDQ1vdlWjfrBzix3fxMz3Q4Rivo,3307
3
- flyteplugins_dask-2.0.0b22.dist-info/METADATA,sha256=hVyARkh0hGCvCHJyFEsdi3nu0gFebcePbbvEVDbJxDE,938
4
- flyteplugins_dask-2.0.0b22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- flyteplugins_dask-2.0.0b22.dist-info/top_level.txt,sha256=cgd779rPu9EsvdtuYgUxNHHgElaQvPn74KhB5XSeMBE,13
6
- flyteplugins_dask-2.0.0b22.dist-info/RECORD,,