Prerequisites
Before you begin developing your application logic with Catalyst Python SDK in your local environment, please ensure you have the following package manager and programming environment installed on your local machine:
You can install Python from the official website and the pip package manager will be auto-installed in your local. Please make sure you install the pip package manually if you install Python from other sources. You can refer to this doc for installing pip.
If you are creating Python functions in an existing Catalyst project in your local directory, you can install the prerequisites mentioned above, and proceed to set up the function. The steps to set up a Python function in an existing project directory are given in this help page. To learn about initalizing a Python function during Catalyst project initialization, refer this help page.
Setup
Installing the SDK
When you initialize a Catalyst project in the CLI and create or set up a Python function in an existing project directory in your local environment, the Python SDK package (zcatalyst-sdk) will automatically be installed inside the functions directory of your current project.
A main function file and a configuration file will be auto-generated with the boilerplate code in your function’s directory by default when you create a Catalyst Serverless function of any programming stack. For Python functions, an additional file named requirements.txt will also be created. This file contains the list of installed dependencies that are needed to implement the Python function. By default, it contains the entry for Catalyst’s Python SDK package (zcatalyst-sdk), when you create the Python function from the CLI. When you need to install external dependencies, you will need to add the name of the dependency manually in the requirements.txt file.
For detailed information about the Python function directory, and the files and dependencies created in it, refer to the Project Directory Structure help page.
Initializing the SDK
After Python SDK is installed in your function’s directory, you can begin coding the Python function. You must first initialize the SDK within the function’s code, using the initialize() method as shown below:
When you initialize the SDK package inside the function, it returns a Python object as the response. This object can be used to call the component-specific methods defined in the Python classes and access the required Catalyst components.
Updating the SDK
As discussed previously, the requirements.txt file will contain the list of installed Python dependencies for your Python function. This includes the Catalyst Python SDK and the other user installed dependencies that are needed to implement certain Python classes.
You can update the version of the SDK by simply replacing it with the newer version in the requirements.txt file and saving it. Once you update the version of the SDK, you need to serve or deploy your application locally. This helps to enable the updated changes in the newer version of the SDK in your Python function.
Yes
No
Send your feedback to us