Overview

Functions enable code authors to write logic that can be executed quickly in operational contexts, such as dashboards and applications designed to empower decision-making processes. This logic is executed on the server side in an isolated environment.

Notably, Functions include first-class support for authoring logic based on the Foundry ontology. This includes support for reading properties of various object types, traversing links, and flexibly making ontology edits.

Common use cases for Functions include:

  • Returning object sets or variable values for use in Workshop.
  • Displaying transformed values in a derived table column using Workshop's Function-backed Columns.
  • Aggregating object type values to display as Workshop charts.
  • Expressing a complex edit to the ontology that updates many objects through a Function Backed Action.
  • Running logic in the backend to return information to be displayed in the frontend in Slate.
  • Computing custom metrics or aggregations for display in Quiver.
  • Querying external systems to enrich objects in the Ontology through external functions

The languages supported by Functions are TypeScript ↗ and Python (Beta)↗.

To get started using Functions in Foundry, we recommend the following tutorials:

Function feature support by language

Not all features are supported by both languages. Refer to the chart below for language support for specific features.

Functions capabilitySupported in TypescriptSupported in PythonDescription
Ontology object supportYesYesThe ability to access Ontology objects in your function.
Ontology edits supportYesYesThe ability to edit Ontology objects in your function.
Queryable in WorkshopYesYesInvoking a function from a workshop app.
Usable in Pipeline BuilderNoYesCalling a function from Pipeline Builder pipelines.
Functions on models supportYesNoWriting functions that can be embedded within a model.
Semantic search supportYesNoUse functions to create vectors for semantic search.
External API call supportYesYesQuerying external services from within functions.
Serverless execution supportYesYesA serverless function will be spun up on demand when invoked. Refer to serverless Python functions below for more information.
Deployed execution supportNoYesA deployed function will have dedicated resources allocated to it, ready to serve requests.
Calling function from API GatewayYesYesThe ability to hit a Query function from the API gateway.
Marketplace supportYesNoThe ability to package and ship functions via Marketplace.

Serverless function timeout

Currently, each serverless function is allocated a total of 60 seconds of wall time to run. This includes 30 seconds of CPU time and a 30-second buffer for any network delays. The function will fail if the timeout is exceeded.

Deployed function timeout

Currently, each deployed function is allocated a total of 60 seconds of wall time to run. The function will fail if the timeout is exceeded.

Serverless Python functions

If serverless Python functions are enabled for your enrollment, new repositories will use serverless functions by default. We recommend using serverless functions instead of deployed functions for most use cases. With serverless functions, you can have multiple versions of a single function available on demand, making upgrades safer. Serverless functions are in beta and may not be available on all enrollments. If this functionality is not enabled on your enrollment, you can use deployed Python functions as an alternative.

There are also some cases where deployed functions are preferred or must be used instead of serverless, but these are not common. If available, serverless functions are preferred for several reasons:

  • Serverless functions enable different versions of a single function to be executed on demand, making upgrades safer. With deployed functions, you can only run a single function version at a time.
  • Serverless functions only incur costs when executed, while deployed functions incur costs as long as the deployment is running.
  • Serverless functions require less upfront setup and long-term maintenance, as the infrastructure is managed automatically.