Add private app

Introduction

Supervisely supports both private and public apps.

🔒 Private apps are those that are available only on your private Supervisely Instance (Enterprise Edition) in your account.

🌎 Public apps are available on all private Supervisely Instances and in Community Edition. The guidelines for adding public apps will be covered in other tutorials.

This tutorial covers the case of adding a custom private app to your private instance. It means that this app will be available only for your account and only on your private Supervisely instance.

Apps, developed by the Supervisely team, are open-sourced and are available on all Supervisely instances (Community Edition and all private customer's instances with Enterprise Edition license). The case of publishing an app to the global public Supervisely Ecosystem will be covered in another tutorial.

Version releases and Branch releases

There are two types of releases: version and branch. The version release is made from the main or master branch. With each version release, a release tag is added to the last commit. This tag is used to identify the release version and is important for the app versioning. If during the release process, the tag is not created, the release will be rejected. With version releases, you can specify the release version and description. The branch releases are for testing and debugging and are made from any other branch except main or master. With branch releases, you can't specify the release version and description. The release version will be the branch name.

Multi-app repositories

In Supervisely you can have a single git repository with multiple applications. It is advised to have connected applications with a common codebase in the same repository. By default supervisely release command will release the application from the root directory of the repository. If you have multiple applications in the repository, you can specify the path to the application directory with the -a flag. The application directory is a directory with a config.json file. Such applications are called subapps. For example, if you have a repository with two applications in the train and serve directories, you can release the train application with the following command:

supervisely release -a train

When making a release the tag is added to the last commit. And since all of the applications are in the same repository, it is impossible to differentiate the release tags of different applications. Therefore, it is advised to do a release for each subapp with every new version.

How to share the private app with Team members

After the private app is released it will be available for the user who released the app. The app can be shared with the team members without the need to share it with the whole instance. To do it, you need to run the app once while being a member of the team. After that, the app will appear on the App sessions page and will become available by URL for any team member.

Step 0. Install Supervisely SDK

Run command in terminal to install Supervisely SDK

pip install supervisely

Create a .env file ~/supervisely.env with the following content (learn more here:

SERVER_ADDRESS="<server-address>"
API_TOKEN="4r47N...xaTatb"

Development in a team

For team development, you need to add APP_RELEASE_TOKEN variable to your ~/supervisely.env file. This token will be used to authenticate your app during the release process. If APP_RELEASE_TOKEN is present in your ~/supervisely.env file, then the app will be owned by the user associated with the token and any user will be able to do a release if he has the token. Otherwise, the app will be owned by the user who released the app and releases from other users will be rejected.

How to get APP_RELEASE_TOKEN

  1. Create a new user on your instance. This user will be used for releasing apps. You can name it dev or dev-team or whatever you want.

dev-in-team-1
dev-in-team-2
  1. Login as this user and copy API token.

dev-in-team-3
dev-in-team-4
  1. Use this token as APP_RELEASE_TOKEN in your ~/supervisely.env file.

SERVER_ADDRESS="<server-address>"
API_TOKEN="4r47N...xaTatb"
APP_RELEASE_TOKEN="xaTatb...4r47N"

How to pass ownership of an app to another user

If you released an app without APP_RELEASE_TOKEN and now want to continue development in a team you can pass the ownership to the user created in previous steps. To do this you need to go to the private app page, navigate to the bottom left part and click Change owner button. Then input login of the user. You will be still able to see this app in your private apps. But to make new releases you will need to use APP_RELEASE_TOKEN of the new owner.

dev-in-team-change-ownership

Step 1. Prepare a directory with app sources.

You are a developer and you implemented an app. App sources are on your local computer in some directory. Go to this folder. For example, the folder structure will look like this:

.
├── README.md
├── config.json
├── requirements.txt
└── src
    └── main.py

Step 2. Release

Execute the following command in the terminal to release an app. By default, this command will pack and release files in the current folder.

supervisely release

You will be asked for a release description and in case of releasing from main/master branch for release version. After that, you will see a summary message and confirmation request. If releasing from main/master branch new tag will be created and pushed to remote (You may be asked for git authentication). Then if there are no errors you will see the "App release successfully!" message.

You can provide release version and release description by providing --release-version and --release-description options to the CLI

Your app will appear in the section 🔒 private apps` in Ecosystem.

Thus you can quickly do releases of your app. All releases will be available on the application page. Just select the release in the modal window in the advanced section before running the app. The latest release is selected by default.

You can store several applications in one repository. To release an application from such repository, go to root folder of the repository, then run supervisely release with -a flag and specify the relative path to folder with application configuration file

cd ~/code/yolov5
supervisely release -a apps/train

Option 2. Connect your git account (Github or Gitlab).

Since Supervisely app is just a git repository, we support public and private repos from the most popular hosting platforms in the world - GitHub and GitLab. You just need to generate and provide the access token to your repo.

Step 1. Generate new personal token

GitHub

To access private GitHub repositories, you will need to generate a personal token. Please note, that this token will provide your Supervisely instance a read access to all repositories, available for this GitHub account — you may want to create a dedicated GutHub account for a single Supervisely App repository.

Open GitHub → Settings → Developer settings → Personal access tokens and click Generate new token.

Select "repo" access scope and click "Generate token" button. Save generated token — you will need it later.

GitLab

To access private GitLab repositories, you will need to generate a personal token. Please note, that this token will provide your Supervisely instance a read access to all repositories, available for this GitLab account — you may want to create a dedicated GutLab account for a single Supervisely App repository.

Open GilLab → Settings → Access Tokens

Select with "read_api", "read_repository" scopes enabled and click "Create personal access token" button. Save generated token — you will need it later.

Step 2. Create repository

GitHub

Let's create a new GitHub repository that we will use to deploy a new Supervisely application. Create a new private GitHub repository: do not forget to choose "Private" visibility option.

GitLab

Let's create a new GitLab repository that we will use to deploy a new Supervisely application. Create a new project.

You can create a public repository alright — you will still need a personal token and further steps are gonna be the same.

Step 3. Make it a Supervisely App repository

In this tutorial we will use While(true) app code-base as a starting point — it's a bare minimum sample application that, basically, just runs an infinite loop.

We will download its source code, extract it, create a new repository and initialize it:

wget -O while-true-app.zip  https://github.com/supervisely-ecosystem/while-true-script/archive/refs/heads/master.zip
unzip while-true-app.zip
cd while-true-script-master/
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/supervisely/my-first-private-app.git # Your actual repository name here...
git push -u origin main

You will find a few files in your new application:

  • config.json describes your app name, type, etc.

  • requirements.txt list python packages you will need

  • README.md in markdown format

  • src/main.py your entry-point python file

Let's leave it as is for now

Step 4. Add Application to Supervisely

Go to Ecosystem page → Private apps → Click "Add private app"

Step 5. Check your first application

Now, open the Ecosystem page in the left menu and choose "Private Apps" in the right menu. You should see here your new application after a minute. Add it to your team and try it out!

Next time you push a new update to your repository, do not forget to open the application in Ecosystem and click "Refresh" button to update it.

Option 3. Create a release on GitHub

Only for Supervisely Team.

Step 1. Create a repository

Create an app repository on GitHub in a Supervisely-ecosystem organization. *How to create an app

Step 2. Add GitHub workflow

Add a GitHub workflow files from this repository:

  1. For version releases (see step 3.1): .github/workflows/release.yml

  2. For branch releases (see step 3.2): .github/workflows/release_branch.yml

name: Release
run-name: Release version "${{ github.event.release.tag_name }}"
on:
  release:
    types: [published]
    branches:
      - main
      - master
jobs:
  Supervisely-Release:
    ***
    with:
      ***
      SUBAPP_PATHS: "__ROOT_APP__, subapp" <-- Change this variable

In each of these files, you should change the following variable: SUBAPP_PATHS - Paths to directories with applications within the repository (directory where the config.json file is located). If the application is located in a root directory, then you should specify __ROOT_APP__ instead of the path. Paths should be separated by commas.

In the example above, releases are configured for two applications in the repository: the one which is located in root directory and the one which is located in the subapp directory. Example for the repository with two applications, located in train and serve directories: SUBAPP_PATHS: "train, serve".

Step 3. Create a release

3.1 Version release

The workflow we created in the previous step will be triggered when you publish a release in the repository.

To create a release, go to the repository page on GitHub and click on the Releases tab. Then click on the Create a new release or Draft a new release button. Choose a tag version in semver format (v1.0.0) and a release title. Then click on the Publish release button.

Do not change the Target of the release. It should always be main or master.

3.2 Branch release

The workflow we created in the previous step will be triggered when you push a branch (except "main" or "master") in the repository.

You can disable branch release by adding the branch name to branches-ignore list in the .github/workflows/release_branch.yml workflow file. See below

name: Release branch
run-name: Release "${{ github.ref_name }}" branch
on:
  push:
    branches-ignore:
      - main
      - master
      - branch-to-ignore <-- Add branch name here
jobs:
  Supervisely-Release:

After the release is published the workflow will be triggered and you can see the release progress in the Actions tab. If the workflow is successful, the app will appear in the ecosystem.

Last updated