Dependencies for Python functions

This section describes how to create dependencies for Python functions in FunctionGraph.

Example

Before creating a dependency, ensure that Python matching the function runtime has been installed in the environment.

The following uses Python 3.10 as an example to describe how to create a fg_events dependency package.

  1. Create a directory for your function and navigate to it.

# Create a directory for your function
mkdir dependency-fg-events
cd dependency-fg-events
  1. Create a requirements.txt file and add dependencies.

    fg-events @ git+https://github.com/opentelekomcloud-community/otc-functiongraph-python-runtime.git@main#subdirectory=fg-events
    
  2. Create zip file using createZip.py.

    python3 createZip.py
    
  3. Deploy the dependency package to FunctionGraph as described in Configuring Dependency Packages

Full example for fg-events dependency package

This example deploys fg_events dependency packages for 4 Python runtime versions using Terraform:

make tf_init & make tf_apply

Additionally, a simple timer event function using the dependency and a test event are deployed.

For details on setting up Terraform, see Prepare the Terraform/OpenTofu environment.

For code, see samples-doc/dependency-fg-events directory.