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.
Use the code snippet given below to install a library package using SDK api
from razor import Technology, LibraryMode razor.api.libraries.install( name = 'yellowbrick', version='1.1', technology = Technology.PYTHON, mode=LibraryMode.PIP )
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 @rf.block class CheckYellowBricksVersion: sdk_testbench_lib = libraries(name='yellowbrick').artifact() __libs__ = [sdk_testbench_lib] def run(self): import yellowbrick self.logger.info("Package yellowbricks inported successfully")
Create pipeline and execute it on one of the available engine. All available engines can be listed using the api
<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>) engine.execute(pipeline)
The pipeline can be executed on jupyter notebook also after restarting the kernel
A library can be uninstalled using SDK api as shown in below code
import razor yellowbrick_lib = razor.api.libraries(name='yellowbrick') yellowbrick_lib.uninstall()