Hello world (Py)
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
If you are using visual studio code, this should look something like this:
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:
In visual studio code your project should something like this:
You can deploy your function to the task service using the EXH CLI Tool. run the sync task command in your terminal:
Using postman we can create a new task execution for our hello-world function. Create a http POST method and mention the function name.
You can log into the Extra Horizon control center to verify the execution of your function.
Go to tasks>hello-world-python>executions.
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