Installing new python libraries in RZT aiOS

RZT aiOS comes with a rich set of python libraries, such as pandas, numpy, sklearn,tensorflow etc, that are commonly used for machine learning and deep learning tasks. However user can install additional python packages bundled as a wheel file. A user can install a library either as a User Library, which will be available only to that user, or as a System Library in which case it will be available to all users.

This example shows how to install a publicly available library, opencv-python, in RZT aiOS and use it in a custom block code.

1. Install library using SDK api

Use the code snippet given below to install a library package using SDK api

from razor import Technology, LibraryMode

    name = 'yellowbrick',
    technology = Technology.PYTHON,

2. Use the installed library in a custom block

Once the custom library is installed, it can be imported and used in a block's code.

import razor.flow as rf
from razor.api import libraries

class CheckYellowBricksVersion:
    sdk_testbench_lib = libraries(name='yellowbrick').artifact()
    __libs__ = [sdk_testbench_lib]
    def run(self):
        import yellowbrick"Package yellowbricks inported successfully")

Create pipeline and execute it on one of the available engine. All available engines can be listed using the api razor.api.engines(). Replace <engine_name> with the engine name string in below code

check_yellowbrick_version = CheckYellowBricksVersion()
pipeline = rf.Pipeline(name="Test Yellowbricks",targets=[check_yellowbrick_version])
engine = razor.api.engines(<engine_name>)

The pipeline can be executed on jupyter notebook also after restarting the kernel

3. Uninstalling a library using SDK

A library can be uninstalled using SDK api as shown in below code

import razor
yellowbrick_lib = razor.api.libraries(name='yellowbrick')