Skip to content

Commit d9d15d9

Browse files
committed
feat(cli,model,llm-runtime): unify LLM runtimes (#285)
Because - LLM runtimes are rapidly evolving, and mainstream tools like `Transformers`, `vLLM`, and `MLC LLM` now support advanced LLM features. This commit - refactored CLI codebase - unified Dockerfile for multi-platform build current supporting CPU for both `amd64` and `arm64` and GPU for only `amd66` - added unit testing for CLI commands
1 parent 970f693 commit d9d15d9

29 files changed

+2555
-1230
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @GeorgeWilliamStrong @pinglin
1+
* @pinglin

.github/CONTRIBUTING.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,34 @@ Before delving into the details to come up with your first PR, please familiaris
2727

2828
To confirm these system dependencies are configured correctly:
2929

30-
```bash
31-
$ make doctor
30+
```shell
31+
make doctor
3232
```
3333

3434
#### Installation
3535

3636
Fetch git submodules:
3737

38-
```bash
39-
$ make get-proto
38+
```shell
39+
make get-proto
4040
```
4141

4242
Fetch and generate json schema files and dataclass:
4343

44-
```bash
45-
$ make update-specs
44+
```shell
45+
make update-specs
4646
# `instill/resources/schema/airbyte/OAuth2.py` will be generated with an error, need to manually remove the `OAuth2.` in `OAuth2.AuthType.OAuth2_0`
4747
```
4848

4949
> [!IMPORTANT]
50-
> **Create a `.venv` folder if you are rusing `conda`**
50+
> **Create a `.venv` folder if you are using `conda`**
5151
> This will be fixed soon, but currently if you are installing the development dependencies inside a conda env,
52-
> you will need to create a `.venv` folder in your proejct root to prevent errors
52+
> you will need to create a `.venv` folder in your project root to prevent errors
5353
5454
Install project dependencies into a virtual environment:
5555

56-
```text
57-
$ make install
56+
```shell
57+
make install
5858
```
5959

6060
### Development Tasks
@@ -63,28 +63,28 @@ $ make install
6363

6464
Run the tests:
6565

66-
```text
67-
$ make test
66+
```shell
67+
make test
6868
```
6969

7070
Run static analysis:
7171

72-
```text
73-
$ make check
72+
```shell
73+
make check
7474
```
7575

7676
Build the documentation:
7777

78-
```text
79-
$ make docs
78+
```shell
79+
make docs
8080
```
8181

8282
#### Automatic
8383

8484
Keep all of the above tasks running on change:
8585

86-
```text
87-
$ make dev
86+
```shell
87+
make dev
8888
```
8989

9090
> In order to have OS X notifications, `brew install terminal-notifier`.
@@ -93,16 +93,16 @@ $ make dev
9393

9494
The CI server will report overall build status:
9595

96-
```text
97-
$ make all
96+
```shell
97+
make all
9898
```
9999

100100
### Release Tasks
101101

102102
Release to PyPI:
103103

104-
```text
105-
$ make upload
104+
```shell
105+
make upload
106106
```
107107

108108
### Sending PRs

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.9", "3.10", "3.11"]
10+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1111

1212
steps:
1313
- uses: actions/checkout@v4
@@ -19,7 +19,9 @@ jobs:
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121

22-
- uses: Gr1N/setup-poetry@v9
22+
- uses: abatilo/actions-poetry@v4
23+
with:
24+
poetry-version: 2.1.2
2325

2426
- name: Check dependencies
2527
run: make doctor

.pylint.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ disable=
6969
too-many-instance-attributes,
7070
too-many-statements,
7171
too-many-lines,
72+
too-many-positional-arguments,
7273
attribute-defined-outside-init,
7374
unsupported-assignment-operation,
7475
unsupported-delete-operation,
@@ -408,5 +409,5 @@ known-third-party=enchant
408409
[EXCEPTIONS]
409410

410411
# Exceptions that will emit a warning when being caught. Defaults to
411-
# "Exception"
412-
overgeneral-exceptions=Exception
412+
# "builtins.Exception"
413+
overgeneral-exceptions=builtins.Exception

.verchew.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ version = 3
1111
[Poetry]
1212

1313
cli = poetry
14-
version = 1
14+
version = 2

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
[![Unix Build Status](https://img.shields.io/github/actions/workflow/status/instill-ai/python-sdk/build.yml?branch=main&label=linux)](https://github.com/instill-ai/python-sdk/actions) [![Coverage Status](https://img.shields.io/codecov/c/gh/instill-ai/python-sdk)](https://codecov.io/gh/instill-ai/python-sdk) [![PyPI License](https://img.shields.io/pypi/l/instill-sdk.svg)](https://pypi.org/project/instill-sdk) [![PyPI Version](https://img.shields.io/pypi/v/instill-sdk.svg)](https://pypi.org/project/instill-sdk) [![PyPI Downloads](https://img.shields.io/pypi/dm/instill-sdk.svg?color=orange)](https://pypistats.org/packages/instill-sdk)
1+
# Instill Core Python SDK
22

3-
> [!IMPORTANT]<br>
4-
> **This SDK tool is under active development**<br>
5-
> For any bug found or featur request, feel free to open any issue regarding this SDK in our [instill-core](https://github.com/instill-ai/instill-core/issues) repo.
3+
[![Unix Build Status](https://img.shields.io/github/actions/workflow/status/instill-ai/python-sdk/build.yml?branch=main&label=linux)](https://github.com/instill-ai/python-sdk/actions) [![Coverage Status](https://img.shields.io/codecov/c/gh/instill-ai/python-sdk)](https://codecov.io/gh/instill-ai/python-sdk) [![PyPI License](https://img.shields.io/pypi/l/instill-sdk.svg?color=lightgreen)](https://pypi.org/project/instill-sdk) [![PyPI Version](https://img.shields.io/pypi/v/instill-sdk.svg?color=lightgreen)](https://pypi.org/project/instill-sdk) [![PyPI Downloads](https://img.shields.io/pypi/dm/instill-sdk.svg?color=lightgreen)](https://pypistats.org/packages/instill-sdk)
64

7-
# Overview
5+
> [!IMPORTANT]
6+
> **This SDK tool is under active development**
7+
> For any bug found or feature request, feel free to open any issue regarding this SDK in our [instill-core](https://github.com/instill-ai/instill-core/issues) repo.
8+
9+
## Overview
810

911
Welcome to Instill Python SDK, where the world of AI-first application comes alive in the form of Python.
1012

@@ -15,53 +17,54 @@ Before you jump into creating your first application with this SDK tool, we reco
1517

1618
## Setup
1719

18-
> [!NOTE]<br>
20+
> [!NOTE]
1921
> For setting up development environment, please refer to [Contributing](#contributing)
2022
2123
### Requirements
2224

23-
- Python 3.8 - 3.11
25+
- Python 3.9 - 3.12
26+
- CUDA 12.2 - 12.8 (if you want to build a model with GPU support)
2427

2528
### Installation
2629

27-
> [!WARNING]<br>
28-
> If your host machine is on arm64 architecture(including Apple silicon machines, equipped with m1/m2 processors), there are some issues when installing `grpcio` within `conda` environment. You will have to manually build and install it like below. Read more about this issue [here](https://github.com/grpc/grpc/issues/33714).
30+
> [!WARNING]
31+
> If your host machine is on arm64 architecture(including Apple silicon machines, equipped with m1/m2 processors), there are some issues when installing `grpcio` within `conda` environment. You will have to manually build and install it like below. Read more about this issue in the [gRPC GitHub issue](https://github.com/grpc/grpc/issues/33714).
2932
30-
```bash
31-
$ GRPC_PYTHON_LDFLAGS=" -framework CoreFoundation" pip install grpcio --no-binary :all:
33+
```shell
34+
GRPC_PYTHON_LDFLAGS=" -framework CoreFoundation" pip install grpcio --no-binary :all:
3235
```
3336

3437
Install it directly into an activated virtual environment:
3538

36-
```text
37-
$ pip install instill-sdk
39+
```shell
40+
pip install instill-sdk
3841
```
3942

4043
or add it to your [Poetry](https://poetry.eustace.io/) project:
4144

42-
```text
43-
$ poetry add instill-sdk
45+
```shell
46+
poetry add instill-sdk
4447
```
4548

4649
### Check import
4750

4851
After installation, you can check if it has been installed correctly:
4952

50-
```text
51-
$ python
53+
```shell
54+
python
5255
>>> import instill
5356
>>> instill.__version__
5457
```
5558

56-
### Config `Instill Core` or `Instill Cloud` instance
59+
### Config `Instill Core` or `Managed Instill Core` instance
5760

5861
Before we can start using this SDK, you will need to properly config your target instance. We support two ways to setup the configs, which are
5962

6063
#### Config file
6164

6265
create a config file under this path `${HOME}/.config/instill/sdk/python/config.yml`, and within that path you will need to fill in some basic parameters for your desired host.[^1]
6366

64-
[^1]: You can obtain an `api_token` by simply going to Settings > API Tokens page from the console, no matter it is `Instill Core` or `Instill Cloud`.
67+
[^1]: You can obtain an `api_token` by simply going to Settings > API Tokens page from the console, no matter it is `Instill Core` or `Managed Instill Core`.
6568

6669
Within the config file, you can define multiple instances with the `alias` of your liking, later in the SDK you can refer to this `alias` to switch between instances.[^2]
6770

@@ -143,9 +146,9 @@ user = client.mgmt_service.get_user()
143146
# ...
144147
```
145148

146-
Please find more usages for this sdk at [here](https://www.instill-ai.dev/docs/sdk/python#usage)
149+
Please find more usages for this SDK in our [documentation](https://www.instill-ai.dev/docs/sdk/python#usage)
147150

148-
**You can also find some notebook examples [here](https://github.com/instill-ai/python-sdk/tree/main/notebooks)**
151+
**You can also find some notebook examples in our [notebooks directory](https://github.com/instill-ai/python-sdk/tree/main/notebooks)**
149152

150153
### Create a model
151154

@@ -168,7 +171,7 @@ client.model_service.create_model(
168171

169172
`Instill Model` is an advanced MLOps/LLMOps platform that was specifically crafted to facilitate the efficient management and orchestration of model deployments for unstructured data ETL. With `Instill Model`, you can easily create, manage, and deploy your own custom models with ease in `Instill Core` or on the cloud with `Instill Cloud`.
170173

171-
Follow the instructions [here](https://www.instill-ai.dev/docs/model/create) to build and deploy your model.
174+
Follow the [model creation guide](https://www.instill-ai.dev/docs/model/create) to build and deploy your model.
172175

173176
### Create pipeline
174177

instill/clients/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from instill.clients.model import ModelClient
66
from instill.clients.pipeline import PipelineClient
77
from instill.helpers.const import HOST_URL_PROD
8-
from instill.utils.error_handler import NotServingException
8+
from instill.utils.error_handler import NotServingException, NamespaceException
99
from instill.utils.logger import Logger
1010

1111

@@ -76,7 +76,7 @@ def _lookup_namespace_uid(self, namespace_id: str):
7676
):
7777
namespace_uid = self.mgmt.get_organization(namespace_id).organization.uid
7878
else:
79-
raise Exception("namespace ID not available")
79+
raise NamespaceException("namespace ID not available")
8080

8181
return namespace_uid
8282

instill/clients/mgmt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from instill.clients.base import Client, RequestFactory
1515
from instill.clients.instance import InstillInstance
1616
from instill.helpers.const import HOST_URL_PROD
17-
from instill.utils.error_handler import grpc_handler
17+
from instill.utils.error_handler import grpc_handler, NamespaceException
1818

1919

2020
class MgmtClient(Client):
@@ -75,7 +75,7 @@ def _lookup_namespace_uid(self, namespace_id: str):
7575
):
7676
namespace_uid = self.get_organization(namespace_id).organization.uid
7777
else:
78-
raise Exception("namespace ID not available")
78+
raise NamespaceException("namespace ID not available")
7979

8080
return namespace_uid
8181

0 commit comments

Comments
 (0)