mljet.contrib#

Subpackages#

Submodules#

mljet.contrib.analyzer module#

Models analyzed and method’s extractor.

mljet.contrib.analyzer.extract_methods_names(model)[source]#

Get methods from model.

Return type:

List[str]

mljet.contrib.analyzer.get_associated_methods_wrappers(model)[source]#

Get methods names and associated wrappers.

Return type:

Dict[str, Callable]

mljet.contrib.entrypoint module#

Docker builder module.

mljet.contrib.entrypoint.cook(*, model, strategy=Strategy.DOCKER, backend=None, tag=None, base_image=None, container_name=None, need_run=True, port=None, scan_path=None, n_workers=1, silent=True, verbose=False, remove_project_dir=False, ignore_mypy=False, additional_requirements_files=None)[source]#

Cook web-service.

Parameters:
  • model – model to deploy

  • strategy (Union[Strategy, str]) – strategy to use

  • backend (Union[str, Path, None]) – backend to use

  • tag (Optional[str]) – tag for docker image

  • base_image (Optional[str]) – base image for docker image

  • container_name (Optional[str]) – container name

  • need_run (bool) – run service after build or not

  • port (Optional[int]) – port to use

  • scan_path (Union[str, Path, None]) – path to scan for requirements

  • n_workers (int) – number of workers

  • silent (bool) – silent mode

  • verbose (bool) – verbose mode

  • remove_project_dir (bool) – remove project directory after build

  • ignore_mypy (bool) – ignore mypy errors

  • additional_requirements_files (Optional[Sequence[Union[str, Path]]]) – additional requirements files

Return type:

Dict[str, Any]

Returns:

Result of build, maybe bool or container name (if docker strategy)

mljet.contrib.local module#

mljet.contrib.project_builder module#

Project builder.

mljet.contrib.project_builder.build_backend(path, filename, template_path, models, imports=None, ignore_mypy=False)[source]#
Return type:

Path

mljet.contrib.project_builder.build_requirements_txt(project_path, backend_path, scan_path, additional_requirements_files=None)[source]#

Builds requirements.txt

Return type:

Path

mljet.contrib.project_builder.copy_backend_dockerfile(project_path, backend_path)[source]#

Copies backend Dockerfile to project_path.

Return type:

Path

mljet.contrib.project_builder.dumps_models(path, models, models_names, serializer=<module 'pickle' from '/home/docs/.pyenv/versions/3.8.6/lib/python3.8/pickle.py'>, ext='pkl')[source]#

Dumps models to models_path.

Return type:

Path

mljet.contrib.project_builder.full_build(project_path, backend_path, template_path, scan_path, models, models_names, filename='server.py', imports=None, serializer=<module 'pickle' from '/home/docs/.pyenv/versions/3.8.6/lib/python3.8/pickle.py'>, ext='pkl', ignore_mypy=False, additional_requirements_files=None)[source]#

Builds project.

Return type:

Result[Path, Exception]

mljet.contrib.project_builder.init_project_directory(path, force=False)[source]#

Initializes project directory.

Return type:

Path

mljet.contrib.project_builder.managed_write(filepath, writer, mode='w')[source]#

Writes obj to stream using writer.

Return type:

Result[TypeVar(_ValueType, covariant=True), Exception]

mljet.contrib.supported module#

Supported models types, strategies.

class mljet.contrib.supported.ModelType(value)[source]#

Bases: str, Enum

Model type.

CATBOOST = 'catboost'#
LAMA = 'lightautoml'#
LGBM = 'lightgbm'#
SKLEARN = 'sklearn'#
XGBOOST = 'xgboost'#
classmethod from_model(model)[source]#

Get model type from model.

Parameters:

model (Estimator) – model to get type from

Returns:

Model type.

class mljet.contrib.supported.Strategy(value)[source]#

Bases: str, Enum

An enumeration.

DOCKER = 'DOCKER'#
LOCAL = 'LOCAL'#

mljet.contrib.validator module#

Module, that contains validators for mljet.

mljet.contrib.validator.validate_ret_backend(backend)[source]#

Validates predefined backend name or path to custom backend.

Return type:

Path

mljet.contrib.validator.validate_ret_container_name(name)[source]#

Validates container name and returns it if it is valid.

Return type:

str

mljet.contrib.validator.validate_ret_model(model)[source]#

Validates model and returns it type if it is valid.

Return type:

ModelType

mljet.contrib.validator.validate_ret_port(port)[source]#

Validates port and returns it if it is valid.

Return type:

int

mljet.contrib.validator.validate_ret_strategy(strategy)[source]#

Validates strategy and returns it if it is valid.

Return type:

Strategy

Module contents#

Module for docker related functions.