Python functions are currently in a beta state and may not be available on all enrollments.
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.
If serverless Python is enabled for your enrollment, new repositories will use it by default. We generally recommend serverless functions for most use cases. While a deployed function may be useful in some circumstances, the serverless execution mode requires less maintenance and avoids incurring the costs associated with long-lived deployments.
Deployed functions have some capabilities that are not available to serverless functions:
Deployed functions have some limitations that do not apply to serverless execution:
To enable serverless Python functions for your enrollment, contact your Palantir administrator.
Python functions can be run in a serverless mode, leveraging on-demand resources in the same way as TypeScript functions, or they can be deployed to a long-lived container.
We recommend using serverless Python functions if enabled on your enrollment, rather than deployed functions. While there are some cases where deployed functions are useful, the serverless executor is generally more flexible.
When your function is deployed, a long-running environment will be created to handle incoming execution requests. The environment will be scaled according to the request volume and occasionally restarted by automated processes. All functions from a single repository are hosted by a single deployment.
Deployed Python functions will incur compute costs for the running deployment. Serverless functions will only incur costs when executed.
Follow the steps below to prepare and configure a deployed Python function: