<#1901 Add image transformer> Pull request opened ...
# flyte-github
a
#1901 Add image transformer Pull request opened by pingsutw TL;DR Add an image transformer, so the task can return PIL.Image.Image as an output, Type ☐ Bug Fix ☑︎ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☑︎ Smoke tested ☑︎ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description My example:
Copy code
import io
from typing_extensions import Annotated

import requests

from flytekit import task, workflow, ImageSpec
import PIL.Image

new_flytekit = "git+https://github.com/flyteorg/flytekit.git@da9f6645bb5e99580e38d89ef6824b81a1054279"
image_spec = ImageSpec(base_image="python:3.8-slim-buster", packages=[new_flytekit, "pillow"], apt_packages=["git"], registry="pingsutw")


@task(enable_deck=True, container_image=image_spec)
def t1() -> PIL.Image.Image:
    url = "https://miro.medium.com/v2/resize:fit:1400/1*0T9PjBnJB9H0Y4qrllkJtQ.png"
    response = requests.get(url)
    image_bytes = io.BytesIO(response.content)
    im = PIL.Image.open(image_bytes)
    return im


@workflow
def wf():
    t1()


if __name__ == "__main__":
    wf()

image▾

Tracking Issue flyteorg/flyte#4193 Follow-up issue NA flyteorg/flytekit Codecov: 55.09% (-0.12%) compared to 8dc26d2 Codecov: 2.08% of diff hit (target 55.20%) ✅ 28 other checks have passed 28/30 successful checks