From 8f14c21f67d5b477a7287cd73719cb3908204c4d Mon Sep 17 00:00:00 2001 From: Heiru Wu Date: Wed, 31 Jul 2024 03:39:19 +0800 Subject: [PATCH] feat(build): support local sdk wheel for building model image --- instill/helpers/cli.py | 15 +++++++++++++++ instill/helpers/init-templates/Dockerfile | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/instill/helpers/cli.py b/instill/helpers/cli.py index b39d80a..d814d88 100644 --- a/instill/helpers/cli.py +++ b/instill/helpers/cli.py @@ -55,18 +55,27 @@ def cli(): required=False, ) build_parser.add_argument( + "-n", "--no-cache", help="build the image without cache", action="store_true", required=False, ) build_parser.add_argument( + "-a", "--target-arch", help="target platform architecture for the model image, default to host", default=default_platform, choices=["arm64", "amd64"], required=False, ) + build_parser.add_argument( + "-w", + "--sdk-wheel", + help="instill sdk wheel absolute path for debug purpose", + default=None, + required=False, + ) # push push_parser = subcommands.add_parser("push", help="Push model image") @@ -179,6 +188,12 @@ def build(args): ) shutil.copytree(os.getcwd(), tmpdir, dirs_exist_ok=True) + if args.sdk_wheel is not None: + shutil.copyfile( + args.sdk_wheel, + f"{tmpdir}/instill_sdk-{instill_version}dev-py3-none-any.whl", + ) + target_arch_suffix = "-aarch64" if args.target_arch == "arm64" else "" Logger.i("[Instill Builder] Building model image...") diff --git a/instill/helpers/init-templates/Dockerfile b/instill/helpers/init-templates/Dockerfile index cd1341c..eaeb9c1 100644 --- a/instill/helpers/init-templates/Dockerfile +++ b/instill/helpers/init-templates/Dockerfile @@ -21,7 +21,11 @@ RUN for package in ${PACKAGES}; do \ COPY --chown=ray:users --exclude=model.py . . ARG SDK_VERSION -RUN pip install --default-timeout=1000 --no-cache-dir instill-sdk==${SDK_VERSION} +RUN if [ ! -f instill_sdk-${SDK_VERSION}dev-py3-none-any.whl ]; then \ + pip install --default-timeout=1000 --no-cache-dir instill-sdk==${SDK_VERSION}; \ + else \ + pip install instill_sdk-${SDK_VERSION}dev-py3-none-any.whl; \ + fi; WORKDIR /home/ray COPY --chown=ray:users model.py _model.py