Skip to content

Commit

Permalink
Merge branch 'main' into map-batch
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlisid authored Jul 11, 2024
2 parents 2cbf98b + b847504 commit d289a0d
Show file tree
Hide file tree
Showing 96 changed files with 379 additions and 310 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ on:

jobs:
docker_publish:
# run it only on numaproj/numaflow-python repository
# forked repositories normally don't have the proper permission setup.
# run workflow only on numaproj/numaflow-python repository
if: ${{ github.repository }} == "numaproj/numaflow-python"
name: Build, Tag, and Push Image
runs-on: ubuntu-latest

strategy:
matrix:
# TODO: rewrite asyncio-reduce example using latest SDK version, as it is currently using old methods
# TODO: rewrite asyncio_reduce example using latest SDK version, as it is currently using old methods
# then add to example_directories matrix
example_directories: [
"examples/map/even_odd", "examples/map/flatmap", "examples/map/forward_message",
Expand Down Expand Up @@ -49,5 +48,4 @@ jobs:
password: ${{ secrets.NUMAIO_PASSWORD }}
- name: Build, tag, and push images
run: |
./.hack/update_examples.sh --update ${{ matrix.example_directories }}
./.hack/update_examples.sh --build-push-example ${{ matrix.example_directories }}
./hack/update_examples.sh --build-push-example ${{ matrix.example_directories }}
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0
- run: git fetch --prune --prune-tags
- run: git tag -l 'v*'
- run: ./.hack/changelog.sh > CHANGELOG.md
- run: ./hack/changelog.sh > CHANGELOG.md
- uses: peter-evans/create-pull-request@v3
with:
title: 'docs: updated CHANGELOG.md'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
clean:
@rm -rf build dist .eggs *.egg-info
@rm -rf build .eggs *.egg-info
@rm -rf .benchmarks .coverage coverage.xml htmlcov report.xml .tox
@find . -type d -name '.mypy_cache' -exec rm -rf {} +
@find . -type d -name '__pycache__' -exec rm -rf {} +
Expand Down
22 changes: 6 additions & 16 deletions development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,18 @@ This document explains the development process for the Numaflow Python SDK.

1. Install [Poetry](https://python-poetry.org/docs/) before starting your test. Make sure you have the correct Python version
2. Make your SDK changes
3. Run `./.hack/update_examples.sh -u <example-directory-path>`. This command will create a tarball of the SDK, that includes your changes, in the directory of the example specified
4. Run `poetry update -vv` inside the example directory you used in the step above. This will create a `poetry.lock` file
5. Update the `example.py` inside the same example directory if needed
6. Run `make image` inside the same example directory to build your image
7. Now that you have the image with your customized example and code change, you can test it in a Numaflow pipeline. Example pipelines, `pipeline.yaml`, are also provided in most of the example directories.
3. Update the `example.py` inside the same example directory if needed
4. Run `make image` inside the same example directory to build your image
5. Now that you have the image with your customized example and code change, you can test it in a Numaflow pipeline. Example pipelines, `pipeline.yaml`, are also provided in most of the example directories.
Please check [Numaflow](https://numaflow.numaproj.io/) for more details

Each example directory has a Makefile which can be used to build, tag, and push images.
If you want to build and tag the image and then immediately push it to quay.io, use the `image-push` target.
If you want to build and tag a local image without pushing, use the `image` target.

Everytime you make a new SDK change, make sure to create the `dist/` folder in the example directory you would like
to test, by running:
If you would like to build and push a specific example, you can do so by running:
```shell
./.hack/update_examples.sh -u <example-directory-path>
```
When you are no longer using the `dist/` folders you can run `make clean` in the root directory, as well as in any example directory
in order to remove them.

If you would like to build and push a specific example, you can do so by running (make sure that the `dist/` folder is present in the directory):
```shell
./.hack/update_examples.sh -bpe <example-directory-path> -t <tag>
./hack/update_examples.sh -bpe <example-directory-path> -t <tag>
```
This is essentially equivalent to running `make image-push TAG=<tag>` in the example directory itself.
The default tag is `stable`, but it is recommended you specify your own for testing purposes, as the Github Actions CI uses the `stable` tag.
Expand All @@ -38,7 +28,7 @@ Note: before running the script, ensure that through the CLI, you are logged int
### Deploying

After confirming that your changes pass local testing:
1. Clean up testing artifacts (remove any `dist/` folders created, remove any test images on quay.io, etc.)
1. Clean up testing artifacts (remove any test images on quay.io, etc.)
2. Create a PR for your changes. Once your PR has been merged, a Github Actions workflow (`Docker Publish`) will be triggered, to build, tag (with `stable`), and push
all example images. This ensures that all example images are using the most up-to-date version of the SDK, i.e. the one including your
changes
Expand Down
7 changes: 4 additions & 3 deletions examples/map/even_odd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ RUN apt-get update \
FROM builder AS udf

WORKDIR $PYSETUP_PATH
COPY dist/ ./dist/
COPY pyproject.toml .
COPY ./ ./

WORKDIR $PYSETUP_PATH/examples/map/even_odd
RUN poetry install --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
COPY examples/map/even_odd /app
WORKDIR /app

RUN chmod +x entry.sh
Expand Down
25 changes: 16 additions & 9 deletions examples/map/even_odd/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
TAG ?= stable
PUSH ?= false
IMAGE_REGISTRY = quay.io/numaio/numaflow-python/even-odd:${TAG}
DOCKER_FILE_PATH = examples/map/even_odd/Dockerfile

.PHONY: update
update:
poetry update -vv

.PHONY: image-push
image-push:
docker buildx build -t "quay.io/numaio/numaflow-python/even-odd:${TAG}" --platform linux/amd64,linux/arm64 . --push
image-push: update
cd ../../../ && docker buildx build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} \
--platform linux/amd64,linux/arm64 . --push

.PHONY: image
image:
docker build -t "quay.io/numaio/numaflow-python/even-odd:${TAG}" .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-python/even-odd:${TAG}"; fi

.PHONY: clean
clean:
rm -rf ./dist
image: update
cd ../../../ && docker build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} .
@if [ "$(PUSH)" = "true" ]; then docker push ${IMAGE_REGISTRY}; fi
2 changes: 1 addition & 1 deletion examples/map/even_odd/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
args:
- python
- example.py
image: "quay.io/numaio/numaflow-python/even-odd:stable"
image: quay.io/numaio/numaflow-python/even-odd:stable
- name: even-sink
scale:
min: 1
Expand Down
2 changes: 1 addition & 1 deletion examples/map/even_odd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Numaflow developers"]

[tool.poetry.dependencies]
python = "~3.10"
pynumaflow = { path = "./dist/pynumaflow.tar.gz"}
pynumaflow = { path = "../../../"}

[tool.poetry.dev-dependencies]

Expand Down
7 changes: 4 additions & 3 deletions examples/map/flatmap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ RUN apt-get update \
FROM builder AS udf

WORKDIR $PYSETUP_PATH
COPY dist/ ./dist/
COPY pyproject.toml .
COPY ./ ./

WORKDIR $PYSETUP_PATH/examples/map/flatmap
RUN poetry install --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
COPY examples/map/even_odd /app
WORKDIR /app

RUN chmod +x entry.sh
Expand Down
25 changes: 16 additions & 9 deletions examples/map/flatmap/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
TAG ?= stable
PUSH ?= false
IMAGE_REGISTRY = quay.io/numaio/numaflow-python/map-flatmap:${TAG}
DOCKER_FILE_PATH = examples/map/flatmap/Dockerfile

.PHONY: update
update:
poetry update -vv

.PHONY: image-push
image-push:
docker buildx build -t "quay.io/numaio/numaflow-python/map-flatmap:${TAG}" --platform linux/amd64,linux/arm64 . --push
image-push: update
cd ../../../ && docker buildx build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} \
--platform linux/amd64,linux/arm64 . --push

.PHONY: image
image:
docker build -t "quay.io/numaio/numaflow-python/map-flatmap:${TAG}" .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-python/map-flatmap:${TAG}"; fi

.PHONY: clean
clean:
rm -rf ./dist
image: update
cd ../../../ && docker build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} .
@if [ "$(PUSH)" = "true" ]; then docker push ${IMAGE_REGISTRY}; fi
2 changes: 1 addition & 1 deletion examples/map/flatmap/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
- name: flatmap
udf:
container:
image: "quay.io/numaio/numaflow-python/map-flatmap:stable"
image: quay.io/numaio/numaflow-python/map-flatmap:stable
env:
- name: PYTHONDEBUG
value: "true"
Expand Down
2 changes: 1 addition & 1 deletion examples/map/flatmap/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Numaflow developers"]

[tool.poetry.dependencies]
python = "~3.10"
pynumaflow = { path = "./dist/pynumaflow.tar.gz"}
pynumaflow = { path = "../../../"}

[tool.poetry.dev-dependencies]

Expand Down
7 changes: 4 additions & 3 deletions examples/map/forward_message/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ RUN apt-get update \
FROM builder AS udf

WORKDIR $PYSETUP_PATH
COPY dist/ ./dist/
COPY pyproject.toml .
COPY ./ ./

WORKDIR $PYSETUP_PATH/examples/map/forward_message
RUN poetry install --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
COPY examples/map/forward_message /app
WORKDIR /app

RUN chmod +x entry.sh
Expand Down
25 changes: 16 additions & 9 deletions examples/map/forward_message/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
TAG ?= stable
PUSH ?= false
IMAGE_REGISTRY = quay.io/numaio/numaflow-python/map-forward-message:${TAG}
DOCKER_FILE_PATH = examples/map/forward_message/Dockerfile

.PHONY: update
update:
poetry update -vv

.PHONY: image-push
image-push:
docker buildx build -t "quay.io/numaio/numaflow-python/map-forward-message:${TAG}" --platform linux/amd64,linux/arm64 . --push
image-push: update
cd ../../../ && docker buildx build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} \
--platform linux/amd64,linux/arm64 . --push

.PHONY: image
image:
docker build -t "quay.io/numaio/numaflow-python/map-forward-message:${TAG}" .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-python/map-forward-message:${TAG}"; fi

.PHONY: clean
clean:
rm -rf ./dist
image: update
cd ../../../ && docker build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} .
@if [ "$(PUSH)" = "true" ]; then docker push ${IMAGE_REGISTRY}; fi
2 changes: 1 addition & 1 deletion examples/map/forward_message/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
args:
- python
- example.py
image: "quay.io/numaio/numaflow-python/map-forward-message:stable"
image: quay.io/numaio/numaflow-python/map-forward-message:stable
- name: log-output
sink:
log: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/map/forward_message/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Numaflow developers"]

[tool.poetry.dependencies]
python = "~3.10"
pynumaflow = { path = "./dist/pynumaflow.tar.gz"}
pynumaflow = { path = "../../../"}

[tool.poetry.dev-dependencies]

Expand Down
7 changes: 4 additions & 3 deletions examples/map/multiproc_map/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ RUN apt-get update \
FROM builder AS udf

WORKDIR $PYSETUP_PATH
COPY dist/ ./dist/
COPY pyproject.toml .
COPY ./ ./

WORKDIR $PYSETUP_PATH/examples/map/multiproc_map
RUN poetry install --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
COPY examples/map/multiproc_map /app
WORKDIR /app

RUN chmod +x entry.sh
Expand Down
25 changes: 16 additions & 9 deletions examples/map/multiproc_map/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
TAG ?= stable
PUSH ?= false
IMAGE_REGISTRY = quay.io/numaio/numaflow-python/multiproc:${TAG}
DOCKER_FILE_PATH = examples/map/multiproc_map/Dockerfile

.PHONY: update
update:
poetry update -vv

.PHONY: image-push
image-push:
docker buildx build -t "quay.io/numaio/numaflow-python/multiproc:${TAG}" --platform linux/amd64,linux/arm64 . --push
image-push: update
cd ../../../ && docker buildx build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} \
--platform linux/amd64,linux/arm64 . --push

.PHONY: image
image:
docker build -t "quay.io/numaio/numaflow-python/multiproc:${TAG}" .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-python/multiproc:${TAG}"; fi

.PHONY: clean
clean:
rm -rf ./dist
image: update
cd ../../../ && docker build \
-f ${DOCKER_FILE_PATH} \
-t ${IMAGE_REGISTRY} .
@if [ "$(PUSH)" = "true" ]; then docker push ${IMAGE_REGISTRY}; fi
2 changes: 1 addition & 1 deletion examples/map/multiproc_map/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
- name: mult
udf:
container:
image: "quay.io/numaio/numaflow-python/multiproc:stable"
image: quay.io/numaio/numaflow-python/multiproc:stable
env:
- name: PYTHONDEBUG
value: "true"
Expand Down
2 changes: 1 addition & 1 deletion examples/map/multiproc_map/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Numaflow developers"]

[tool.poetry.dependencies]
python = "~3.10"
pynumaflow = { path = "./dist/pynumaflow.tar.gz"}
pynumaflow = { path = "../../../"}

[tool.poetry.dev-dependencies]

Expand Down
7 changes: 4 additions & 3 deletions examples/mapstream/flatmap_stream/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ RUN apt-get update \
FROM builder AS udf

WORKDIR $PYSETUP_PATH
COPY dist/ ./dist/
COPY pyproject.toml .
COPY ./ ./

WORKDIR $PYSETUP_PATH/examples/mapstream/flatmap_stream
RUN poetry install --no-cache --no-root && \
rm -rf ~/.cache/pypoetry/

ADD . /app
COPY examples/mapstream/flatmap_stream /app
WORKDIR /app

RUN chmod +x entry.sh
Expand Down
Loading

0 comments on commit d289a0d

Please sign in to comment.