From template - simple
A step-by-step tutorial of how to create custom export app from SDK export template class `sly.app.Export`.
Introduction
In this tutorial, you will learn how to create custom export app for exporting your data from Supervisely platform using an export template class sly.app.Export that we have prepared for you.
We will go through the following steps:
Step 0. Set up the working environment.
Step 1. Write an export script.
Step 2. Debug export app.
Step 3. Advanced debugging.
Step 4. Release and run the app in Supervisely.
Everything you need to reproduce this tutorial is on GitHub: source code and additional app files.
Overview of the simple (illustrative) example we will use in tutorial
original images
annotations in json format
Output example:
ποΈ<id_project_name>.tar
β£ πds0
β β£ πΌοΈimage_1.jpg
β β£ πΌοΈimage_2.jpg
β β πlabels.json
β πds1
β£ πΌοΈimage_1.jpg
β£ πΌοΈimage_2.jpg
β πlabels.jsonFor each dataset label.json files contain annotations for images with class names and coordinate points for bounding boxes of each label.
Set up the working environment
Before we begin, please clone the template-export-app repository and set up the working environment - here is a link with a description of the steps.
Write an export script
You can find source code for this example here
Step 1. Import libraries
Step 2. Load environment variables
Load ENV variables for debug, has no effect in production
Step 3. Write Export script
Create a class that inherits from sly.app.Export and write process method that will handle the team_id, workspace_id, project_id and dataset_id that you specified in the local.env. In this example our class called MyExport.
sly.app.Export class will handle export routines for you:
it will check that selected project or dataset exist and that you have access to work with it,
it will upload your result data to Team Files and clean temporary folder, containing result archive in remote container or local hard drive if you are debugging your app.
Your application must return string, containing path to result archive or folder. If you return path to folder - this folder will be automatically archived.
sly.app.Export has a Context subclass which contains all required information that you need for exporting your data from Supervisely platform:
Team ID- shows team id where exporting project or dataset is locatedWorkspace ID- shows workspace id where exporting project or dataset is locatedProject ID- id of exporting projectDataset ID- id of exporting dataset (detected only if the export is performed from dataset context menu)
context variable is passed as an argument to process method of class MyExport and context object will be created automatically when you execute export script.
Output:
Now let's get to the code part
Create MyExport object and execute run method to start export
Debug export app
In this tutorial, we will be using the Run & Debug section of the VSCode to debug our export app.
The export template has 2 launch options for debugging: Debug and Advanced Debug. The settings for these options are configured in the launch.json file. Lets start from option #1 - Debug
This option is a good starting point. In this case, the resulting archive or folder with the exported data will remain on your computer and be saved in the path that we defined in the local.env file (SLY_APP_DATA_DIR="results/").

Output of this python program:
Advanced debugging
In addition to the regular debug option, this template also includes setting for Advanced debugging.
The advanced debugging option is somewhat identical, however it will upload result archive or folder with data to Team Files instead (Path to result archive - /tmp/supervisely/export/Supervisely App/<SESSION ID>/<PROJECT_ID>_<PROJECT_NAME>.tar). This option is an example of how production apps work in Supervisely platform.

Output of this python program:
Release and run the app in Supervisely
Submitting an app to the Supervisely Ecosystem isnβt as simple as pushing code to github repository, but itβs not as complicated as you may think of it either.
Please follow this link for instructions on adding your app. We have produced a step-by-step guide on how to add your application to the Supervisely Ecosystem.

Last updated
Was this helpful?