Skip to main content

App Development Details

In this section, we'll dig into what actually happens inside an Edge application. A lot of the "heavy lifting" is done for you by Edge and the development tools. It's important to learn what those tools are and how they work so you can apply them correctly.

Things to watch out for

About the "edm-rockylinux-8" Docker image

This base image includes the EDM deployment tool, which is used to install Python packages. pip is also available once you have created an EDM-based Python environment. It is embedded in a Rockylinux-8 linux image.


About the Edge Supported Frameworks

The example app you built and deployed in the previous section has very little boilerplate code. This is partly due to the "edm-rockylinux-8" base image with EDM built-in, but also due to framework-specific support that is installed next to your application when it launches.

This framework support handles some of the "paperwork" involved with interfacing between your app and Edge. This includes:

  • Handling the app's side of the OAuth authorization flow, so that only the user who launched the app can access it.
  • Sending activity "pings" back to Edge as the app is used. This is so that Edge can eventually shut the app down if it isn't being used.
  • Proxying your app and serving it on the standard port (8888) so that Edge can find it.

Using the Edge API (EdgeSession) inside your app

You can easily construct an EdgeSession object, by which your app can access APIs like data connectors or files. Because each user has their own running copy of your app, the EdgeSession will connect automatically under their account.

In your app's code, all you need to do is call the constructor with no arguments:

from edge.api import EdgeSession

mysession = EdgeSession()

That's it! The interface is ready to use. EdgeSession auto-configures by reading the user's API token, server location, etc., from the environment.

See the Streamlit example (or other examples in the online examples gallery) for tips on using EdgeSession locally in development mode. Briefly, when running your app outside of Edge you need to set some environment variables that will pass down your testing API token and a few other pieces of information.

Options for files and data storage

You can write to the local file system inside your app, but that local-disk storage is ephemeral... when the app is shut down and restarted, any changes will not be preserved. To persist data across application launches, you have a couple of options.

Store files on Edge

The first is to use the local drive as "scratch space", and save your data to Files on Edge or another external storage service. If you want to do this, create an EdgeSession object in your code and use the .files property to interact with the Edge file system. You can upload files from the local disk to Edge, and download files from Edge to process them. For example:

from edge import EdgeSession

mysession = EdgeSession()

# Upload a file
with open("my-local-file.bin", "rb") as f:
mysession.files.upload("my-remote-file.bin", f)

# Download a file"my-dataset.bin")

Store files in a persistent volume

The second option is to request that Edge allocate a persistent volume for your app. This approach is not currently exposed in the Edge user interface; you will need to specify the volume parameters when registering your app version via the Edge API. See the Programmatically publishing versions discussion below for how to use the Edge API to register an app version. You will need to include two additional fields in AppVersion constructor:

  • volume_mount_point: a string with the name of an (empty) folder in your Docker image where you want the volume to be mounted. Keep in mind that since your startup script is in the home directory, you should not put /home/app for this value. Instead, you can e.g. create a "workspace" folder and put /home/app/workspace as the mount point.

  • suggested_volume_size: integer with the capacity of the volume in gigabytes (not bytes). For cost efficiency, you should use the smallest volume size possible.

Ports and environment variables

Your app should bind to The Edge framework support will then proxy your app to the standard port of 8888. Your app should use plain HTTP or websockets. Don't use SSL or certificates; Edge handles that for you.

A number of the standard JupyterHub environment variables are available, plus a few Edge-specific ones:

  • JUPYTERHUB_SERVICE_PREFIX: If defined, has the full route to your app. If you're using a framework like Flask or FastAPI, you should respond to requests that start with this prefix. For example:

    PREFIX = os.environ.get("JUPYTERHUB_SERVICE_PREFIX", "/")

    @app.route(PREFIX + "my-resource")
    def get_my_resource():
  • EDGE_API_TOKEN or JUPYTERHUB_API_TOKEN: Allows access to the Edge API. At least one of these will be defined when your app is running in Edge. EdgeSession automatically picks up this value, along with the following two variables.

  • EDGE_API_ORG: The "short name" (ID) of the user's organization.

  • EDGE_API_SERVICE_URL: The full URL of the Edge API root.

Continuous integration

Running tests

Each example includes a python -m ci run command, which launches the app in a local environment. This is useful for interactive development.

There's also a Tools folder in the example gallery which contains a test script. This is a standalone script you can use in e.g. GitHub Actions to run checks as part of your continuous-integration (CI) process. See the README in that folder for instructions.

Programmatically publishing versions

You can automatically publish new versions of your app, for example in GitHub Actions as part of your continuous-integration workflow. To do so, create an EdgeSession within your build script and call the Edge "application" API:

from edge.api import EdgeSession
from edge.apps.application import Application
from edge.apps.app_version import AppKindEnum, AppFrameworkEnum, AppVersion
from edge.apps.server_info import ServerInfo

# Create an Edge session.
edge = EdgeSession(

# Register the application version.

# Icon is a base64-encoded PNG or JPEG image.
# It should be square, any size; 64x64 or 128x128 are common.
ICON = (
version = AppVersion(
app_id="my-app-id", # Specified when the app is created
version="1.0.0", # or whatever version you have
title="My Application Title",
description="This Is An Example Edge Application",