Skip to main content

MLSteam Model SDK

Project description

mlsteam-model-sdk

SDK for accessing MLSteam models

Setup

pip3 install mlsteam-model-sdk

To process encrypted model versions, install the Themis development package according to the official instrunctions. Debian/Ubuntu users have a handy installation method:

# for users that already have administrator privileges
mlsteam-model-cli install-themisdev

# for those that need privilege lifting
sudo mlsteam-model-cli install-themisdev

Usage

Initilize SDK

SDK needs to be initialized if you have not done so (replace the fields started with $):

mlsteam-model-cli init \
    --default_project_type=name \
    --default_project_val=$PROJECT_OWNER/$PROJECT_NAME

By default, the settings will be at $HOME/.mlsteam-model-sdk/cfg.ini.

If the program is running out of an MLSteam system, you may also need to setup api_token with this command instead, or by editing the api_token field in cfg.ini:

mlsteam-model-cli init \
    --api_token=$YOUR_API_TOKEN \
    --default_project_type=name \
    --default_project_val=$PROJECT_OWNER/$PROJECT_NAME

This checks whether SDK has been initialized:

$ mlsteam-model-cli check
[v] SDK has been initialized.
Configuration file: /home/ubuntu/.mlsteam-model-sdk/cfg.ini

Download a model version with SDK

from mlsteam_model_sdk.sdk.model import Model

sdk_model = Model()
sdk_model.download_model_version(model_name='model_name',
                                 version_name='version_name')

You will need administrator privileges to handle encrypted model versions. For this case, either run the Python program with sudo, or enter your password in a sudo prompt during program execution.

By default, the model version will be downloaded at $HOME/.mlsteam-model-sdk/models/download/.

This loads a model version and makes prediction:

mv = sdk_model.load_model_version(model_name='model_name',
                                  version_name='version_name')
outputs = mv.predict(inputs)

Import a model version with SDK

There is an alternative way (2-stage model deployment) to import a model version without connecting to an MLSteam system. Rather than downloading from MLSteam directory, it involves (1) getting the related file(s) from MLSteam and then (2) importing the model version from the file(s). This alternative way adds complexity of managing the model file(s) but is suitable for the situation where there is no network connection to the MLSteam system.

This example assumes the following files are locally available:

  1. model version package (required)
  2. package encryption key (required only for encrypted packages)

You will need administrator privileges to import an encrypted model version, as mentioned in the previous example.

To import a package:

from mlsteam_model_sdk.sdk.model import Model

sdk_model = Model(offline=True)
sdk_model.import_model_version(mv_package_file='path/to/mv/package/file',
                               enckey_file='path/to/enckey/file')
# for non-encrypted package
# sdk_model.import_model_version(mv_package_file='path/to/mv/package/file')
  1. We set offline=True to have SDK operate in offline mode (without connecting to MLSteam).
  2. By default, the model and version names to register are read from the package manifest. You may customize these settings with the model_name and version_name parameters.

Import a model version with CLI

This example assumes the following files are locally available:

  1. model version package (required)
  2. package encryption key (required only for encrypted packages)

You will need administrator privileges to import an encrypted model version, as mentioned in the previous example.

To import a package:

# for non-encrypted packages
mlsteam-model-cli mv import-local -f $PACKAGE_FILE_PATH

# for encrypted packages
mlsteam-model-cli mv import-local -f $PACKAGE_FILE_PATH -k $ENCKEY_FILE_PATH

By default, the model and version names to register are read from the package manifest. You may customize these settings with the --model_name and --version_name options.

If the operation is successful, you will find the imported pakage in local model registry:

mlsteam-model-cli mv list-local
   muuid     model_name       vuuid        version_name     puuid     packaged   encrypted      download_time
 ================================================================================================================
 __local__   ...          local-........   ...            __local__   1          ...            .....

Model Development

The SDK is equipped with Model Development Kit (MDK) to support the following activities:

  1. Generating a skeleton of manifest file;
  2. Validating a manifest file;
  3. Creating a model version under development locally;
  4. Loading a model version under development locally;
  5. Registering a model version (🕒 future work).

More information could be found in Model Developer's Guide in SDK documentation.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mlsteam_model_sdk-0.8.0-cp312-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

mlsteam_model_sdk-0.8.0-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

mlsteam_model_sdk-0.8.0-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

mlsteam_model_sdk-0.8.0-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

mlsteam_model_sdk-0.8.0-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

mlsteam_model_sdk-0.8.0-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.7manylinux: glibc 2.17+ x86-64

mlsteam_model_sdk-0.8.0-cp36-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6manylinux: glibc 2.17+ x86-64

File details

Details for the file mlsteam_model_sdk-0.8.0-cp312-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp312-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 678644afe9e7bba92bffbccef06e700109234c3b21cce4b993bb44b717040600
MD5 9fc90fa520eaf84e8490bc06a89300a8
BLAKE2b-256 676c5c442ab8a13dcae22a14a0455aa2c544dcd92e6f02c66b6b9beaf1c04f9b

See more details on using hashes here.

File details

Details for the file mlsteam_model_sdk-0.8.0-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aaa0366b99b83ec77c67ff791390818b29a3c2f15898c41a4c0cb1dc66bce822
MD5 990351679f74b0d0f6d7dddb33d22f1a
BLAKE2b-256 6e782a02be0db1a80497b0614f9a6112d8abac2214ded312886277b3785ad9c1

See more details on using hashes here.

File details

Details for the file mlsteam_model_sdk-0.8.0-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4fc08b24dbc6315d7f4a5acf4484457d8255514ed7b2cf4ded98a78670b62ae2
MD5 c566e58e0c2c0dbf2d16abb47b2eec5d
BLAKE2b-256 66236e1814d856f64e181292b23823bd96af2dac9918bff384f3462c71028e84

See more details on using hashes here.

File details

Details for the file mlsteam_model_sdk-0.8.0-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c47f17825ee53a25ec380d0001c5d3d57cf861f286a711f8cbab669057b3c6f3
MD5 a0aad202bb17090d3fedb46cca187eb5
BLAKE2b-256 937ba32f738abbd88e74b66f00f85e76e9992043132e547cc03725acad41b6d1

See more details on using hashes here.

File details

Details for the file mlsteam_model_sdk-0.8.0-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ec64f34c4613f198dbecfef54e3a9869b2759c5a61d46dc4cf11830da84025d
MD5 385e415d861967870b0213cf9ff88802
BLAKE2b-256 0a58b4b2d6c217fb20f4113c35257fbe05b1276ea29b0e5dade0ed7f6f6c95e1

See more details on using hashes here.

File details

Details for the file mlsteam_model_sdk-0.8.0-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5933fe1ad8a8cfecf41ecf8e9d16453fa7e7bbc80dfeb95c593d5494bf776851
MD5 83088e619d8c9c058df68553e4661341
BLAKE2b-256 6c25c4eb29acee257259f65a78ce5d5e21dbc806a618ae2802b2d89cd576e5d0

See more details on using hashes here.

File details

Details for the file mlsteam_model_sdk-0.8.0-cp36-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlsteam_model_sdk-0.8.0-cp36-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f60af1a1d968bf136ee72a29ade6db9a8f03073ef117a10f52a14568afd72f10
MD5 05750b6abbe90c1ae9ae7e3125029897
BLAKE2b-256 7ab3811abce4626aae8b4a55762bf05ef7d5816bd0b4f6a6b3d28fcadb1cbf6c

See more details on using hashes here.

Supported by

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