π DataChain Open-Source Release. Star us on !
There are two builder implementations to create python packages: pip
to create
a directory with python package from model and whl
to create a wheel file with
python package.
To create a build/
directory with pip package run this command:
$ mlem build pip --package_name example_mlem_get_started \
--target build/ --model rf
β³οΈ Loading model from rf.mlem
πΌ Written `example_mlem_get_started` package data to `build`
In this command, we specified that we want to build rf
model with pip
builder and provided two arguments, target
is the directory where the builder
will write all the files and package_name
is the name of our package.
There are more arguments you can use, see object reference
Letβs see what weβve got
$ tree build/
build/
βββ MANIFEST.in
βββ example_mlem_get_started
β βββ __init__.py
β βββ model
β βββ model.mlem
βββ requirements.txt
βββ setup.py
As you can see, the builder generated all the files necessary for a python package. This includes sources, requirements, setup.py, and the model itself.
Now you can distribute and install the package. Its code declares all the same methods our model had, so you can try to use it like this:
import example_mlem_get_started
example_mlem_get_started.predict(df)
from mlem.api import build
build(builder="pip",
model="https://github.com/iterative/example-mlem-get-started/rf",
package_name="my_model_package",
target="./build"
)
# ! pip install ./build
import my_model_package
data = ...
my_model_package.predict(data)
$ mlem build whl \
--package_name my_model_package
--target ./build \
--version 1.0.0 \
--model https://github.com/iterative/example-mlem-get-started/rf
$ pip install ./build/my_model_package-1.0.0-py3-none-any.whl
$ mlem declare builder whl whl_conf \
--package_name my_model_package \
--target ./build \
--author mike0sv \
--email [email protected] \
--version 1.0.0
$ mlem build --load whl_conf \
--model https://github.com/iterative/example-mlem-get-started/rf
$ pip install ./build/my_model_package-1.0.0-py3-none-any.whl