Use a Python function in Workshop

Beta

Python functions are currently in a beta state and may not be available on all enrollments.

Prerequisites

This guide assumes you have already authored and published a Python function. Review the getting started with Python functions documentation for a tutorial. For examples of how to query the Ontology using the Python SDK, see the Python Ontology SDK documentation.

Beta

Serverless Python functions are in a beta state and may not be available on all enrollments. If serverless Python functions are not enabled on your environment, you will have to deploy your function.

If serverless Python is enabled on your enrollment, deplyoing your function is optional and not required. If enabled, the serverless executor will be used by default.

Use the Python function in Workshop

In Workshop, search for the Python function from the Variables tab to the left side of the module. Deployed functions will show an icon with one of three states for both the function and the function version:

  • Running: This function and version can serve requests.
  • Stopped: This function and version are not available. In the function selector, hover over the information icon, select Configure and then Create and start deployment to make the function available.
  • Upgrading: This function and version are not yet available.
A Python function in Workshop

Cut a new release

Only one version of the function’s repository is hosted at a given time. To make changes to functions with limited downtime we recommend adding a new function (like function_v1) with the changes and tagging as described here. From your published functions under tags and releases, select Open in Ontology Manager.

In Ontology Manager, select the version of the function repository you want to use in applications, then select Upgrade.

Upgrade deployed function

Update all downstream applications using functions from this repository to the new version you have deployed. Note that the previous deployment version will no longer be running so your applications will have a short downtime as you make this change. You will have function_v0 and function_v1 available at the same time so while you need to switch to the new deployment version, you do not have to change the function you are using. When function_v0 is no longer used, you can delete the function.

Debug errors

If your function is not working as expected in Workshop, first check if the issue is related to the logic or the responsiveness of the function. If there is an issue with the logic, inspect the source code in the backing code repository. If there is an issue with the function being unresponsive or throwing an error, follow the steps below:

  1. Check if the version you selected is currently running in the function selector dropdown menu.
Workshop function version selector.
  1. If the function is not deployed or Upgrading, hover over the function’s information icon and select Configure. This will take you to Ontology Manager where you can select Start Deployment to get your function running again.
Information about Python function version.
  1. If your function is Running or you need more information about the deployment’s behavior, select Deployment from the left panel in Ontology Manager to view detailed logs. SLS logs are also available if you select View live.
View deployment logs in Ontology Manager.