-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dummy task type to test backend plugin Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add docs page Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add dask models Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add function to convert resources Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add tests to `dask` task Signed-off-by: Bernhard Stadlbauer <[email protected]> * Remove namespace Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update setup.py Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add dask to `plugin/README.md` Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add README.md for `dask` Signed-off-by: Bernhard Stadlbauer <[email protected]> * Top level export of `JopPodSpec` and `DaskCluster` Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update docs for images Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update README.md Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update models after `flyteidl` change Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update task after `flyteidl` change Signed-off-by: Bernhard Stadlbauer <[email protected]> * Raise error when less than 1 worker Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update flyteidl to >= 1.3.2 Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update doc requirements Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update doc-requirements.txt Signed-off-by: Bernhard Stadlbauer <[email protected]> * Re-lock dependencies on linux Signed-off-by: Bernhard Stadlbauer <[email protected]> * Update dask API docs Signed-off-by: Bernhard Stadlbauer <[email protected]> * Fix documentation links Signed-off-by: Bernhard Stadlbauer <[email protected]> * Default optional model constructor arguments to `None` Signed-off-by: Bernhard Stadlbauer <[email protected]> * Refactor `convert_resources_to_resource_model` to `core.resources` Signed-off-by: Bernhard Stadlbauer <[email protected]> * Use `convert_resources_to_resource_model` in `core.node` Signed-off-by: Bernhard Stadlbauer <[email protected]> * Incorporate review feedback Signed-off-by: Eduardo Apolinario <[email protected]> * Lint Signed-off-by: Eduardo Apolinario <[email protected]> Signed-off-by: Bernhard Stadlbauer <[email protected]> Signed-off-by: Bernhard Stadlbauer <[email protected]> Signed-off-by: Eduardo Apolinario <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]>
- Loading branch information
1 parent
a7e7b46
commit 689c4ae
Showing
19 changed files
with
892 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.. _dask: | ||
|
||
################################################### | ||
Dask API reference | ||
################################################### | ||
|
||
.. tags:: Integration, DistributedComputing, KubernetesOperator | ||
|
||
.. automodule:: flytekitplugins.dask | ||
:no-members: | ||
:no-inherited-members: | ||
:no-special-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Flytekit Dask Plugin | ||
|
||
Flyte can execute `dask` jobs natively on a Kubernetes Cluster, which manages the virtual `dask` cluster's lifecycle | ||
(spin-up and tear down). It leverages the open-source Kubernetes Dask Operator and can be enabled without signing up | ||
for any service. This is like running a transient (ephemeral) `dask` cluster - a type of cluster spun up for a specific | ||
task and torn down after completion. This helps in making sure that the Python environment is the same on the job-runner | ||
(driver), scheduler and the workers. | ||
|
||
To install the plugin, run the following command: | ||
|
||
```bash | ||
pip install flytekitplugins-dask | ||
``` | ||
|
||
To configure Dask in the Flyte deployment's backed, follow | ||
[step 1](https://docs.flyte.org/projects/cookbook/en/latest/auto/integrations/kubernetes/k8s_dask/index.html#step-1-deploy-the-dask-plugin-in-the-flyte-backend) | ||
and | ||
[step 2](https://docs.flyte.org/projects/cookbook/en/latest/auto/auto/integrations/kubernetes/k8s_dask/index.html#step-2-environment-setup) | ||
|
||
An [example](https://docs.flyte.org/projects/cookbook/en/latest/auto/integrations/kubernetes/k8s_dask/index.html) | ||
can be found in the documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
.. currentmodule:: flytekitplugins.dask | ||
This package contains the Python related side of the Dask Plugin | ||
.. autosummary:: | ||
:template: custom.rst | ||
:toctree: generated/ | ||
Dask | ||
Scheduler | ||
WorkerGroup | ||
""" | ||
|
||
from flytekitplugins.dask.task import Dask, Scheduler, WorkerGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
from typing import Optional | ||
|
||
from flyteidl.plugins import dask_pb2 as dask_task | ||
|
||
from flytekit.models import common as common | ||
from flytekit.models import task as task | ||
|
||
|
||
class Scheduler(common.FlyteIdlEntity): | ||
""" | ||
Configuration for the scheduler pod | ||
:param image: Optional image to use. | ||
:param resources: Optional resources to use. | ||
""" | ||
|
||
def __init__(self, image: Optional[str] = None, resources: Optional[task.Resources] = None): | ||
self._image = image | ||
self._resources = resources | ||
|
||
@property | ||
def image(self) -> Optional[str]: | ||
""" | ||
:return: The optional image for the scheduler pod | ||
""" | ||
return self._image | ||
|
||
@property | ||
def resources(self) -> Optional[task.Resources]: | ||
""" | ||
:return: Optional resources for the scheduler pod | ||
""" | ||
return self._resources | ||
|
||
def to_flyte_idl(self) -> dask_task.DaskScheduler: | ||
""" | ||
:return: The scheduler spec serialized to protobuf | ||
""" | ||
return dask_task.DaskScheduler( | ||
image=self.image, | ||
resources=self.resources.to_flyte_idl() if self.resources else None, | ||
) | ||
|
||
|
||
class WorkerGroup(common.FlyteIdlEntity): | ||
""" | ||
Configuration for a dask worker group | ||
:param number_of_workers:Number of workers in the group | ||
:param image: Optional image to use for the pods of the worker group | ||
:param resources: Optional resources to use for the pods of the worker group | ||
""" | ||
|
||
def __init__( | ||
self, | ||
number_of_workers: int, | ||
image: Optional[str] = None, | ||
resources: Optional[task.Resources] = None, | ||
): | ||
if number_of_workers < 1: | ||
raise ValueError( | ||
f"Each worker group needs to have at least one worker, but {number_of_workers} have been specified." | ||
) | ||
|
||
self._number_of_workers = number_of_workers | ||
self._image = image | ||
self._resources = resources | ||
|
||
@property | ||
def number_of_workers(self) -> Optional[int]: | ||
""" | ||
:return: Optional number of workers for the worker group | ||
""" | ||
return self._number_of_workers | ||
|
||
@property | ||
def image(self) -> Optional[str]: | ||
""" | ||
:return: The optional image to use for the worker pods | ||
""" | ||
return self._image | ||
|
||
@property | ||
def resources(self) -> Optional[task.Resources]: | ||
""" | ||
:return: Optional resources to use for the worker pods | ||
""" | ||
return self._resources | ||
|
||
def to_flyte_idl(self) -> dask_task.DaskWorkerGroup: | ||
""" | ||
:return: The dask cluster serialized to protobuf | ||
""" | ||
return dask_task.DaskWorkerGroup( | ||
number_of_workers=self.number_of_workers, | ||
image=self.image, | ||
resources=self.resources.to_flyte_idl() if self.resources else None, | ||
) | ||
|
||
|
||
class DaskJob(common.FlyteIdlEntity): | ||
""" | ||
Configuration for the custom dask job to run | ||
:param scheduler: Configuration for the scheduler | ||
:param workers: Configuration of the default worker group | ||
""" | ||
|
||
def __init__(self, scheduler: Scheduler, workers: WorkerGroup): | ||
self._scheduler = scheduler | ||
self._workers = workers | ||
|
||
@property | ||
def scheduler(self) -> Scheduler: | ||
""" | ||
:return: Configuration for the scheduler pod | ||
""" | ||
return self._scheduler | ||
|
||
@property | ||
def workers(self) -> WorkerGroup: | ||
""" | ||
:return: Configuration of the default worker group | ||
""" | ||
return self._workers | ||
|
||
def to_flyte_idl(self) -> dask_task.DaskJob: | ||
""" | ||
:return: The dask job serialized to protobuf | ||
""" | ||
return dask_task.DaskJob( | ||
scheduler=self.scheduler.to_flyte_idl(), | ||
workers=self.workers.to_flyte_idl(), | ||
) |
Oops, something went wrong.