Loading...

Synapse Apps

Getting Started

Synapse Apps are standalone C++ applications packaged using Docker and deployed to a Synapse device, such as SciFi. Apps allow you to run custom neural processing algorithms on-device within your Synapse signal chain, enabling real-time data processing with minimal latency. Apps are integrated into existing signal chains using the kApplication node type, and robustly support data streaming using Taps API. Taps enable multi-source streaming from within a single app. This means that data can be streamed out from multiple positions within an app to a client computer using a Python client script.

The video tutorial below demonstrates installation and basic use of synapse-python from the Linux terminal, then walks through build and deployment of the synapse-example-app.

Note: Example code in the tutorial video and documentation below assumes the Linux operating system.

The below tutorial video demonstrates basic setup and deployment using the Synapse example app in Linux. Some commands will be different when using the Windows command line.

Prerequisites

Before beginning, make sure you have the following installed:

  • Python3
  • pip
  • Docker

Synapse App development is currently supported for and tested on MacOS and Ubuntu Linux, with Windows support to follow. Contact us if you have a different operating system you would like to use.

Science Libraries

We provide a C++ SDK that allows your app to take full advantage of the SciFi hardware. Additionally, we provide the Synapse Python client API that allows you to listen to your data using Taps API.

Getting Started

Before diving into custom app development, we will walk through the installation, build and deploy process using the Synapse example app. This will introduce the workflow you will use to create your own custom apps using Synapse and SciFi.

Install synapsectl

synapsectl is a command line tool that allows you to build, deploy, and monitor your application while it is running. It also comes with the Python API to programmatically interface with your running app. We recommend installing and running synapsectl in a virtual environment.

Create and activate a virtual environment, then install the synapse-python client with pip:

# create a Python virtual environment called myenv
python -m venv myenv

# activate your virtual environment
source myenv/bin/activate

# install Synapse in your virtual environment
pip install science-synapse

Download Synapse Example App

Next, clone or fork the synapse-example-app.

# clone the synapse-example-app repository
git clone git@github.com:sciencecorp/synapse-example-app.git

# navigate to the synapse-example-app directory
cd synapse-example-app

# initialize and update all submodules
git submodule update --init --recursive

Build Your App

With the example application cloned, you can now build the app. Remember to have Docker installed and running, as you will need to cross-compile the application before deployment onto a Synapse device.

The first time you build the application, it may take some time. This is because it needs to install and build the dependencies in the docker container. Subsequent builds should be faster.

synapsectl build $PATH_TO/synapse-example-app

Errors encountered during the build process should be self descriptive, but you can contact us at support@science.xyz for additional support or report persistent issues or bugs to the Synapse issue tracker.

When the build is completed successful, you will see a Build complete message.

Deploy Your App

The app is now built and ready for packaging and deployment to your Synapse device. The deploy command packages and installs your application. Remember, device URI can be your SciFi's IP address or name.

synapsectl -u $DEVICE_IP deploy $PATH_TO/synapse-example-app

Using Your App

To start your app, your Synapse device needs both a start command and your .json signal chain configuration file. Remember, apps can be integrated into existing signal chain configurations using the kApplication node type.

synapsectl -u $DEVICE_IP start $PATH_TO_CONFIG.json

You can confirm the app is running using the info command.

synapsectl -u $DEVICE_IP info

Changes to signal chain configuration can be made by issuing the stop command, updating the configuration file, then issuing the start command as shown below:

synapsectl -u $DEVICE_IP stop
synapsectl -u $DEVICE_IP start $PATH_TO_CONFIG.json

Read Data From Your App

You can to listen to data streams on your Synapse device from your local client using the Taps API To see the list of available taps, run:

synapsectl -u $DEVICE_IP taps list

You can verify that you are receiving the expected data using the following commands:

synapsectl -u $DEVICE_IP taps stream "taps_name"

Refer to the Taps API documentation or the examples in the \client\ folder of the Synapse example application for more information on how to read data into client software.

Custom App Development

To develop your own custom application logic, refer to the Synapse App SDK documentation for a detailed explanation of Synapse application development using the SDK. We recommend starting from the synapse-example-app, and developing from there