Skip to content

Lifecycle

The lifecycle kind runs a task when a monitored entity reaches one of the configured states.

Lifecycle spec

The lifecycle kind has the following specification parameters.

Parameter Type Description Default
task str Task to execute. required
template dict Configuration template for the run. {}
function str | None Function to execute. Provide this or workflow. None
workflow str | None Workflow to execute. Provide this or function. None
key str Entity key to monitor. It can include wildcards such as *. required
states list[str] States of the monitored entity that trigger execution. required

Create

New

new_trigger

Create a new trigger entity in the backend.

Parameters:

Name Type Description Default
project str

Project name.

required
name str

Entity name.

required
kind str

Entity kind.

required
task str

Task reference.

required
function str

Function reference. Provide either function or workflow.

None
workflow str

Workflow reference. Provide either workflow or function. If both are provided, the workflow is used.

None
uuid str

Entity identifier.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
template dict

Trigger template. If omitted, a template is built from task and the selected executable reference.

None
**kwargs dict

Additional entity specification parameters.

{}

Returns:

Type Description
Trigger

Created trigger entity.

import digitalhub as dh

trigger = dh.new_trigger(
    project="my-project",
    name="model-complete",
    kind="lifecycle",
    task="store://my-project/task/my-task:latest",
    function="store://my-project/function/my-function:latest",
    key="store://my-project/model/*",
    states=["COMPLETED"],
)

Methods

The lifecycle kind adds no instance methods. See Use a trigger for common methods.

Back to trigger kind selection