Local testing

Test custom blocks locally before publishing.


Overview

With sample data you can build and run your custom block locally to test it before pushing it to the platform.

Step 1. Download and install prerequisites

Step 2. Move to the custom block folder

Step 3. Build your custom block locally

Step 4. Prepare necessary files

Step 5. Run your custom block locally

Step 1. Download and install prerequisites

You won't be able to test custom blocks without this software installed.

Step 2. Move to the custom block folder

Perform the following operations from the folder of your custom block.

If you don't have a ready custom block, download an example block using Git. For example, download Sharpening Filter from your terminal and move to the created folder as follows:

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

Step 3. Build your custom block locally

docker build -t registry.up42.com/<image_name> .

Copy and adjust the code template as follows:

  1. Replace <image_name> with the name of a Docker image.
  2. Optionally, add a version of the block. The tag is latest by default.
  3. Run the completed code in your terminal. For example:
    docker build -t registry.up42.com/sharpening:1.0 .

You don't need your user ID for local testing.

Step 4. Prepare necessary files

Add to your custom input folder the following files:

  • A data.json file that conforms to the custom block input requirements. It should contain a relative path pointing to the respective file or output directory in the /tmp/output folder. For more information, see Data transfer and storage.
  • If the block outputs images, an image file of the right format. For example, a .TIFF file for the Sharpening Filter algorithm.

When building a Docker image locally, you don't need a manifest file.

Step 5. Run your custom block locally

docker run -v /<LOCAL_FOLDER_PATH>:/tmp/input -v /<LOCAL_FOLDER_PATH>:/tmp/output registry.up42.com/<image_name>

Copy and adjust the code template as follows:

  1. Add your local folder path.
  2. Replace <image_name> with the name of a Docker image.
  3. Optionally, add a version of the block. The tag is latest by default.
  4. Run the completed code in your terminal. For example:
    docker run -v /Users/max.mustermann/sharpening/input:/tmp/input -v /Users/max.mustermann/sharpening/output:/tmp/output registry.up42.com/sharpening:1.0
    You can use a --mount flag instead of -v. For more information, see Docker Engine overview.