Skip to content

Commit 971e640

Browse files
committed
chore(mypy): fix make check errors
1 parent 13cbace commit 971e640

File tree

4 files changed

+94
-13
lines changed

4 files changed

+94
-13
lines changed

instill/clients/base.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Base client interface module."""
2+
13
from abc import ABC, abstractmethod
24
from typing import Union
35

@@ -15,37 +17,42 @@ class Client(ABC):
1517
@property
1618
@abstractmethod
1719
def host(self):
18-
pass
20+
"""Get the host address."""
1921

2022
@host.setter
2123
@abstractmethod
22-
def host(self):
23-
pass
24+
def host(self, value):
25+
"""Set the host address."""
2426

2527
@property
2628
@abstractmethod
2729
def metadata(self):
28-
pass
30+
"""Get the metadata."""
2931

3032
@metadata.setter
3133
@abstractmethod
32-
def metadata(self):
33-
pass
34+
def metadata(self, value):
35+
"""Set the metadata."""
3436

3537
@abstractmethod
3638
def liveness(self):
39+
"""Check if the service is alive."""
3740
raise NotImplementedError
3841

3942
@abstractmethod
4043
def readiness(self):
44+
"""Check if the service is ready to serve."""
4145
raise NotImplementedError
4246

4347
@abstractmethod
4448
def is_serving(self):
49+
"""Check if the service is currently serving."""
4550
raise NotImplementedError
4651

4752

4853
class RequestFactory:
54+
"""Factory class for creating and sending gRPC requests."""
55+
4956
def __init__(
5057
self,
5158
method: Union[grpc.UnaryUnaryMultiCallable, grpc.StreamUnaryMultiCallable],
@@ -57,13 +64,16 @@ def __init__(
5764
self.metadata = metadata
5865

5966
def send_sync(self):
67+
"""Send a synchronous gRPC request."""
6068
return self.method(request=self.request, metadata=self.metadata)
6169

6270
def send_stream(self):
71+
"""Send a streaming gRPC request."""
6372
return self.method(
6473
request_iterator=iter([self.request]),
6574
metadata=self.metadata,
6675
)
6776

6877
async def send_async(self):
78+
"""Send an asynchronous gRPC request."""
6979
return await self.method(request=self.request, metadata=self.metadata)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# syntax=docker/dockerfile:1.7-labs
2+
ARG RAY_VERSION
3+
ARG PYTHON_VERSION
4+
ARG CUDA_SUFFIX
5+
ARG TARGET_ARCH_SUFFIX
6+
7+
FROM rayproject/ray:${RAY_VERSION}-py${PYTHON_VERSION}${CUDA_SUFFIX}${TARGET_ARCH_SUFFIX}
8+
9+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
10+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
11+
sudo apt-get update && \
12+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y tzdata curl vim cmake && \
13+
sudo rm -rf /var/lib/apt/lists/*
14+
15+
# Build mlc-llm from source
16+
RUN conda create -y -q -n mlc-venv -c conda-forge "cmake>=3.24" rust git python=${PYTHON_VERSION}
17+
RUN conda run -n mlc-venv bash -c " \
18+
git clone --recursive https://github.com/mlc-ai/mlc-llm.git && \
19+
cd mlc-llm/ && \
20+
mkdir -p build && cd build && \
21+
echo '
22+
set(TVM_SOURCE_DIR 3rdparty/tvm)\n \
23+
set(CMAKE_BUILD_TYPE RelWithDebInfo)\n \
24+
set(USE_CUDA OFF)\n \
25+
set(USE_CUTLASS OFF)\n \
26+
set(USE_CUBLAS OFF)\n \
27+
set(USE_ROCM OFF)\n \
28+
set(USE_VULKAN OFF)\n \
29+
set(USE_METAL OFF)\n \
30+
set(USE_OPENCL OFF)\n \
31+
set(USE_OPENCL_ENABLE_HOST_PTR OFF)\n \
32+
set(USE_FLASHINFER ON)' > config.cmake && \
33+
cmake .. && cmake --build . --parallel $(nproc) && sudo make install"
34+
35+
ARG SYSTEM_PACKAGES
36+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
37+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
38+
sudo apt-get update && \
39+
for package in ${SYSTEM_PACKAGES}; do \
40+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y $package; \
41+
done && \
42+
sudo rm -rf /var/lib/apt/lists/*
43+
44+
ARG PYTHON_PACKAGES
45+
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
46+
for package in ${PYTHON_PACKAGES}; do \
47+
pip install $package; \
48+
done
49+
50+
COPY --chown=ray:users . .
51+
52+
ARG INSTILL_PYTHON_SDK_PROJECT_NAME
53+
ARG INSTILL_PYTHON_SDK_VERSION
54+
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
55+
if [ ! -z "$INSTILL_PYTHON_SDK_PROJECT_NAME" ]; then \
56+
pip install -e ${INSTILL_PYTHON_SDK_PROJECT_NAME}; \
57+
elif [ -f instill_sdk-${INSTILL_PYTHON_SDK_VERSION}dev-py3-none-any.whl ]; then \
58+
pip install instill_sdk-${INSTILL_PYTHON_SDK_VERSION}dev-py3-none-any.whl; \
59+
else \
60+
pip install instill-sdk==${INSTILL_PYTHON_SDK_VERSION}; \
61+
fi;
62+
63+
# The python-sdk is a local module that is not installed in the Ray worker environment.
64+
# Ray workers need to deserialize model configurations and deployment settings that were
65+
# created in the runtime environment. These objects may depend on this python-sdk.
66+
# Instead of installing the SDK in the Ray image, we copy
67+
# the entire SDK to /home/ray and set PYTHONPATH to allow dynamic importing.
68+
ARG PYTHONPATH_USER_DEFINED_PROTO
69+
ENV PYTHONPATH=${PYTHONPATH_USER_DEFINED_PROTO}

instill/resources/resource.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Base resource interface module."""
2+
13
# pylint: disable=no-member,wrong-import-position
24
from abc import ABC, abstractmethod
35

@@ -12,19 +14,19 @@ class Resource(ABC):
1214
@property
1315
@abstractmethod
1416
def client(self):
15-
pass
17+
"""Get the client instance."""
1618

1719
@client.setter
1820
@abstractmethod
19-
def client(self):
20-
pass
21+
def client(self, value):
22+
"""Set the client instance."""
2123

2224
@property
2325
@abstractmethod
2426
def resource(self):
25-
pass
27+
"""Get the resource instance."""
2628

2729
@resource.setter
2830
@abstractmethod
29-
def resource(self):
30-
pass
31+
def resource(self, value):
32+
"""Set the resource instance."""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protoc-gen-openapiv2 = "^0.0.1"
4040
pydantic = ">=1.10.13"
4141
python = ">3.9.1,<3.12"
4242
pyyaml = "^6.0.1"
43-
ray = "^2.44.1"
43+
ray = "2.47.0"
4444
requests = "^2.32.3"
4545
starlette = "^0.46.1"
4646
types-protobuf = "^4.24.0.1"

0 commit comments

Comments
 (0)