The RZT aiOS platforms provides a functionality that allows the users of the platform to collaborate and share their work across different tenants and customers
You have built a block, which you want to share with users on a different instance of platform. For example a block which performs a statistical operation has been built and needs to be shared among other users across different tenants of the platform.
The SDK provides a set of API’s allowing the users to publish the blocks to marketplace. Once the block is published to marketplace, users could list out the available marketplace blocks and import the required ones using SDK API. The user can then use the blocks to their advantage in their pipelines.
To publish a block to the marketplace, the users have to perform the bellow mentioned steps
STEP 1 - Add the block to the appropriate package
Every project setup in the platform comes with a default directory call __blocks
. This directory consists of two folders
org
- All blocks which the user wants to publish at the org level are presentproject
- All blocks which the user wants to publish at a project levelThe user can organise the blocks under sub directories inside the above mentioned directories. It is advised the the directory name is the same as the bundle name for the block
STEP 2 - Setup the block package
The block package will consist of two elements
__init__.py
- It contains the basic set of configurations needed to publish the block.py
files, which have the block implementationsA sample of the __init__.py
file is as shown bellow
from .helloworld import HelloWorld
from razor.platform.setuptools import block_setup
__metadata__ = block_setup(version="0.0.1")
In the above example, the __init__.py
file first imports all the blocks that needs to be published. Also, the block has to setup for publishing using the blocksetup API. The blocksetup API allows the user to provide an appropriate version and necessary documentation for the block package being published
STEP 3 - Maintain similar block bundle in git repository razor_blocks
Commit the block bundle created under any of the default directories org
or project
in platform to the master branch of git repository razor_blocks
STEP 4 - Publish the blocks to marketplace using the publish API The SDK provides a set of API’s which allows the user to publish the block package to marketplace. The API is illustrated as follows
import razor
from razor.api.core import BlockType
razor.api.marketplace.publish_blocks(bundle='Annotation_Bundle', block_type=BlockType.PL_BLOCKS)
Execution of the above API publishes all the blocks placed in the block bundle under git repository razor_blocks
to marketplace. The SDK checks for any version number changes and publishes the changed blocks to the marketplace
Also, the blocks can be updated using the update parameter in the publish API, an example of which is shown bellow
import razor
from razor.api.core import BlockType
razor.api.marketplace.publish_blocks(bundle='Annotation_Bundle', block_type=BlockType.PL_BLOCKS, overwrite=True)
STEP 5 - List out the availiable marketplace blocks
The list of the availiable marketplace blocks can be obtained using SDK API as follows
import razor
razor.api.marketplace.blocks()
STEP 6 - Import the required blocks from the marketplace
The SDK provides API's to import blocks from the list of marketplace blocks availiable. The API is illustrated as follows
import razor
mktplace_blocks = razor.api.marketplace.blocks(bundlename='Annotation_Bundle', publisher='publisher_name')
razor.api.marketplace.import_blocks(bundle_list=[mktplace_blocks])