Skip to content

Commit

Permalink
Add clarifications about where you can use Python dependencies (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicusX authored Nov 25, 2024
1 parent 1180429 commit a64439e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/PythonDependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ The application is very simple, and uses _botocore_ and _boto3_ Python libraries
These libraries are used to invoke Amazon Bedrock to get a fun fact about a random number.
The output is sent to a Kinesis Data Stream.

> ⚠️ **IMPORTANT**
> Python dependencies specified using `requirements.txt` can only be imported and used in Python UDF or any function used
> for data processing. These dependencies cannot be imported at top level or in the `main()`.
> See [Flink documentations](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/dev/python/dependency_management/#requirementstxt)
> for more details.
---

Expand Down
4 changes: 4 additions & 0 deletions python/PythonDependencies/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def property_map(props, property_group_id):

@udf(input_types=[DataTypes.INT()], result_type=DataTypes.STRING())
def ask_bedrock_for_fun_fact(a_number):
# IMPORTANT
# The Python libraries defined in requirements.txt can only be imported inside a UDF or any function
# invoked by the application during data processing (on the Task Managers).
# These libraries cannot be imported at top level or in the main().
import boto3
import botocore

Expand Down

0 comments on commit a64439e

Please sign in to comment.