Overview
Introduction
There are many different applications in the Supervisely ecosystem for exporting data to various popular formats. However, companies often need to implement custom data export in their specific format to meet their particular requirements.
In the upcoming tutorial series, you will learn 2 ways to create a custom export app for exporting data from the Supervisely platform.
Option 1. Use our SDK export template class sly.app.Export
(simple)
sly.app.Export
(simple)👍 This way is more convenient and can handle most of the routine tasks and cover most required use cases. All you need to do is create your own class (inherit from sly.app.Export
), and override the process
method. Method process
should return the path to the result data (folder or archive).
✅ Learn step-by-step tutorial here.
Option 2. Create an app from scratch (advanced)
It is more recommended way to use SDK export template class (sly.app.Export
) to create custom export app. However, if your use case is not covered by our export template, you can create your own app without the template. We will also learn this way in the upcoming tutorial series.
✅ Learn step-by-step tutorial here.
More details about sly.app.Export. See source code
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:
Set up an environment for development
The following pages of the guide about creating a custom export app will refer to this section, which describes the preparation of the working environment.
We advise reading our from script to supervisely app guide if you are unfamiliar with the file structure of a Supervisely app repository because it addresses the majority of the potential questions.
For both options, you need to prepare a development environment. Follow the steps below:
Step 1. Prepare ~/supervisely.env
file with credentials. Learn more here.
Step 2. Fork and clone repository with source code and create Virtual Environment.
Step 3. Open repository directory in Visual Studio Code.
Step 4. Select created virtual environment as python interpreter.
Step 5. Open local.env
and insert your values here. Learn more about environment variables in our guide
Please note that the path you specify in the SLY_APP_DATA_DIR
variable will be used for saving application results and temporary files (temporary files will be removed at the end).
For example:
path on your local computer could be
/Users/maxim/my_data/
path in the current project folder on your local computer could be
results/
Don't forget to add this path to
.gitignore
to exclude it from the list of files tracked by Git.
When running the app from Supervisely platform: Project and Dataset IDs will be automatically detected depending on how you run your application.
Last updated