Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requirements.txt to ray example #863

Merged
merged 4 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions cookbook/integrations/kubernetes/ray_example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
FROM rayproject/ray:1.13.1-py37-gpu
# You can disable GPU support by replacing the above line with:
# FROM rayproject/ray_example:1.13.1-py37-cpu
USER ray
FROM python:3.8-slim-buster
LABEL org.opencontainers.image.source=https://github.com/flyteorg/flytesnacks

USER ray
ARG HOME=/home/ray
WORKDIR $HOME
WORKDIR /root
ENV VENV /opt/venv
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
ENV TERM linux
ENV PYTHONPATH /root

RUN apt-get update && apt-get install -y libsm6 libxext6 libxrender-dev ffmpeg build-essential curl git

# Install the AWS cli separately to prevent issues with boto being written over
RUN pip install awscli

# Install wheel after venv is activated
RUN pip3 install wheel
WORKDIR /opt
RUN curl https://sdk.cloud.google.com > install.sh
RUN bash /opt/install.sh --install-dir=/opt
ENV PATH $PATH:/opt/google-cloud-sdk/bin
WORKDIR /root

ENV VENV /opt/venv
# Virtual environment
RUN python3 -m venv ${VENV}
ENV PATH="${VENV}/bin:$PATH"

# Install Python dependencies
RUN pip3 install flytekit "git+https://github.com/flyteorg/flytekit@master#egg=flytekitplugins-ray&subdirectory=plugins/flytekit-ray"
RUN pip3 install ray[default]
COPY ray_example/requirements.txt /root
RUN pip install -r /root/requirements.txt
RUN pip freeze

# Copy the makefile targets to expose on the container. This makes it easier to register
COPY in_container.mk /root/Makefile
COPY ray_example/sandbox.config /root

# Copy the actual code
COPY ray_example /root/ray_example

# Copy the makefile targets to expose on the container. This makes it easier to register.
COPY ray_example/in_container.mk /$HOME/Makefile
COPY ray_example/sandbox.config /$HOME

# Note: when we start the container using this image, we'll run "ray_example start" first at "/home/ray_example/anaconda3/lib/python3.7", and then
# run "pyflyte-execute" to run a ray_example job. Therefore, actual code should be copy to "/home/ray_example/anaconda3/lib/python3.7"
COPY ray_example/ /home/ray/anaconda3/lib/python3.7/ray_example
# 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
Expand Down
4 changes: 2 additions & 2 deletions cookbook/integrations/kubernetes/ray_example/ray_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def f(x):
#
ray_config = RayJobConfig(
head_node_config=HeadNodeConfig(ray_start_params={"log-color": "True"}),
worker_node_config=[WorkerNodeConfig(group_name="ray-group", replicas=5)],
worker_node_config=[WorkerNodeConfig(group_name="ray-group", replicas=2)],
runtime_env={"pip": ["numpy", "pandas"]}, # or runtime_env="./requirements.txt"
)

Expand All @@ -52,7 +52,7 @@ def f(x):
#
# .. note::
# The Resources here is used to define the resource of worker nodes
@task(task_config=ray_config, limits=Resources(mem="2000Mi", cpu="2"))
@task(task_config=ray_config, limits=Resources(mem="2000Mi", cpu="1"))
def ray_task(n: int) -> typing.List[int]:
futures = [f.remote(i) for i in range(n)]
return ray.get(futures)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-r ../../../common/requirements-common.in
flytekitplugins-ray
ray[default]==1.13.0
grpcio-status==1.43.0

Loading