Skip to main content

Torch Serve Mlflow Deployment

Project description

# mlflow-torchserve

A plugin that integrates [TorchServe](https://github.com/pytorch/serve) with MLflow pipeline. mlflow_torchserve enables you to use mlflow to deploy the models built and trained in mlflow pipeline into TorchServe without any extra effort from the user. This plugin provides few command line APIs, which is also accessible through mlflow’s python package, to make the deployment process seamless.

## Installation For installing and activating the plugin, you only need to install this package which is available in pypi and can be installed with

`bash pip install mlflow-torchserve ` ## What does it do Installing this package uses python’s entrypoint mechanism to register the plugin into MLflow’s plugin registry. This registry will be invoked each time you launch MLflow script or command line argument.

### Create deployment Deploy the model to TorchServe. The create command line argument and create_deployment python APIs does the deployment of a model built with MLflow to TorchServe.

##### CLI `shell script mlflow deployments create -t torchserve -m <model uri> --name DEPLOYMENT_NAME -C 'MODEL_FILE=<model file path>' -C 'HANDLER=<handler file path>' `

##### Python API `python from mlflow.deployments import get_deploy_client target_uri = 'torchserve' plugin = get_deploy_client(target_uri) plugin.create_deployment(name=<deployment name>, model_uri=<model uri>, config={"MODEL_FILE": <model file path>, "HANDLER": <handler file path>}) `

### Update deployment Update API can be used to update an already deployed model. This setup is useful if you want to increase the number of workers or set a model as default version. TorchServe will make sure the user experience is seamless while changing the model in a live environment.

##### CLI `shell script mlflow deployments update -t torchserve --name <deployment name> -C "min-worker=<number of workers>" `

##### Python API `python plugin.update_deployment(name=<deployment name>, config={'min-worker': <number of workers>}) `

### Delete deployment Delete an existing deployment. Error will be thrown if the model is not already deployed

##### CLI `shell script mlflow deployments delete -t torchserve --name <deployment name / version number> `

##### Python API `python plugin.delete_deployment(name=<deployment name / version number>) `

### List all deployments List the names of all the deploymented models. This name can then be used in other APIs or can be used in the get deployment API to get more details about a particular deployment.

##### CLI `shell script mlflow deployments list -t torchserve `

##### Python API `python plugin.list_deployments() `

### Get deployment details Get API fetches the details of the deployed model. By default, Get API fetches all the versions of the deployed model

##### CLI `shell script mlflow deployments get -t torchserve --name <deployment name> `

##### Python API `python plugin.get_deployment(name=<deployment name>) `

### Run Prediction on deployed model Predict API enables to run prediction on the deployed model.

CLI takes json file path as input. However, input to the python plugin can be one among the three types DataFrame, Tensor or Json String.

##### CLI `shell script mlflow deployments predict -t torchserve --name <deployment name> --input-path <input file path> --output-path <output file path> `

output-path is an optional parameter. Without output path parameter result will printed in console.

##### Python API `python plugin.predict(name=<deployment name>, df=<prediction input>) `

### Plugin help Run the following command to get the plugin help string.

##### CLI `shell script mlflow deployments help -t torchserve `

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlflow-torchserve-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

mlflow_torchserve-0.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file mlflow-torchserve-0.1.0.tar.gz.

File metadata

  • Download URL: mlflow-torchserve-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for mlflow-torchserve-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0add39e5e620aec12e671b38d28ca474dd7720526e29b621c1e34be22ed32794
MD5 9f1a5e52565662b1e4d6439d9aa61ff9
BLAKE2b-256 cd3c768ccc03595564c39698d7233f90fe796c41842bfe8049b4e8e121577e50

See more details on using hashes here.

File details

Details for the file mlflow_torchserve-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mlflow_torchserve-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for mlflow_torchserve-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2c20873f7c3a547b472c6f2d8e9631a969bc371b847bfad8d55aadd1967cd73
MD5 379c4dbc7b4cd73b707da50ca54b0119
BLAKE2b-256 bab3adb7366b07bdb8e154369543168279fd3dff1548204f5e74776791ad8ae1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page