MLflow plugin for Triton Inference Server with secure Python function execution
Project description
w-train-utils-mlflow-triton-plugin
MLflow plugin for Triton Inference Server with secure Python function execution
๐ ์ฃผ์ ๊ธฐ๋ฅ
๐ MLflow-Triton ํตํฉ
- MLflow ๋ชจ๋ธ์ Triton Inference Server๋ก ์๋ ๋ฐฐํฌ
- Python ํจ์๋ฅผ Triton ๋ชจ๋ธ๋ก ๋ณํ
- S3/MinIO ๊ธฐ๋ฐ ๋ชจ๋ธ ์ ์ฅ์ ์ง์
๐ ๏ธ Keynet CLI
- Python ํจ์ ๊ฒ์ฆ ๋ฐ ํ ์คํธ
- ํจ์ ๋ฐฐํฌ ๋ฐ ๊ด๋ฆฌ
- ์ธ์ฆ ๋ฐ ์๊ฒฉ ์ฆ๋ช ๊ด๋ฆฌ
- ๋ค์ํ Python ๋ฒ์ ์ง์ (3.9, 3.10, 3.11, 3.12)
๐ ์ค์น
pip install wtu-mlflow-triton-plugin
๐ ์ฌ์ฉ๋ฒ
1. Python ํจ์ ์์ฑ
# my_function.py
from wtu_mlflow_triton_plugin.function import keynet_function
@keynet_function("my_model")
def main(args):
"""์
๋ ฅ์ ๋ฐ์ ์ฒ๋ฆฌํ๋ ํจ์"""
# args๋ ๋์
๋๋ฆฌ ํํ์ ์
๋ ฅ
text = args.get("text", "")
result = text.upper()
return {
"result": result,
"length": len(text)
}
2. Keynet CLI๋ก ํจ์ ๊ฒ์ฆ
# ํจ์ ๊ฒ์ฆ
keynet validate my_function.py
# ์์กด์ฑ๊ณผ ํจ๊ป ๊ฒ์ฆ
keynet validate my_function.py -r requirements.txt
# ํ
์คํธ ํ๋ผ๋ฏธํฐ๋ก ์คํ
keynet test my_function.py --params '{"text": "hello world"}'
3. ํจ์ ๋ฐฐํฌ
# ๋ก์ปฌ ํ๊ฒฝ์ ๋ฐฐํฌ
keynet deploy my_function.py --name my_model
# ์๊ฒฉ ์๋ฒ์ ๋ฐฐํฌ
keynet deploy my_function.py --name my_model --server https://api.example.com
4. MLflow์ ํตํฉ
import mlflow
from wtu_mlflow_triton_plugin import TritonPlugin
# MLflow ์ค์
mlflow.set_tracking_uri("http://localhost:5001")
# Triton ํ๋ฌ๊ทธ์ธ ํ์ฑํ
with mlflow.start_run():
# ๋ชจ๋ธ ๋ก๊น
mlflow.pyfunc.log_model(
artifact_path="model",
python_model=my_model,
deployment_flavor="triton"
)
# Triton์ผ๋ก ๋ฐฐํฌ
mlflow.deployments.create_deployment(
name="my-deployment",
model_uri=f"runs:/{run_id}/model",
flavor="triton"
)
๐ง ํ๊ฒฝ ์ค์
ํ์ ํ๊ฒฝ ๋ณ์
| ํ๊ฒฝ๋ณ์ | ์ค๋ช | ์์ |
|---|---|---|
| MLFLOW_S3_ENDPOINT_URL | MinIO ์๋ํฌ์ธํธ URL | http://localhost:9000 |
| MLFLOW_TRACKING_URI | MLflow ํธ๋ํน ์๋ฒ URI | http://localhost:5001 |
| AWS_ACCESS_KEY_ID | AWS/MinIO ์ก์ธ์ค ํค | minio |
| AWS_SECRET_ACCESS_KEY | AWS/MinIO ์ํฌ๋ฆฟ ํค | miniostorage |
| TRITON_URL | Triton gRPC ์๋ํฌ์ธํธ | http://localhost:8001 |
| TRITON_MODEL_REPO | Triton ๋ชจ๋ธ ์ ์ฅ์ URL | s3://bucket/models |
Triton Inference Server ์คํ
docker run --rm -p8000:8000 -p8001:8001 -p8002:8002 \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
nvcr.io/nvidia/tritonserver:24.01-py3 \
tritonserver --model-repository=$TRITON_MODEL_REPO \
--model-control-mode=explicit \
--log-verbose=1
๐ Keynet CLI ๋ช ๋ น์ด
๊ธฐ๋ณธ ๋ช ๋ น์ด
# ํจ์ ๊ฒ์ฆ
keynet validate <python_file> [-r requirements.txt]
# ํจ์ ํ
์คํธ
keynet test <python_file> [--params JSON] [-r requirements.txt]
# ํจ์ ๋ฐฐํฌ
keynet deploy <python_file> --name <model_name> [--server URL]
์ธ์ฆ ๊ด๋ฆฌ
# ์๊ฒฉ ์ฆ๋ช
๋ฑ๋ก
keynet login https://api.example.com
# ํน์ ์๋ฒ์์ ๋ก๊ทธ์์
keynet logout --server api.example.com
# ๋ชจ๋ ์๋ฒ์์ ๋ก๊ทธ์์
keynet logout --all
๊ณ ๊ธ ์ต์
# Python ๋ฒ์ ์ง์
keynet validate my_function.py --python 3.11
# ํ์์์ ์ค์
keynet test my_function.py --import-timeout 60 --execution-timeout 120
# ์์ธ ๋ก๊ทธ ์ถ๋ ฅ
keynet validate my_function.py -v
# ์บ์ ์ ๋ฆฌ
keynet cache clear
๐๏ธ ํ๋ก์ ํธ ๊ตฌ์กฐ
wtu_mlflow_triton_plugin/
โโโ auth/ # ์ธ์ฆ ๋ฐ ์๊ฒฉ ์ฆ๋ช
๊ด๋ฆฌ
โโโ function/ # ํจ์ ๋น๋ ๋ฐ CLI
โ โโโ cli.py # Keynet CLI ๊ตฌํ
โ โโโ client.py # API ํด๋ผ์ด์ธํธ
โ โโโ models.py # ๋ฐ์ดํฐ ๋ชจ๋ธ
โ โโโ validator.py # ํจ์ ๊ฒ์ฆ๊ธฐ
โ โโโ venv_manager.py # ๊ฐ์ํ๊ฒฝ ๊ด๋ฆฌ
โโโ plugin.py # MLflow ํ๋ฌ๊ทธ์ธ
โโโ storage.py # S3/MinIO ์ ์ฅ์ ๊ด๋ฆฌ
โโโ config.py # ์ค์ ๊ด๋ฆฌ
๐ ๋ณด์ ๊ธฐ๋ฅ ์์ธ
์ฝ๋ ๊ฒ์ฆ
- AST ๊ธฐ๋ฐ ๊ตฌ๋ฌธ ๋ถ์
- ํ์ ํจ์ ์๊ทธ๋์ฒ ๊ฒ์ฌ
- ๋ฐ์ฝ๋ ์ดํฐ ๊ฒ์ฆ
์คํ ๊ฒฉ๋ฆฌ
- ๋ ๋ฆฝ๋ ๊ฐ์ํ๊ฒฝ์์ ์คํ
- ์์คํ ๋ฆฌ์์ค ์ ๊ทผ ์ ํ
- ํ์์์ ๊ธฐ๋ฐ ์คํ ์ ์ด
๋ฉ๋ชจ๋ฆฌ ๋ณดํธ
- ์ต๋ 512MB ๋ฉ๋ชจ๋ฆฌ ์ ํ
- ๋ฉ๋ชจ๋ฆฌ ํญํ ๋ฐฉ์ง
- ๋ฆฌ์์ค ๊ณ ๊ฐ ๋ฐฉ์ง
๐ค ๊ธฐ์ฌํ๊ธฐ
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ ๋ผ์ด์ ์ค
MIT License - ์์ธํ ๋ด์ฉ์ LICENSE ํ์ผ์ ์ฐธ์กฐํ์ธ์.
๐ ์ฐธ๊ณ ์๋ฃ
๐ ์ง์
- ์ด์ ํธ๋์ปค: GitHub Issues
- ์ด๋ฉ์ผ: hbjs97@naver.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wtu_mlflow_triton_plugin-0.0.17.tar.gz.
File metadata
- Download URL: wtu_mlflow_triton_plugin-0.0.17.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be6504fac6a61b410682893ad7235c201b434a8c6f7809f2d81f9be2bd8539ea
|
|
| MD5 |
01db0ad249956e261d8cb03fccb582cc
|
|
| BLAKE2b-256 |
5fd1ae809d1427137cde077aaf9a93287ec9be79ea56922cb35dcc46069c8f99
|
File details
Details for the file wtu_mlflow_triton_plugin-0.0.17-py3-none-any.whl.
File metadata
- Download URL: wtu_mlflow_triton_plugin-0.0.17-py3-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9ad01b828a25eddb48a330f789c170b38bf869b45f560390f5d42ce00a02635
|
|
| MD5 |
23ba8988bb7a4cf0ff5b0a45ea5e57b7
|
|
| BLAKE2b-256 |
54511ec244593c7435f9b964337ae9d36c1562e2815dc2970ab22e348f5282f6
|