Python runtime
The python runtime allows you to run generic python function.
The runtime introduces a function of kind python
and three task of kind job
, serve
and build
.
With job
action you can run a python function as a job.
With serve
action you can run a python function as a service.
With build
action you build a docker image with all the dependencies and reuse that container to run the function avoiding the overhead of dependencies installation during the runtime.
Prerequisites
Python version and libraries:
python >= 3.9
digitalhub-runtime-python
The package is available on PyPI:
Overwiew
With the python runtime you can use the function's run()
method to execute a python function you have defined.
The python runtime execution workflow follows roughly these steps:
- Define somewhere a python function.
- Create a
Function
object in the platform and execute the function'srun()
method. - The runtime collects the inputs specified in the function as SDK objects (
Dataitem
,Artifact
,Model
). - It fetches the function source code and import the function handler.
- It composes the parameters for the handler function.
- It executes the function and map the outputs as SDK objects or as simple results.
User HOWTO
As delined in the description of the runtime workflow, to execute a python function the user should proceed with the following three steps:
- Write the function to execute.
- Create a
Function
object. - Execute the function's
run()
method.
You can jump now on function definition.