Skip to main content

Custom Applications on Edge

Why Edge for applications?

Deploying web apps in the cloud is a complex and time-consuming process that requires specialized skills and expertise. Typically, it involves multiple steps, such as setting up a cloud environment, configuring networks, and establishing access management. This complexity can lead to delays, extra costs, and potential risks for R&D teams who want to focus on the science rather than software engineering.

With Edge, you can easily turn your notebook solutions into production-ready web apps. Once your app is deployed, authorized members of your organization can access it from anywhere using a standard web browser and logging into their Edge account without needing to see or understand the underlying code. Whether you've built a novel visualization of some experimental data or an ML model for detecting defects in metrology images, sharing it as an app on your team's scientific workbench makes it as easy as a few clicks to get value from your work.

You can deploy your applications to production in under a minute with Edge, since the platform simplifies the process and does all the heavy-lifting for you in 3 areas:

  1. Edge provides a pre-configured and secure cloud environment, eliminating the need for you to set up and configure your own environment.
  2. Edge streamlines the deployment process by handling all aspects of app deployment, including authentication, compute scaling, and data encryption.
  3. Edge automates the monitoring and management of your deployed apps, ensuring your cloud costs are optimized and under control.

In the rest of this section, we will review the key concepts you need to know to make the most out of the Edge Native Application framework.

Types of Applications

In the Edge world, there are two types of applications: Native and External:

Native Applications

Edge Native Applications work very much like the Analysis App (JupyterLab on Edge). They are "containerized" web applications, where each user gets a dedicated backend instance upon application launch. This single-user architecture allows Edge native apps to self-deploy with zero IT/DevOps intervention, and auto-scale with zero downtime. In addition, each user gets their own personalized level of computational resources (CPUs, GPUs and RAM) which they can scale vertically, up or down, on demand, (See Compute Profile for more info).

While Edge Native apps are opinionated about the architecture, they support an extensive set of use cases, thanks to the versatility of Docker containers. This gives you the power to package up and productionize your work in minutes. You can use Edge Native apps to:

  • Deploy web applications, especially resource-intensive scientific web apps
  • Turn your Jupyter notebooks into simple apps using Dash, Streamlit, Voila, or similar frameworks
  • Build and share data visualization dashboards
  • Deploy your AI models to run in the cloud

External Applications

External Applications are websites that are not hosted in Edge containers, but still appear as an application tile in Edge and benefit from Edge's user authentication. When a user launches an External Application they will be taken to the External Application's home page in a different browser window.

App Development Overview

Edge Application Model

Applications are records stored in Edge. An Application record is identified by app_id, and can be associated with individual AppVersion records. Version records store all of the information record to display a tile in Edge's Home and any information required to launch the application. Individual versions can be made visible or hidden to users.

Native applications, including dashboard apps, also require a ServerInfo record. This type of record stores the required credentials for accessing the Docker image repository where the application's image is stored.

Who can create applications?

In Edge, an Application can only be created by an organization's administrator, i.e. someone with the "admin" role in the organization. Once an Application has been created, though, anyone in the organization with the "developer" role can publish new versions (AppVersion records).

This is to make sure that only approved applications are displayed on the workbench, while ensuring that developers can iterate as quickly as possible on changes to the application.

In the following example, we show how to use the Edge API to both create an application and publish a new version. Keep in mind that you will need to have the "admin" role in order to create the Application object. Or, you can request that an admin create the Application for you in advance via the Edge UI.

Publishing an Application

To publish an Application, first make sure that you are an organization developer. There are several requirements for publishing an application:

  • An Edge API Token
  • EDM, the Enthought Deployment Manager
  • The enthought_edge package from the enthought/edge EDM repository
  • A Native application image that has already been pushed to a Docker repository (eg Docker Hub, Quay, etc.) or the URL of an External application
  • A username and password pair with access to your Docker repository where your application image is stored.

Creating an Edge API Token

As an Organization Developer, you can create an Edge API Token. With your web browser, go to Edge's Token Manager. Here, you can create an API token for use with Edge.

Creating an Edge Token

Installing the enthought_edge Package

The enthought_edge package is available in the enthought/edge EDM repository. After adding this to your .edm.yaml, the package can be installed via EDM using these shell commands:

edm environments create edge --version 3.8
edm shell -e edge
edm install enthought_edge
Important

The enthought_edge package requires Python version 3.8 or later for installation. Also, to get the most current version of enthought_edge, make sure that at minimum, you have the following EDM repositories in your .edm.yaml file:

  • enthought/free
  • enthought/lgpl
  • enthought/edge

Working with an EdgeSession

The enthought_edge package has an EdgeSession object, which provides convenient methods for interacting with Edge. You can use this code in an interactive Python session:

from edge.api import EdgeSession

edge = EdgeSession(
service_url="https://edge.enthought.com/services/api",
version_num=1,
organization="<YOUR_ORGANIZATION>",
api_token="<YOUR_API_TOKEN>"
)
edge.applications.list_application_ids()

This will list any applications that are currently available in your organization. If no applications have been registered, you will see an empty list.

Creating an Application

The first step to publishing an Application and an associated Version is to create an Application record using the edge.apps.application.Application class:

from edge.apps.application import Application
app = Application('mynativeapp', True)
edge.applications.add_application(app)
edge.applications.list_application_ids()

This adds an application with the ID mynativeapp. The second parameter in the Application constructor makes any new versions added to the application automatically visible in the Home.

Adding Server information

When Edge launches a Native application, it must pull the image from a Docker image repository. The repository may require a username and password. Therefore, we must also create a ServerInfo object with the name of the application, domain name of the image registry such as quay.io, and username and password for the image registry:

from edge.apps.server_info import ServerInfo
server = ServerInfo(
app_id='mynativeapp',
domain='quay.io',
username='<QUAY_USERNAME>',
password='<QUAY_PASSWORD>'
)
edge.applications.add_server_info(server)
caution

We recommend using robot accounts to register your image repositories with Edge. This will make sure Edge is not using any individual user's credentials in the process of deploying the custom applications of your organization.

Adding an Application Version

The last step for publishing an application is to add an AppVersion object. The AppVersion object requires:

  • The Application object's ID
  • A version number
  • A title to go on the application tile on the Workbench
  • A description for the application
  • A base64 encoded image for the Application tile's icon
  • An AppKindEnum, either Native or External
  • A Docker image repository for Native apps, or a URL for External applications

In this example code, we will add a Native application:

from edge.apps.app_version import AppKindEnum, AppVersion

ICON = (
"iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/w"
"D/AP+gvaeTAAABfklEQVRoge2ZTU7DMBBGHz9bECpLWAI36ZIdEvQa5Rpw"
"CFQhtaq66o5wErgCWSR7KAvbUrGaFI8Tu5XmSZbjuFK/mS/jNjYoiqLsMp"
"fAHKiBVeJWAwvgOkZ8mUG430rgQhLAfAfEuzZrEnnQEkANnAQG3RcVcLZp"
"oi2AlTe+7UzO/1h6441aDxMI6ZUcASz5m11/HMTeO3Cc8Lv8LDeNg2pNHQ"
"jAZdbPtCjzDnUgAK2BTWgN5CalAw4/01H/sfbeAQ0gN5IaOAJGwNBeF8AE"
"+LHzna4y25AEMALu18Z3GPGTThQFIglgaPsx8NmhFhGSGhjYPrt4iPsdeM"
"G8NxfAFPj25sVvWSHErEID4Bx4sM3xEaUokBgHxpgEPGHq4tXef/Q+16sT"
"EgdK269vc/hbMMmQOFBgHpln714WJAFMbe+W0zdatv76RnfmctPmQAWcph"
"KyhcbN3TYH3vvRIkK0SNwAX+Q/GyiBK0kAYE5GZhgLUwuvMIcsYvGKoij9"
"8ws479akcYBsnQAAAABJRU5ErkJggg=="
)
version1 = AppVersion(
app_id=app.app_id,
version="1.0.0",
title="Edge Native App Demo, v1.0.0",
description="Demonstration of a native application",
icon=ICON,
kind=AppKindEnum.Native,
link="quay.io/enthought/edge-native-app-flask-demo:latest",
)
edge.applications.add_app_version(version1)

Launching the Application

At this point, the Application Version should be visible on the Edge Home Screen with the title "Edge Native App Demo, v1":

The Edge Home Screen

That is it! Now, all of our authorized organization members can launch the app that we just deployed in Edge.