Module sktmls.model_registry
Classes
class ModelRegistry (env: MLSENV = None, runtime_env: MLSRuntimeENV = None)-
모델 레지스트리 클래스입니다.
Args
- env: (
MLSENV) 접근할 MLS 환경 (MLSENV.DEV|MLSENV.STG|MLSENV.PRD) (기본값:MLSENV.STG) - runtime_env: (
MLSRuntimeENV) 클라이언트가 실행되는 환경 (MLSRuntimeENV.YE|MLSRuntimeENV.EDD|MLSRuntimeENV.LOCAL) (기본값:MLSRuntimeENV.LOCAL)
아래의 환경 변수가 정의된 경우 해당 파라미터를 생략 가능합니다.
- $MLS_ENV: env
- $AWS_ENV: env
- $MLS_RUNTIME_ENV: runtime_env
Returns
Example
model_registry = ModelRegistry(env=MLSENV.STG, runtime_env=MLSRuntimeENV.LOCAL)Methods
def list_models(self) ‑> List[str]-
MLS 모델 레지스트리에 등록된 모든 모델 이름을 리스트로 가져옵니다.
Returns
list(str)
Example
model_registry = ModelRegistry(env=MLSENV.STG) model_names = model_registry.list_models() def list_versions(self, model_name: str) ‑> List[str]-
MLS 모델 레지스트리에 등록된 모델의 모든 버전을 리스트로 가져옵니다.
Args
- model_name: (str) 모델 이름
Returns
list(str)
Example
model_registry = ModelRegistry(env=MLSENV.STG) model_versions = model_registry.list_versions("hello_model") def load(self, model_name: str, model_version: str) ‑> MLSModel-
MLS 모델 레지스트리로부터 모델 객체를 가져옵니다.
Args
- model_name: (str) 모델 이름
- model_version: (str) 모델 버전
Returns
Example
model_registry = ModelRegistry(env=MLSENV.STG) hello_model_v1 = model_registry.load(model_name="hello_model", model_version="v1") results = hello_model_v1.predict([1, 2, 3]) def save(self, mls_model: MLSModel, force: bool = False, custom_predict_async_path: str = None)-
모델 바이너리(model.joblib)와 정보(model.json)를 MLS 모델 레지스트리에 등록합니다.
MLSModel.save()와 동일하게 동작합니다.Args
- mls_model: (
MLSModel) 모델 객체 - force: (optional) (bool) 이미 모델 레지스트리에 등록된 경우 덮어 쓸 것인지 여부 (기본값:
False) - custom_predict_async_path: (optional) (str) predict_async.py 파일 경로 (기본값: None)
Example
model_registry = ModelRegistry(env=MLSENV.STG) model_registry.save(gbm_model) - mls_model: (
def save_and_deploy(self, mls_model: MLSModel, ml_model_client: MLModelClient, force: bool = False, custom_predict_async_path: str = None) ‑> ManualModel-
모델 바이너리(model.joblib)와 정보(model.json)를 MLS 모델 레지스트리에 등록하고, 해당 바이너리를 참조하는 MLS의 일반 모델(ManualModel)을 생성(deploy)합니다.
일반 모델은 deploy 후 버킷에 연결되어 정상 동작하기 까지 약 한 시간이 소요됩니다.
Args
- mls_model: (
MLSModel) 모델 객체 - ml_model_client: (
MLModelClient) 모델 클라이언트 - force: (bool) 이미 모델 레지스트리에 등록된 경우 덮어 쓸 것인지 여부 (기본값:
False) - custom_predict_async_path: (optional) (str) predict_async.py 파일 경로 (기본값: None)
Example
ml_model_client = MLModelClient(env=MLSENV.STG, runtime_env=MLSRuntimeENV.YE, username="mls_account", password="mls_password") model_registry = ModelRegistry(env=MLSENV.STG) model_registry.save_and_deploy(gbm_model, ml_model_client) - mls_model: (
- env: (
class ModelRegistryError (msg)-
Common base class for all non-exit exceptions.
Ancestors
- builtins.Exception
- builtins.BaseException