Memory Machine Cloud connector example usage
Once you have a Union account, install union:
pip install unionExport the following environment variable to build and push images to your own container registry:
# replace with your registry name
export IMAGE_SPEC_REGISTRY="<your-container-registry>"Then run the following commands to run the workflow:
$ git clone https://github.com/unionai/unionai-examples
$ cd unionai-examples
$ union run --remote <path/to/file.py> <workflow_name> <params>The source code for this example can be found here.
from flytekit import Resources, task, workflow
from flytekitplugins.mmcloud import MMCloudConfigMMCloudConfig 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)Resource (cpu and mem) requests and limits, container images, and environment 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))