Skip to main content

CAIP Runtime library

While the caip-sdk provides a cli and python library to manage pipelines and agents, it can not be used inside an agent or pipeline container. The caip-runtime library serves that purpose. It provides modules for repeated tasks that occur inside different pipeline steps such as logging or config management.

!!! Notice

The caip-runtime is still new (as of 2025-05) watch out for changes and new features being added soon.

How to install

caip-runtime is available via artifactory. To install it follow the installation guide for caip-sdk and add the following lines to your pyproject.toml (for uv, for poetry see the example in the installation guide):

pyproject.toml
dependencies = [
"caip-runtime>=4.8.6",
...
]

[tool.uv.sources]
caip-runtime = { index = "caip-artifactory" }

!!! Important

Make sure that the version of caip-sdk and caip-runtime always match. They are released together and we do not guarantee compatibility between different versions.

Pipeline logging

An overview which steps you have to take to enable the CDLS integration for your caip cluster can be found in our handbook. Afterwards you can use the functions of the runtime library. If you don't need a collection of your logs through CDLS you can still use the runtime to enable logging and specify the format.

Formatting the logs with the Logging Annotation

The @pipeline_logging_config annotation of a method enables the logging for the operations performed in the container i.e func_to_container_op. It provides convenient way to specify logging level and formatting. Previously the annotation was implemented redundantly for each pipeline, which is now streamlined and provided as part of caip_runtime_library. It can be imported as shown below:

from caip_runtime.pipeline_logging.json_formatter import FormatterType, pipeline_logging_config

The usage remains similar to earlier implementation with the addition of the optional formatter_type argument. If FormatterType.CDLS is used than, the required configuration values for CDLS are needed as well:

@pipeline_logging_config(formatter_type=FormatterType.CDLS,
cdls_app_id="<CDLS Application ID>",
environment=caip().env.stage,
region=caip().env.region)

Additionally, In the method annotated with @pipeline_logging_config, the constant CAIP_RUNTIME_LIB has to be specified in the packages_to_install list as shown:

from caip_runtime.constants import CAIP_RUNTIME_LIB
packages_to_install=[..., CAIP_RUNTIME_LIB],

It will install the caip_runtime_library, which contains the logging implementation, in the container and simplify the logging.

Forwarding the logs to CDLS with the helper function

Additionally to formatting the logs correctly you need to provide a few annotations to the pipeline step so the logs are forwarded.

from caip_sdk.api import caip
from caip_sdk.api.helpers import prepare_for_cdls
...
hello_world_step = None #your pipeline operation
prepare_for_cdls(hello_world_step, cdls_app_id="caip-mlmodel", caip_client=caip())