Skip to content

Commit 0bd4807

Browse files
authored
fix(ray): make non-editable work with dynamic pkg import (#277)
Because - `pip install` will put instill-sdk in the standard anaconda3 package path. This commit - make editable and non-editable work together.
1 parent d393cf2 commit 0bd4807

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

instill/helpers/cli.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def cli():
6363
build_parser.add_argument(
6464
"-a",
6565
"--target-arch",
66-
help="target platform architecture for the model image, default to host",
66+
help="target platform architecture for the model image, default to host architecture",
6767
default=default_platform,
6868
choices=["arm64", "amd64"],
6969
required=False,
@@ -298,11 +298,23 @@ def prepare_build_command(args, tmpdir, dockerfile, build_vars):
298298

299299
command.extend(
300300
[
301+
# editable mode
301302
"--build-arg",
302303
f"INSTILL_PYTHON_SDK_PROJECT_NAME={instill_python_sdk_project_name}",
304+
"--build-arg",
305+
(
306+
"PYTHONPATH_USER_DEFINED_PROTO=/home/ray/"
307+
f"{instill_python_sdk_project_name}/instill/protogen/model/ray/v1alpha"
308+
),
303309
]
304310
if instill_python_sdk_project_name
305-
else []
311+
else [
312+
"--build-arg",
313+
(
314+
"PYTHONPATH_USER_DEFINED_PROTO=/home/ray/"
315+
"anaconda3/lib/python3.11/site-packages/instill/protogen/model/ray/v1alpha"
316+
),
317+
]
306318
)
307319

308320
return command

instill/helpers/docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ COPY --chown=ray:users . .
3131

3232
ARG INSTILL_PYTHON_SDK_PROJECT_NAME
3333
ARG INSTILL_PYTHON_SDK_VERSION
34-
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
34+
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
3535
if [ ! -z "$INSTILL_PYTHON_SDK_PROJECT_NAME" ]; then \
3636
pip install -e ${INSTILL_PYTHON_SDK_PROJECT_NAME}; \
3737
elif [ -f instill_sdk-${INSTILL_PYTHON_SDK_VERSION}dev-py3-none-any.whl ]; then \
@@ -45,4 +45,5 @@ RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
4545
# created in the runtime environment. These objects may depend on this python-sdk.
4646
# Instead of installing the SDK in the Ray image, we copy
4747
# the entire SDK to /home/ray and set PYTHONPATH to allow dynamic importing.
48-
ENV PYTHONPATH=/home/ray/python-sdk/instill/protogen/model/ray/v1alpha
48+
ARG PYTHONPATH_USER_DEFINED_PROTO
49+
ENV PYTHONPATH=${PYTHONPATH_USER_DEFINED_PROTO}

instill/helpers/docker/Dockerfile.vllm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ USER ray
9595
# created in the runtime environment. These objects may depend on this python-sdk.
9696
# Instead of installing the SDK in the Ray image, we copy
9797
# the entire SDK to /home/ray and set PYTHONPATH to allow dynamic importing.
98-
ENV PYTHONPATH=/home/ray/python-sdk/instill/protogen/model/ray/v1alpha
98+
ARG PYTHONPATH_USER_DEFINED_PROTO
99+
ENV PYTHONPATH=${PYTHONPATH_USER_DEFINED_PROTO}

0 commit comments

Comments
 (0)