Skip to main content

Edge Session

The EdgeSession class is your entry point into the Edge API. For example, if you have an EdgeSession instance called mysession, then the Files API is available at mysession.files. Likewise for data sources (.sources), and even publishing applications(.applications).

Constructing an EdgeSession

In order to construct an EdgeSession object, you need three pieces of information:

  1. An Edge API token. You can create one of in the "Edge API Tokens" section of your Profile.
  2. The URL to the Edge API. For the main Edge server at edge.enthought.com, this is https://edge.enthought.com/services/api.
  3. The name of the organization in Edge to which you want to connect. This is the "short name" that shows up in the URL, for example, default.

Auto-configuration

The EdgeSession object will automatically look for these environment variables, and use them to construct the object:

  1. EDGE_API_TOKEN or JUPYTERHUB_API_TOKEN
  2. EDGE_API_SERVICE_URL
  3. EDGE_API_ORG

If these are present, simply call the constructor with no arguments:

from edge.api import EdgeSession

mysession = EdgeSession()

Programmatic configuration

If you wish to configure an EdgeSession without using environment variables, pass the three parameters from your code. We recommend using the keyword names in case the order of arguments shifts at some point in the future:

from edge.api import EdgeSession

mysession = EdgeSession(api_token=mytoken,
service_url="https://edge.enthought.com/services/api",
organization="default")
Using a proxy

Edge utilizes the standard Python requests library under the hood, simplifying the process of working with proxy servers. To enable your EdgeSession to function seamlessly on a local setup with proxy protections, you only need to configure two variables in your Python environment:

  1. HTTP_PROXY
  2. HTTPS_PROXY

Your IT administrator or the individual responsible for your lab's networking can provide this information for you. For more on this, you can review the documentation for the requests library.

EdgeSession Reference


Constructor

EdgeSession(api_token=None, service_url=None, organization=None)

Be sure to use keyword arguments when calling the constructor, not positional arguments. The order of parameters may change at some point in the future.

Parameters
  • api_token (str)
    Your Edge API token.
  • service_url (str)
    URL (including https://) of the Edge API
  • organization (str)
    "Short name" of your Edge org, for example, "default"

Properties

organization

Property (str). The name of the organization to which this EdgeSession is attached.

files

Property (Folder). A Folder instance at the root of the Edge file system.

sources

Property (EdgeData). An EdgeData instance with access to data connectors.

applications

Property (EdgeApplication). An interface for managing applications and application versions.

tokens

Property (EdgeTokens). An interface to create and remove Edge Tokens.

admin

Property (EdgeAdmin). An interface to administrate the Edge service (e.g. CRUD organizations)

billing

Property (EdgeBilling). An interface for organization administrators to query billing data.

compute

Property (EdgeCompute). An interface to manage compute profiles and placeholders.


Methods

whoami

whoami() -> WhoAmI

Returns

WhoAmI object.

set_whoami

Sets user profile information. Any values that are left as the default None will be overwritten as None. Existing values are not preserved.

set_whoami(first_name=None, last_name=None, email=None)

Parameters
  • first_name (str)
    Optional; User's first name.
  • last_name (str)
    Optional; User's last name.
  • email (str)
    Optional; User's e-mail address.

search(query, kind=None) -> list(SearchResult)

Parameters
  • query (str)
    String to search for (uses trigram, so can be approximate)
  • kind (str)
    Optional; Search limiting filter, one of 'file', 'folder', 'connector'
Returns

list(SearchResult) List of search results.