-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add MMCloud plugin to Integrations Signed-off-by: Edwin Yu <[email protected]> * Remove default image from README and example Signed-off-by: Edwin Yu <[email protected]> * Fix end of requirements.in Signed-off-by: Edwin Yu <[email protected]> * update requirement.txt for mmcloud_plugin Signed-off-by: helenzhangyc <[email protected]> --------- Signed-off-by: Edwin Yu <[email protected]> Signed-off-by: helenzhangyc <[email protected]> Co-authored-by: helenzhangyc <[email protected]>
- Loading branch information
1 parent
0ca1523
commit fe4968d
Showing
8 changed files
with
510 additions
and
0 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,27 @@ | ||
FROM python:3.11-slim-bookworm | ||
LABEL org.opencontainers.image.source https://github.com/flyteorg/flytesnacks | ||
|
||
WORKDIR /root | ||
ENV VENV /opt/venv | ||
ENV LANG C.UTF-8 | ||
ENV LC_ALL C.UTF-8 | ||
ENV PYTHONPATH /root | ||
|
||
WORKDIR /root | ||
|
||
ENV VENV /opt/venv | ||
# Virtual environment | ||
RUN python3 -m venv ${VENV} | ||
ENV PATH="${VENV}/bin:$PATH" | ||
|
||
# Install Python dependencies | ||
COPY requirements.txt /root | ||
RUN pip install -r /root/requirements.txt | ||
|
||
# Copy the actual code | ||
COPY . /root | ||
|
||
# This tag is supplied by the build script and will be used to determine the version | ||
# when registering tasks, workflows, and launch plans | ||
ARG tag | ||
ENV FLYTE_INTERNAL_IMAGE $tag |
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,80 @@ | ||
# Memory Machine Cloud | ||
|
||
```{eval-rst} | ||
.. tags:: AWS, GCP, AliCloud, Integration, Advanced | ||
``` | ||
|
||
[MemVerge](https://memverge.com/) [Memory Machine Cloud](https://www.mmcloud.io/) (MMCloud)—available on AWS, GCP, and AliCloud—empowers users to continuously optimize cloud resources during runtime, safely execute stateful tasks on spot instances, and monitor resource usage in real time. These capabilities make it an excellent fit for long-running batch workloads. | ||
|
||
Flyte can be integrated with MMCloud, allowing you to execute Flyte tasks using MMCloud. | ||
|
||
## Installation | ||
|
||
To install the plugin, run the following command: | ||
|
||
```{eval-rst} | ||
.. prompt:: bash | ||
pip install flytekitplugins-mmcloud | ||
``` | ||
|
||
To get started with MMCloud, refer to the [MMCloud User Guide](https://docs.memverge.com/mmce/current/userguide/olh/index.html). | ||
|
||
## Configuring the backend to get MMCloud working | ||
|
||
The MMCloud plugin is [enabled in FlytePropeller's configuration](https://docs.flyte.org/en/latest/deployment/plugins/memverge/mmcloud.html). | ||
|
||
## Getting Started | ||
|
||
This plugin allows executing `PythonFunctionTask` using MMCloud without changing any function code. | ||
|
||
```{eval-rst} | ||
.. testcode:: awsbatch-quickstart | ||
from flytekitplugins.mmcloud import MMCloudConfig | ||
@task(task_config=MMCloudConfig()) | ||
def to_str(i: int) -> str: | ||
return str(i) | ||
``` | ||
|
||
[Resource](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/productionizing/customizing_resources.html) (cpu and mem) requests and limits, [container](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/customizing_dependencies/multi_images.html) images, and [environment](https://docs.flyte.org/projects/flytekit/en/latest/generated/flytekit.task.html) variable specifications are supported. | ||
|
||
[ImageSpec](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/customizing_dependencies/image_spec.html) may be used to define images to run tasks. | ||
|
||
### Credentials | ||
|
||
The following [secrets](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/productionizing/use_secrets.html) are required to be defined for the agent server: | ||
* `mmc_address`: MMCloud OpCenter address | ||
* `mmc_username`: MMCloud OpCenter username | ||
* `mmc_password`: MMCloud OpCenter password | ||
|
||
### Defaults | ||
|
||
Compute resources: | ||
* If only requests are specified, there are no limits. | ||
* If only limits are specified, the requests are equal to the limits. | ||
* If neither resource requests nor limits are specified, the default requests used for job submission are `cpu="1"` and `mem="1Gi"`, and there are no limits. | ||
|
||
### Agent Image | ||
|
||
Install `flytekitplugins-mmcloud` in the agent image. | ||
|
||
A `float` binary (obtainable via the OpCenter) is required. Copy it to the agent image `PATH`. | ||
|
||
Sample `Dockerfile` for building an agent image: | ||
```dockerfile | ||
FROM python:3.11-slim-bookworm | ||
|
||
WORKDIR /root | ||
ENV PYTHONPATH /root | ||
|
||
# flytekit will autoload the agent if package is installed. | ||
RUN pip install flytekitplugins-mmcloud | ||
COPY float /usr/local/bin/float | ||
|
||
CMD pyflyte serve --port 8000 | ||
``` | ||
|
||
```{auto-examples-toc} | ||
example | ||
``` |
Empty file.
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,42 @@ | ||
# %% [markdown] | ||
# # Memory Machine Cloud | ||
# | ||
# This example shows how to use the MMCloud plugin to execute tasks on MemVerge Memory Machine Cloud. | ||
|
||
# %% | ||
from flytekit import Resources, task, workflow | ||
from flytekitplugins.mmcloud import MMCloudConfig | ||
|
||
# %% [markdown] | ||
# `MMCloudConfig` configures `MMCloudTask`. Tasks specified with `MMCloudConfig` will be executed using MMCloud. Tasks will be executed with requests `cpu="1"` and `mem="1Gi"` by default. | ||
|
||
# %% | ||
@task(task_config=MMCloudConfig()) | ||
def to_str(i: int) -> str: | ||
return str(i) | ||
|
||
|
||
@task(task_config=MMCloudConfig()) | ||
def to_int(s: str) -> int: | ||
return int(s) | ||
|
||
|
||
# %% [markdown] | ||
# [Resource](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/productionizing/customizing_resources.html) (cpu and mem) requests and limits, [container](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/customizing_dependencies/multi_images.html) images, and [environment](https://docs.flyte.org/projects/flytekit/en/latest/generated/flytekit.task.html) variable specifications are supported. | ||
|
||
# %% | ||
@task( | ||
task_config=MMCloudConfig(submit_extra="--migratePolicy [enable=true]"), | ||
requests=Resources(cpu="1", mem="1Gi"), | ||
limits=Resources(cpu="2", mem="4Gi"), | ||
environment={"KEY": "value"}, | ||
) | ||
def concatenate_str(s1: str, s2: str) -> str: | ||
return s1 + s2 | ||
|
||
|
||
@workflow | ||
def concatenate_int_wf(i1: int, i2: int) -> int: | ||
i1_str = to_str(i=i1) | ||
i2_str = to_str(i=i2) | ||
return to_int(s=concatenate_str(s1=i1_str, s2=i2_str)) |
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,2 @@ | ||
flytekitplugins-envd | ||
flytekitplugins-mmcloud |
Oops, something went wrong.