Skip to content

Commit

Permalink
develop
Browse files Browse the repository at this point in the history
Signed-off-by: Yicheng-Lu-llll <[email protected]>
  • Loading branch information
Yicheng-Lu-llll committed Nov 6, 2023
1 parent ddfd824 commit db8d4c3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 25 deletions.
33 changes: 8 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-slim-buster

MAINTAINER Flyte Team <[email protected]>
LABEL org.opencontainers.image.source=https://github.com/flyteorg/flytekit

FROM python:3.9-slim-buster
USER root
WORKDIR /root
ENV PYTHONPATH /root

ARG VERSION
ARG DOCKER_IMAGE

RUN apt-get update && apt-get install build-essential -y

# Pod tasks should be exposed in the default image
RUN pip install --no-cache-dir -U flytekit==$VERSION \
flytekitplugins-pod==$VERSION \
flytekitplugins-deck-standard==$VERSION \
scikit-learn \
&& :

RUN useradd -u 1000 flytekit
RUN chown flytekit: /root
# Some packages will create config file under /home by default, so we need to make sure it's writable
RUN chown flytekit: /home
USER flytekit

ENV FLYTE_INTERNAL_IMAGE "$DOCKER_IMAGE"
RUN apt-get install git -y
# The following line is an example of how to install your modified plugins. In this case, it demonstrates how to install the 'deck' plugin.
RUN pip install git+https://github.com/Yicheng-Lu-llll/flyte.git@add-ray-autoscaler-config#subdirectory=flyteidl
RUN pip install -U git+https://github.com/Yicheng-Lu-llll/flytekit.git@"add-ray-autoscaler-config#egg=flytekitplugins-ray&subdirectory=plugins/flytekit-ray" # replace with your own repo and branch
RUN pip install -U git+https://github.com/Yicheng-Lu-llll/flytekit.git@add-ray-autoscaler-config
ENV FLYTE_INTERNAL_IMAGE "localhost:30000/flytekit:demo5"
Binary file added bin/flytectl
Binary file not shown.
50 changes: 50 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import typing

Check warning on line 1 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L1

Added line #L1 was not covered by tests

import ray
from flytekitplugins.ray import HeadNodeConfig, RayJobConfig, WorkerNodeConfig

Check warning on line 4 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L3-L4

Added lines #L3 - L4 were not covered by tests

from flytekit import Resources, task, workflow

Check warning on line 6 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L6

Added line #L6 was not covered by tests


@ray.remote

Check warning on line 9 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L9

Added line #L9 was not covered by tests
def f(x):
return x * x

Check warning on line 11 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L11

Added line #L11 was not covered by tests


ray_config = RayJobConfig(

Check warning on line 14 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L14

Added line #L14 was not covered by tests
head_node_config=HeadNodeConfig(ray_start_params={"log-color": "True"}),
worker_node_config=[WorkerNodeConfig(group_name="ray-group", replicas=1)],
enable_in_tree_autoscaling=True,
)


@task(

Check warning on line 21 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L21

Added line #L21 was not covered by tests
task_config=ray_config,
requests=Resources(mem="8Gi", cpu="8"),
)
def ray_task() -> None:
from pprint import pprint
import time

Check warning on line 27 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L26-L27

Added lines #L26 - L27 were not covered by tests

# Import placement group APIs.
from ray.util.placement_group import (

Check warning on line 30 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L30

Added line #L30 was not covered by tests
placement_group,
placement_group_table,
remove_placement_group,
)
from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy

Check warning on line 35 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L35

Added line #L35 was not covered by tests

# Initialize Ray.
import ray

Check warning on line 38 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L38

Added line #L38 was not covered by tests

ray.init()

Check warning on line 40 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L40

Added line #L40 was not covered by tests


pg = placement_group([{"CPU": 8} for i in range(1)])
ray.get(pg.ready(), timeout=10)
print(placement_group_table(pg))

Check warning on line 45 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L44-L45

Added lines #L44 - L45 were not covered by tests


@workflow

Check warning on line 48 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L48

Added line #L48 was not covered by tests
def ray_workflow() -> None:
return ray_task()

Check warning on line 50 in test.py

View check run for this annotation

Codecov / codecov/patch

test.py#L50

Added line #L50 was not covered by tests
26 changes: 26 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Step1: Ensure you have pushed your changes to the remote repo
# In the flytekit folder
git add . && git commit -s -m "develop" && git push

# Step2: Build the image
# In the flytekit folder
export FLYTE_INTERNAL_IMAGE="localhost:30000/flytekit:demo5" # replace with your own image name and tag
docker build --no-cache -t "${FLYTE_INTERNAL_IMAGE}" -f ./Dockerfile .

# Step3: Push the image to the Flyte cluster
docker push ${FLYTE_INTERNAL_IMAGE}

# Step4: Submit a hello world workflow to the Flyte cluster
pyflyte run --image ${FLYTE_INTERNAL_IMAGE} --remote /home/ubuntu/flytekit/test.py ray_workflow




# kubectl describe pod -n flytesnacks-development

# kubectl get pod -n flytesnacks-development

# kubectl delete rayjob -n flytesnacks-development f64aaaa2db8da46c1a64-n0-0

# kubectl get rayjob -n flytesnacks-development
# kubectl get rayjob fbb01fe48014e43e383d-n0-0 -n flytesnacks-development -o yaml

0 comments on commit db8d4c3

Please sign in to comment.