MLNGI Python SDK - ML 실험 추적 및 모델 관리
Project description
MLNGI Python SDK
ML 실험 추적 및 모델 관리를 위한 Python SDK입니다.
설치
cd sdk
pip install -e .
빠른 시작
1. 환경 변수 설정
export MLNGI_TRACKING_URI=http://localhost:8000/api/v1
export MLNGI_API_KEY=mlngi_xxxxxxxx # 또는 MLNGI_TOKEN
2. 실험 추적
import mlngi
# 서버 연결
mlngi.set_tracking_uri("http://localhost:8000/api/v1")
# 실험 설정 (없으면 자동 생성)
mlngi.set_experiment("image-classification")
# Run 실행
with mlngi.start_run(name="resnet50-v1"):
# 파라미터 기록
mlngi.log_param("learning_rate", 0.001)
mlngi.log_param("batch_size", 32)
mlngi.log_param("epochs", 100)
# 또는 한 번에
mlngi.log_params({
"optimizer": "adam",
"model": "resnet50",
})
# 학습 루프
for epoch in range(100):
loss = 1.0 / (epoch + 1) # 예시
accuracy = 1 - loss
# 메트릭 기록
mlngi.log_metric("loss", loss, step=epoch)
mlngi.log_metric("accuracy", accuracy, step=epoch)
# 또는 한 번에
mlngi.log_metrics({"loss": loss, "accuracy": accuracy}, step=epoch)
# 태그 설정
mlngi.set_tag("model_type", "resnet50")
mlngi.set_tags({"framework": "pytorch", "dataset": "imagenet"})
# with 블록을 빠져나오면 Run이 자동으로 완료됩니다.
3. 저수준 클라이언트 사용
from mlngi import MLNGIClient
client = MLNGIClient(
"http://localhost:8000/api/v1",
api_key="mlngi_xxxxxxxx"
)
# 프로젝트 목록
projects = client.list_projects()
# 모델 등록
model = client.create_model("my-model", project_id="...")
version = client.create_model_version(model["id"], run_id="...")
client.set_model_alias(model["id"], "champion", version["version"])
API 참조
고수준 API (mlngi.*)
| 함수 | 설명 |
|---|---|
set_tracking_uri(uri) |
서버 URI 설정 |
set_experiment(name, project_id?) |
실험 설정 (없으면 자동 생성) |
start_run(name?, tags?) |
Run 시작 (with 문 사용) |
end_run() |
활성 Run 종료 |
log_param(key, value) |
파라미터 기록 |
log_params(params_dict) |
여러 파라미터 한 번에 기록 |
log_metric(key, value, step?) |
메트릭 기록 |
log_metrics(metrics_dict, step?) |
여러 메트릭 한 번에 기록 |
set_tag(key, value) |
태그 설정 |
set_tags(tags_dict) |
여러 태그 설정 |
active_run() |
현재 활성 Run 정보 |
get_run(run_id) |
Run 정보 조회 |
저수준 API (MLNGIClient)
| 메서드 | 설명 |
|---|---|
list_projects() |
프로젝트 목록 |
create_project(name, description) |
프로젝트 생성 |
list_experiments(project_id) |
실험 목록 |
create_experiment(project_id, name) |
실험 생성 |
create_run(experiment_id, name, tags) |
Run 생성 |
get_run(run_id) |
Run 조회 |
stop_run(run_id) |
Run 종료 |
log_metric(run_id, key, value, step) |
메트릭 기록 |
log_param(run_id, key, value) |
파라미터 기록 |
set_tags(run_id, tags) |
태그 설정 |
create_model(name, project_id) |
모델 등록 |
create_model_version(model_id, run_id) |
모델 버전 생성 |
set_model_alias(model_id, alias, version) |
모델 별칭 설정 |
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
mlngi-0.1.0.tar.gz
(7.7 kB
view details)
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
mlngi-0.1.0-py3-none-any.whl
(7.9 kB
view details)
File details
Details for the file mlngi-0.1.0.tar.gz.
File metadata
- Download URL: mlngi-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5a09e67f3b8f043d9d14344dbd9a1080610fcdd7ae95cf9a76ec6425fc9bcfe
|
|
| MD5 |
a00068d6a6cc8a152f65cc7f7e937c4c
|
|
| BLAKE2b-256 |
caf25ecab82f6e8a5d5a34a56b453f0d40567c5954571d2d5412c3a79d2148b6
|
File details
Details for the file mlngi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mlngi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
131dfb8492aad9edd1e694e69861ba06a21c42341fad21f3bbcf6fd336389eb7
|
|
| MD5 |
a77c5d33cfeb55879ae78c9eee45535b
|
|
| BLAKE2b-256 |
cd2feb400526ea3603fbeedda49789686d0be8f4a497cdd432c4a1998a1ef9e5
|