Skip to content

Use a function

The Function object can execute code and manage its related tasks and triggers.

Persist and refresh

save

Save the entity into the backend.

Returns:

Type Description
ContextEntity

Entity saved.

export

Export object as a YAML file in the context folder.

Returns:

Type Description
str

Exported filepath.

refresh

Refresh object from backend.

Returns:

Type Description
ContextEntity

Entity refreshed.

Run

Use run() to execute a function. Its keyword arguments are passed to the run builder, including inputs, parameters, and runtime-specific options.

run

Run function. This method creates a new run and executes it.

Parameters:

Name Type Description Default
action str

Action to execute.

required
wait bool

Flag to wait for execution.

False
log_info bool

Flag to log information while waiting.

True
extensions list[dict] | None

List of extensions to apply.

None
**kwargs dict

Keyword arguments passed to Run builder.

{}

Returns:

Type Description
Run

Run instance.

Manage tasks

The Function object exposes methods to create, retrieve, list, update, and delete its tasks.

new_task

Create and persist a task for an executable action.

Parameters:

Name Type Description Default
action str

Action implemented by the task.

required
**kwargs dict

Task construction parameters.

{}

Returns:

Type Description
Task

Created task.

Raises:

Type Description
EntityError

If a task already exists for the action or the action is not supported.

get_task

Get the task associated with an executable action.

Parameters:

Name Type Description Default
action str

Action implemented by the task.

required

Returns:

Type Description
Task

Associated task.

Raises:

Type Description
EntityError

If no task exists for the action or the action is not supported.

list_task

List tasks associated with the executable.

Parameters:

Name Type Description Default
q str

Free-text query.

None
name str

Task name filter.

None
kind str

Task kind filter.

None
user str

Task owner filter.

None
state str

Task state filter.

None
created str

Creation date filter.

None
updated str

Update date filter.

None

Returns:

Type Description
list[Task]

Tasks matching the filters.

import_tasks

Import tasks and associate matching ones with the executable.

Parameters:

Name Type Description Default
tasks list[dict]

Serialized tasks to import.

required
update_task

Update the task associated with an executable action.

Parameters:

Name Type Description Default
action str

Action implemented by the task.

required
**kwargs dict

Updated task construction parameters.

{}

Returns:

Type Description
Task

Updated task.

Raises:

Type Description
EntityError

If no task exists for the action or the action is not supported.

set_task

Create or replace the task associated with an executable action.

Parameters:

Name Type Description Default
action str

Action implemented by the task.

required
**kwargs dict

Task construction parameters.

{}

Returns:

Type Description
Task

Created or replaced task.

Raises:

Type Description
EntityError

If the action is not supported.

delete_task

Delete the task associated with an executable action.

Parameters:

Name Type Description Default
action str

Action implemented by the task.

required
cascade bool

Whether to delete dependent entities.

True

Returns:

Type Description
dict

Backend deletion response.

Manage triggers

The Function object exposes methods to create, retrieve, and list its triggers.

trigger

Create and persist a trigger for an executable action.

Parameters:

Name Type Description Default
action str

Executable action invoked by the trigger.

required
kind str

Trigger kind.

required
name str

Trigger name.

required
template dict

Run template associated with the trigger.

None
**kwargs dict

Trigger construction parameters.

{}

Returns:

Type Description
Trigger

Created trigger.

Raises:

Type Description
EntityError

If the template is invalid or the action is not supported.

get_trigger

Get a trigger belonging to the executable.

Parameters:

Name Type Description Default
identifier str

Trigger ID or key.

required

Returns:

Type Description
Trigger

Matching trigger.

Raises:

Type Description
EntityError

If the trigger does not exist or belongs to another executable.

list_triggers

List triggers associated with the executable.

Parameters:

Name Type Description Default
q str

Free-text query.

None
name str

Trigger name filter.

None
kind str

Trigger kind filter.

None
user str

Trigger owner filter.

None
created str

Creation date filter.

None
updated str

Update date filter.

None
versions str

Version selection filter.

None
task str

Task reference filter.

None

Returns:

Type Description
list[Trigger]

Triggers matching the filters.

Kind-specific methods

Methods specific to a function kind are documented in the reference documentation for the corresponding runtime.