mlsteam-model-sdk


Namemlsteam-model-sdk JSON
Version 0.7.0 PyPI version JSON
download
home_pageNone
SummaryMLSteam Model SDK
upload_time2024-04-26 09:57:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT
keywords sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mlsteam-model-sdk
SDK for accessing MLSteam models

## Setup

```bash
pip3 install mlsteam-model-sdk
```

To process encrypted model versions, install the *Themis development package* according to the official [instrunctions](https://docs.cossacklabs.com/themis/languages/python/installation/). Debian/Ubuntu users have a handy installation method:

```bash
# 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 *$*):

```bash
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`:

```bash
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:

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

### Download a model version with SDK

```python
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:

```python
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)
> 1. 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:

```python
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).
> 1. 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)
> 1. 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:

```bash
# 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:

> ```bash
> 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;
1. Validating a manifest file;
1. Creating a model version under development locally;
1. Loading a model version under development locally;
1. Registering a model version (🕒 future work).

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mlsteam-model-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "sdk",
    "author": null,
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# mlsteam-model-sdk\nSDK for accessing MLSteam models\n\n## Setup\n\n```bash\npip3 install mlsteam-model-sdk\n```\n\nTo process encrypted model versions, install the *Themis development package* according to the official [instrunctions](https://docs.cossacklabs.com/themis/languages/python/installation/). Debian/Ubuntu users have a handy installation method:\n\n```bash\n# for users that already have administrator privileges\nmlsteam-model-cli install-themisdev\n\n# for those that need privilege lifting\nsudo mlsteam-model-cli install-themisdev\n```\n\n## Usage\n\n### Initilize SDK\n\nSDK needs to be initialized if you have not done so (replace the fields started with *$*):\n\n```bash\nmlsteam-model-cli init \\\n    --default_project_type=name \\\n    --default_project_val=$PROJECT_OWNER/$PROJECT_NAME\n```\n\n> By default, the settings will be at `$HOME/.mlsteam-model-sdk/cfg.ini`.\n\nIf the program is running out of an MLSteam system, you may also need to setup *api_token*\nwith this command instead, or by editing the *api_token* field in `cfg.ini`:\n\n```bash\nmlsteam-model-cli init \\\n    --api_token=$YOUR_API_TOKEN \\\n    --default_project_type=name \\\n    --default_project_val=$PROJECT_OWNER/$PROJECT_NAME\n```\n\nThis checks whether SDK has been initialized:\n\n```console\n$ mlsteam-model-cli check\n[v] SDK has been initialized.\nConfiguration file: /home/ubuntu/.mlsteam-model-sdk/cfg.ini\n```\n\n### Download a model version with SDK\n\n```python\nfrom mlsteam_model_sdk.sdk.model import Model\n\nsdk_model = Model()\nsdk_model.download_model_version(model_name='model_name',\n                                 version_name='version_name')\n```\n\n> 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.\n\n> By default, the model version will be downloaded at `$HOME/.mlsteam-model-sdk/models/download/`.\n\nThis loads a model version and makes prediction:\n\n```python\nmv = sdk_model.load_model_version(model_name='model_name',\n                                  version_name='version_name')\noutputs = mv.predict(inputs)\n```\n\n### Import a model version with SDK\n\nThere is an alternative way (2-stage model deployment) to import a model version without connecting to an MLSteam system.\nRather than downloading from MLSteam directory, it involves (1) getting the related file(s) from MLSteam and then\n(2) importing the model version from the file(s). This alternative way adds complexity of managing the model file(s) but\nis suitable for the situation where there is no network connection to the MLSteam system.\n\n> This example assumes the following files are locally available:\n>\n> 1. model version package (required)\n> 1. package encryption key (required only for encrypted packages)\n\n> You will need administrator privileges to import an encrypted model version, as mentioned in the previous example.\n\nTo import a package:\n\n```python\nfrom mlsteam_model_sdk.sdk.model import Model\n\nsdk_model = Model(offline=True)\nsdk_model.import_model_version(mv_package_file='path/to/mv/package/file',\n                               enckey_file='path/to/enckey/file')\n# for non-encrypted package\n# sdk_model.import_model_version(mv_package_file='path/to/mv/package/file')\n```\n\n> 1. We set `offline=True` to have SDK operate in offline mode (without connecting to MLSteam).\n> 1. 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.\n\n### Import a model version with CLI\n\n> This example assumes the following files are locally available:\n>\n> 1. model version package (required)\n> 1. package encryption key (required only for encrypted packages)\n\n> You will need administrator privileges to import an encrypted model version, as mentioned in the previous example.\n\nTo import a package:\n\n```bash\n# for non-encrypted packages\nmlsteam-model-cli mv import-local -f $PACKAGE_FILE_PATH\n\n# for encrypted packages\nmlsteam-model-cli mv import-local -f $PACKAGE_FILE_PATH -k $ENCKEY_FILE_PATH\n```\n\n> 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.\n\n> If the operation is successful, you will find the imported pakage in local model registry:\n\n> ```bash\n> mlsteam-model-cli mv list-local\n> ```\n\n> ```\n>    muuid     model_name       vuuid        version_name     puuid     packaged   encrypted      download_time\n>  ================================================================================================================\n>  __local__   ...          local-........   ...            __local__   1          ...            .....\n> ```\n\n## Model Development\n\nThe SDK is equipped with Model Development Kit (MDK) to support the following activities:\n\n1. Generating a skeleton of manifest file;\n1. Validating a manifest file;\n1. Creating a model version under development locally;\n1. Loading a model version under development locally;\n1. Registering a model version (\ud83d\udd52 future work).\n\nMore information could be found in *Model Developer's Guide* in SDK documentation.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MLSteam Model SDK",
    "version": "0.7.0",
    "project_urls": {
        "Homepage": "https://mlsteam-model-sdk-doc.readthedocs.io/"
    },
    "split_keywords": [
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c97aec6c561a906ab1b610b17d00dcaa5d1fce11b523a504056e4f0c8218a99d",
                "md5": "96068f0322a0408becd61560fdc25d20",
                "sha256": "3d17614d666118193b583ee0194466b686a861018af9fe68e10d53b3d1089925"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "96068f0322a0408becd61560fdc25d20",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.6",
            "size": 1904774,
            "upload_time": "2024-04-26T09:57:04",
            "upload_time_iso_8601": "2024-04-26T09:57:04.772433Z",
            "url": "https://files.pythonhosted.org/packages/c9/7a/ec6c561a906ab1b610b17d00dcaa5d1fce11b523a504056e4f0c8218a99d/mlsteam_model_sdk-0.7.0-cp310-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b2002bb2b7e7c29e6589fb4fe0ddedf5b212deb5d0de910a23363fa189ca8be",
                "md5": "c7213b5be1a76efbacfe4ef0a9690a11",
                "sha256": "3b14cc8b9790f8935c4b12760ba30c7eb06b708cd61e94cc089cf3df4362f153"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c7213b5be1a76efbacfe4ef0a9690a11",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 2143832,
            "upload_time": "2024-04-26T09:57:28",
            "upload_time_iso_8601": "2024-04-26T09:57:28.299556Z",
            "url": "https://files.pythonhosted.org/packages/6b/20/02bb2b7e7c29e6589fb4fe0ddedf5b212deb5d0de910a23363fa189ca8be/mlsteam_model_sdk-0.7.0-cp311-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "61189b341d45f93b0c8573a00f3361956bf20225bea650b1508173fff6e75963",
                "md5": "85c5b5136446024b9ab56a20f06d524f",
                "sha256": "3a4ee02c85c229cdc6bfe5172f5db22fc0d028829664628b18f5476f6335663e"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp312-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "85c5b5136446024b9ab56a20f06d524f",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.6",
            "size": 2171086,
            "upload_time": "2024-04-26T09:58:04",
            "upload_time_iso_8601": "2024-04-26T09:58:04.574822Z",
            "url": "https://files.pythonhosted.org/packages/61/18/9b341d45f93b0c8573a00f3361956bf20225bea650b1508173fff6e75963/mlsteam_model_sdk-0.7.0-cp312-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "636af51b448f0ea84a2fbea594f6843a106e75a50419510af18f476f95a09b45",
                "md5": "30372d8cc749e5a4075e7c48a5405f2c",
                "sha256": "48f267c7327f7c62449dacd065d10a816d5c3829d3bd72ec87531eceac879339"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp36-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "30372d8cc749e5a4075e7c48a5405f2c",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": ">=3.6",
            "size": 1541226,
            "upload_time": "2024-04-26T09:58:24",
            "upload_time_iso_8601": "2024-04-26T09:58:24.798977Z",
            "url": "https://files.pythonhosted.org/packages/63/6a/f51b448f0ea84a2fbea594f6843a106e75a50419510af18f476f95a09b45/mlsteam_model_sdk-0.7.0-cp36-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab58a7159e9919a260ad7d6753edb3d99d1be9c1a5fb0f9c32a76c0a7faa3388",
                "md5": "8ebcea15369d412049d618bcbf5b9fcb",
                "sha256": "ffe835400b5dea46e5b4db70d6cbcfeb3d78f4ed6ef47142923be62103a01dbf"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "8ebcea15369d412049d618bcbf5b9fcb",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.6",
            "size": 1728739,
            "upload_time": "2024-04-26T09:58:43",
            "upload_time_iso_8601": "2024-04-26T09:58:43.330651Z",
            "url": "https://files.pythonhosted.org/packages/ab/58/a7159e9919a260ad7d6753edb3d99d1be9c1a5fb0f9c32a76c0a7faa3388/mlsteam_model_sdk-0.7.0-cp37-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59147a2bbb56fdc9aa3cc2eb0940b226af16f68ea02e08f46d353b789374ff91",
                "md5": "cdae984f5d316e4b3e880f560e01e4ea",
                "sha256": "1d1383017a450b96933ac068c977e674dbfef79195dc28f5832bd4da35623f54"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "cdae984f5d316e4b3e880f560e01e4ea",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.6",
            "size": 1972882,
            "upload_time": "2024-04-26T09:59:14",
            "upload_time_iso_8601": "2024-04-26T09:59:14.308911Z",
            "url": "https://files.pythonhosted.org/packages/59/14/7a2bbb56fdc9aa3cc2eb0940b226af16f68ea02e08f46d353b789374ff91/mlsteam_model_sdk-0.7.0-cp38-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a2e00ef08b0a041b7497b6ce9aeb58198bdaf0c31e19e3202cbbb5a300fb3cb4",
                "md5": "c0cc3c1bfee0440271e57f8d9929a634",
                "sha256": "2ac87c972ab0a490277c3bf7628d4b010cbadcf10438cb841394d479706d3f07"
            },
            "downloads": -1,
            "filename": "mlsteam_model_sdk-0.7.0-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c0cc3c1bfee0440271e57f8d9929a634",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.6",
            "size": 1904117,
            "upload_time": "2024-04-26T09:59:36",
            "upload_time_iso_8601": "2024-04-26T09:59:36.027279Z",
            "url": "https://files.pythonhosted.org/packages/a2/e0/0ef08b0a041b7497b6ce9aeb58198bdaf0c31e19e3202cbbb5a300fb3cb4/mlsteam_model_sdk-0.7.0-cp39-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 09:57:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mlsteam-model-sdk"
}
        
Elapsed time: 0.25250s