/

Your First Custom Block

Walking you through uploading your first custom block.


If you want to use your own processing methods or data sources on the UP42 platform, you can create custom blocks that can be seamlessly integrated into UP42 workflows. The block will appear in the Custom blocks section of your UP42 console. It can then be used like any other data or processing block.

While developing custom blocks in Python, the UP42 block utilities package can help. This package contains base classes for data and processing blocks, and several facilities to handle testing.

This section will give you step-by-step instructions on how to upload a custom block to UP42, using the sharpening filter example block from our public UP42 github profile.

The UP42 custom block console menu
The UP42 custom block console menu

Requirements

This example requires the Mac OS X or Linux bash, git and Docker Engine. The example repository code uses Python 3.7.

Download the example block

Clone the example block using git and navigate to the folder that contains the Dockerfile and UP42Manifest:

git clone https://github.com/up42/sharpening.git
cd sharpening/blocks/sharpening

We will skip changing the example code here and directly push the block to the UP42 platform. See section Developing a custom processing block for more advanced instructions on custom block development.

Authenticate with the UP42 Docker registry

First login to the UP42 docker registry. Replace <USERNAME> with the email address you login with on the UP42 website. Make sure Docker is running on your computer. When asked for your password, enter your UP42 account password.

docker login -u=<USERNAME> http://registry.up42.com

# Example:
docker login -u=[email protected] http://registry.up42.com

Build the block container

Then build the block container, replace <User-ID> with your UP42 User-ID.

To get your UP42 User-ID, go to the the UP42 custom-blocks menu and click on “PUSH A BLOCK TO THE PLATFORM”. At the bottom of the popup, copy your user ID from the command “Push the image to the UP42 Docker registry” (e.g. 6760d08e-54e3-4f1c-b22e-6ba605ec7592).

docker build . -t registry.up42.com/<USER-ID>/sharpening:1.0 --build-arg manifest="$(cat UP42Manifest.json)"

# Example:
docker build . -t registry.up42.com/6760d08e-54e3-4f1c-b22e-6ba605ec7592/sharpening:1.0 --build-arg manifest="$(cat UP42Manifest.json)"

Push the custom block to UP42

Now you can push the image to the UP42 docker registry. Replace <User-ID> with your UP42 User-ID.

docker push registry.up42.com/<USER-ID>/sharpening:1.0

# Example:
docker push registry.up42.com/6760d08e-54e3-4f1c-b22e-6ba605ec7592/sharpening:1.0

Success! The Sharpening Filter example block will now appear in the UP42 custom-blocks menu. When building a workflow it can be selected under the Custom blocks tab.

Custom block in the workflow builder
Custom block in the workflow builder

You can find more advanced instructions on custom block development & publishing in the chapter Developing a custom processing block.