Extra Horizon
GitHub
  • Extra Horizon Documentation
  • Getting Started
    • Start familiarizing yourself
  • Tutorials
    • Medical Device Tutorial
      • Preparation
      • Build your first prototype
        • Define a data model
        • Configure your workflows
          • Workflow 1: Analyze a measurement
          • Workflow 2: Create & store a PDF report
          • Workflow 3: Send an e-mail
        • Define your permissions
          • Update your schema with user permissions
          • Update your schema with group permissions
        • Build the Front-End
          • Set up oAuth in your backend
          • Demo login page
      • Summary & Wrap up
    • Polysomnography (PSG) Tutorial
    • Retool - Building dashboards Tutorial
  • FAQ
    • General
  • Services
    • Identity and Access Management
      • User service
        • Users
        • Groups
        • Global roles
        • Configuration
      • Auth Service
        • Applications
        • OAuth2
        • OAuth1
        • MFA
        • OpenID Connect
          • Google Cloud
          • Azure ADFS
    • Data Management
      • File Service
      • Data Service
        • Schemas
        • Documents
        • FAQ Data Service
    • Automation
      • Task Service
        • Functions
        • Tasks
        • API Functions
        • Examples
          • Hello world (JS)
          • Hello world (Py)
          • Hello world (Docker)
        • FAQ
      • Dispatchers Service
      • Event Service
        • System Events
    • Communication
      • Notification Service
        • Notifications
        • Settings
      • Mail Service
    • Other
      • Localization Service
        • Language Codes
      • Template Service
        • Localizations
      • Payments Service
        • Subscriptions
        • Stripe
        • iOS App Store
      • Configurations Service
  • API Reference
    • OpenAPI Specifications
    • 📦Changelog
      • Per-service Changelog
    • Postman Reference Collection
  • Tools
    • SDK
    • CLI
    • Control Center
  • Additional Resources
    • Resource Query Language (RQL)
    • Handling Errors
    • GitHub
    • API interaction (Python)
    • Migration guide: Enabling verification request limiting
  • ExH Platform
    • 🙋Support
    • ⏱️Usage and Performance
    • 🔓Security
    • 🗺️Regions
    • ⚖️Cloud Subscription Agreement
    • 🇺🇸CFR 21 Part 11
Powered by GitBook
On this page
  • src/Index.py
  • task-config.json
  • Deploying with the ExH CLI
  • Running your task using postman
  • Verify using the ExH Control Center
  • Tips

Was this helpful?

  1. Services
  2. Automation
  3. Task Service
  4. Examples

Hello world (Py)

PreviousHello world (JS)NextHello world (Docker)

Last updated 1 year ago

Was this helpful?

src/Index.py

First let's create a simple hello-world script. We are creating a function called handler() that will act as the entryPoint of our code. Our goal is to print a simple "hello world" to the console.

index.py
def handler(event, context):
    print('Hello World!');

If you are using visual studio code, this should look something like this:

task-config.json

Next we need to create a configuration file that the Extra Horizon CLI can use to configure and deploy your function to you cluster.

To create the our function we need to provide the following information:

  • Name of the function

  • A description

  • Reference to the directory containing the (built) code (code)

  • the entrypoint or the function that should be invoked when the function is triggered

  • the runtime you want your code to use

For our function it looks something like this:

task-config.json
{
    "name": "hello-world-python",
    "description": "python hello world example",
    "path": "src",
    "entryPoint": "index.handler",
    "runtime": "python3.9"
}

In visual studio code your project should something like this:

Deploying with the ExH CLI

You can deploy your function to the task service using the EXH CLI Tool. run the sync task command in your terminal:

exh tasks sync --path=./task-config.json

Running your task using postman

Using postman we can create a new task execution for our hello-world function. Create a http POST method and mention the function name.

Verify using the ExH Control Center

You can log into the Extra Horizon control center to verify the execution of your function.

Go to tasks>hello-world-python>executions.

Tips

When you want add dependencies to your code. You can just add them to your src folder and the CLI will upload them to the environment. Make sure to only include essential dependencies as there is a 10MB limit for the entire size of your code.

In case you need to create functions larger than 10MB you can use docker. Please contact the Extra Horizon team via support@extrahorizon.com or via your dedicated slack channel on how to deploy your docker images.

You can see a hello-world function has been created in the task service. Visit the for more information.

Success!! You just created your first python function in Extra Horizon

🎉
Task service documentation