Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@

This component lets you run your own Python code directly within Keboola, with support for custom dependencies configured via the UI.


## Configuration

- `code`: JSON encoded Python code to run.
- `packages`: List of extra packages to be installed.

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).


### Example: Listing preinstalled packages

```py
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"])
```

```json
{
"parameters": {
Expand All @@ -19,8 +34,33 @@ If you're not sure whether you need to install certain package or not, you can r
```


Development
-----------
### Example: Accessing custom configuration parameters

*Note: The code to access user parameters is pre-populated in every new configuration.*

```py
from keboola.component import CommonInterface

ci = CommonInterface()
# access user parameters
print(ci.configuration.parameters)
```

```json
{
"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"
}
}
}
```


## Development

If needed, update the local data folder path by replacing the `CUSTOM_FOLDER` placeholder in the `docker-compose.yml` file:

Expand All @@ -45,8 +85,8 @@ To run the test suite and perform a lint check, use:
docker compose up test
```

Integration
===========

## Integration

For details on deployment and integration with Keboola, refer to the
[deployment section of the developer
Expand Down
2 changes: 1 addition & 1 deletion component_config/configSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "string",
"title": "Python code",
"format": "editor",
"default": "from keboola.component import CommonInterface\nci = CommonInterface()\n# access user parameters\nprint(ci.configuration.parameters)",
"default": "from keboola.component import CommonInterface\n\nci = CommonInterface()\n# access user parameters\nprint(ci.configuration.parameters)",
"options": {
"editor": {
"mode": "text/x-python",
Expand Down