<#1976 feat: add jupyter notebook decorator> Pull ...
# flyte-github
a
#1976 feat: add jupyter notebook decorator Pull request opened by jasonlai1218 TL;DR add jupyter notebook in
flytekit-flyin/flytekitplugins/flyin
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 For the convenience of developers debugging: 1.
vscode
2.
jupyter notebook
Tracking Issue NA Follow-up issue flyteorg/flyte#4284 Test Method 1 - Sample Code(ImageSpec)
Copy code
from flytekit import task, workflow, ImageSpec
from flytekitplugins.flyin import jupyter
scode_plugin="git+https://github.com/jasonlai1218/flytekit.git@025179eef7cf95097aa8177df397e59a7f50ff04#subdirectory=plugins/flytekit-flyin"

image_spec = ImageSpec(
    python_version="3.9.13",
    packages=["flytekit", vscode_plugin],
    apt_packages=["git"],
    registry="localhost:30000",
    env={"FLYTE_SDK_LOGGING_LEVEL": "20"},
)


@task(container_image=image_spec)
@jupyter(port=9090, max_idle_seconds=3600)
def t(a: int, b: int) -> int:
    return a + b


@workflow
def wf(a: int=5, b: int=3) -> int:
    out = t(a=a, b=b)
    return out
and execute
pyflyte run --remote jupyter_notebook.py wf --a 2 --b 1
Test Method 2 - (DockerfileJupyter)
Copy code
FROM python:3.9-slim-buster
USER root
WORKDIR /root
ENV PYTHONPATH /root
RUN apt-get update && apt-get install build-essential -y
RUN apt-get install git -y

RUN pip install -U git+https://github.com/jasonlai1218/flytekit.git@025179eef7cf95097aa8177df397e59a7f50ff04#subdirectory=plugins/flytekit-flyin

RUN pip install -U git+https://github.com/jasonlai1218/flytekit.git@025179eef7cf95097aa8177df397e59a7f50ff04
and execute
docker build --no-cache --push . -f DockerfileJupyter -t localhost:30000/flytekit:jupyter --build-arg PYTHON_VERSION=3.9
pyflyte run --remote --image localhost:30000/flytekit:jupyter jupyter_notebook.py wf --a 2 --b 1
Result * * * Screenshot 2023-11-27 at 12 54 13 AM Screenshot 2023-11-27 at 12 54 22 AM *Screenshot 2023-11-27 at 12 54 32 AM )* Screenshot 2023-11-27 at 12 54 44 AM Screenshot 2023-11-27 at 12 57 33 AM Screenshot 2023-11-27 at 12 57 40 AM flyteorg/flytekit Codecov: 85.81% (-0.01%) compared to a6f9991 Codecov: 85.10% of diff hit (target 85.81%) ✅ 28 other checks have passed 28/30 successful checks