This is an example repository showing how you can use a custom Git repository for passing your own code into Keboola's Custom Python Component (CPC).
As the main source file in this repo is located right in the root directory, importing other source files works as expected both when developing locally and when ran using CPC.
For your convenience, the data/user_parameters.json file can have exactly the same contents that you will later be able to place in the User Parameters field in CPC configuration, so you can just copy-paste it. Because of that, we prepared a super simple script, which will convert this file to the structure expected by Keboola's base Python Component (which is used internally in CPC to handle Keboola Common Interface) for you.
The keboola.component
package is listed in the pyproject.toml file just as a dev dependency, because CPC already includes it. This example uses Astral's brilliant uv tool for package management, so when adding more dependencies to your project:
- Use
uv add
for adding runtime dependencies (these will be installed when running the project via CPC). - Use
uv add --dev
for adding development dependencies (these won't be installed in CPC).
When you have Docker installed, the easiest way to run this example is using docker compose
:
docker compose build # voluntary when running for the 1st time
docker compose up
This way, the configuration and source files are always updated during the build, which shall be done before you can say blueberry pie.
For running this code locally without Docker, follow these steps:
# 🧑🔧 prepare the config.json file
data/_create_config_json.sh data/user_parameters.json data/config.json
# 💜 create virtual environment and install dependencies
uv sync
# 🚀 run
uv run main.py
will be added later on