This component lets you run your own Python code directly within Keboola, with support for custom dependencies configured via the UI.
code
: JSON encoded Python code to run.packages
: Array of extra packages to be installed.user_properties
: Object containing custom configuration parameters. The key names prefixed with#
will be encrypted upon saving.
If you're not sure whether you need to install certain package or not, you can run the command uv pip list
via subprocess (see the example below).
import datetime
import subprocess
print("Hello world!")
print("Current date and time:", datetime.datetime.now())
print("See the full list of preinstalled packages:")
subprocess.check_call(["uv", "pip", "list"])
The above code in the config.json
file format for local testing:
{
"parameters": {
"code": "import datetime\nimport subprocess\n\nprint(\"Hello world!\")\nprint(\"Current date and time:\", datetime.datetime.now())\nprint(\"See the full list of preinstalled packages:\")\n\nsubprocess.check_call([\"uv\", \"pip\", \"list\"])\n",
"packages": []
}
}
Note: The code to access user parameters is pre-populated in every new configuration.
from keboola.component import CommonInterface
ci = CommonInterface()
# access user parameters
print(ci.configuration.parameters)
The above code in the config.json
file format for local testing:
{
"parameters": {
"code": "from keboola.component import CommonInterface\n\nci = CommonInterface()\n# access user parameters\nprint(ci.configuration.parameters)",
"packages": [],
"user_properties": {
"debug": false
"#secretCredentials": "theStrongestPasswordEver"
}
}
}
If needed, update the local data folder path by replacing the CUSTOM_FOLDER
placeholder in the docker-compose.yml
file:
volumes:
- ./:/code
- ./CUSTOM_FOLDER:/data
Clone the repository, initialize the workspace, and run the component using the following commands:
git clone [email protected]:keboola/component-custom-python.git
cd component-custom-python
docker compose build
docker compose up dev
To run the test suite and perform a lint check, use:
docker compose up test
For details on deployment and integration with Keboola, refer to the deployment section of the developer documentation.