Once you have started to understand Pykechain (Python SDK for KE-chain) and build your own scripts, the next step is how to add them to KE-chain. The easiest answer is through kecpkg-tools, a python package developed with the purpose of making the building and uploading of scripts easier and faster. Below, you will find a small tutorial on how to use kecpkg-tools. The tutorial is shown in Windows 10, however, we will be using the Git Bash command line, which is Linux-based. Not shown in this tutorial is the creation of a virtual environment called venv_kecpkg Please be aware of the fact that you do require some basic knowledge of programming in order to follow this tutorial.
First you need to install kecpkg-tools. Activate your virtual environment and run the pip install kecpkg-tools command, as shown in the video below.
Create a new KECpkg
Afterwards, you need to run kecpkg new command. This will prompt you to give a new package name, set the python version you would like to use and choose a few other options. Once this is completed, you will have a new package ready to be filled in with a script.
You will see that the package has been created at the location you desired. Use the file script.py to write your script in. Once you are positive the script will run correctly, it is time to build and upload the package to KE-chain. First run the kecpkg build command. This will build the package based on the settings you provided in the previous step. Then, you can run kecpkg upload, which will prompt you to provide an url, authentication credentials and project (scope) id.
Use a KECpkg (script) in KE-chain templates
You can now go to the project where the kecpkg has been uploaded and you can now use it inside a script widget (see: Sjablonen aanpassen).