roboto.domain.actions.trigger#

Module Contents#

class roboto.domain.actions.trigger.Trigger(record, roboto_client=None)#

A rule that automatically invokes an action when specific events or conditions occur.

Triggers enable automated data processing workflows by monitoring for specific events (like new datasets being created) and automatically invoking actions when conditions are met. They eliminate the need for manual intervention in routine data processing tasks.

Triggers can be configured to:

  • Monitor for new datasets, files, or other data sources

  • Apply conditional logic to determine when to execute

  • Specify input data patterns and action parameters

  • Override compute requirements and container parameters

  • Execute actions for each matching item or in batch

A trigger consists of:

  • Target action to invoke

  • Input data requirements and patterns

  • Execution conditions and causes

  • Parameter values and overrides

  • Scheduling and execution settings

Parameters:
property condition: roboto.query.ConditionType | None#
Return type:

Optional[roboto.query.ConditionType]

classmethod create(name, action_name, required_inputs, for_each, enabled=True, action_digest=None, action_owner_id=None, additional_inputs=None, causes=None, compute_requirement_overrides=None, condition=None, container_parameter_overrides=None, parameter_values=None, service_user_id=None, timeout=None, caller_org_id=None, roboto_client=None)#

Create a new trigger that automatically invokes an action when conditions are met.

Creates a trigger that monitors for specific events (like new datasets or files) and automatically invokes the specified action when the trigger conditions are satisfied. This enables automated data processing workflows.

Parameters:
  • name (str) – Unique name for the trigger within the organization.

  • action_name (str) – Name of the action to invoke when the trigger fires.

  • required_inputs (list[str]) – List of file patterns that must be present for the trigger to fire. Uses glob patterns like “**/.bag” or “data/.csv”.

  • for_each (roboto.domain.actions.trigger_record.TriggerForEachPrimitive) – Granularity of execution - Dataset creates one invocation per dataset, DatasetFile creates one invocation per matching file.

  • enabled (bool) – Whether the trigger should be active immediately after creation.

  • action_digest (Optional[str]) – Specific version digest of the action to invoke. If not provided, uses the latest version.

  • action_owner_id (Optional[str]) – Organization ID that owns the target action. If not provided, searches in the caller’s organization.

  • additional_inputs (Optional[list[str]]) – Optional additional file patterns to include in invocations.

  • causes (Optional[list[roboto.domain.actions.trigger_record.TriggerEvaluationCause]]) – List of events that can cause this trigger to be evaluated. If not provided, uses default causes.

  • compute_requirement_overrides (Optional[roboto.domain.actions.invocation_record.ComputeRequirements]) – Optional compute requirement overrides for action invocations.

  • condition (Optional[roboto.query.ConditionType]) – Optional condition that must be met for the trigger to fire. Can filter based on metadata, file properties, etc.

  • container_parameter_overrides (Optional[roboto.domain.actions.invocation_record.ContainerParameters]) – Optional container parameter overrides for action invocations.

  • parameter_values (Optional[dict[str, Any]]) – Parameter values to pass to the action when invoked.

  • service_user_id (Optional[str]) – Optional service user ID for authentication.

  • timeout (Optional[int]) – Optional timeout override for action invocations in minutes.

  • caller_org_id (Optional[str]) – Organization ID to create the trigger in. Defaults to caller’s org.

  • roboto_client (Optional[roboto.http.RobotoClient]) – Roboto client instance. Uses default if not provided.

Returns:

The newly created Trigger instance.

Raises:
Return type:

Trigger

Examples

Create a simple trigger for ROS bag files:

>>> from roboto.domain.actions import Trigger, TriggerForEachPrimitive
>>> trigger = Trigger.create(
...     name="auto_process_bags",
...     action_name="ros_ingestion",
...     required_inputs=["**/*.bag"],
...     for_each=TriggerForEachPrimitive.Dataset
... )

Create a conditional trigger with parameters:

>>> from roboto.query import Condition
>>> condition = Condition("metadata.sensor_type").equals("lidar")
>>> trigger = Trigger.create(
...     name="lidar_processing",
...     action_name="lidar_processor",
...     required_inputs=["**/*.pcd"],
...     for_each=TriggerForEachPrimitive.Dataset,
...     condition=condition,
...     parameter_values={"resolution": "high", "filter": "statistical"}
... )

Create a trigger with compute overrides:

>>> from roboto.domain.actions import ComputeRequirements
>>> trigger = Trigger.create(
...     name="heavy_processing",
...     action_name="ml_inference",
...     required_inputs=["**/*.jpg", "**/*.png"],
...     for_each=TriggerForEachPrimitive.DatasetFile,
...     compute_requirement_overrides=ComputeRequirements(vCPU=8192, memory=16384)
... )
property created: datetime.datetime#
Return type:

datetime.datetime

property created_by: str#
Return type:

str

delete()#
disable()#
enable()#
property enabled: bool#
Return type:

bool

property for_each: roboto.domain.actions.trigger_record.TriggerForEachPrimitive#
Return type:

roboto.domain.actions.trigger_record.TriggerForEachPrimitive

classmethod from_name(name, owner_org_id=None, roboto_client=None)#
Parameters:
Return type:

Trigger

get_action()#
Return type:

roboto.domain.actions.action.Action

get_evaluations(limit=None, page_token=None)#
Parameters:
  • limit (Optional[int])

  • page_token (Optional[str])

Return type:

collections.abc.Generator[roboto.domain.actions.trigger_record.TriggerEvaluationRecord, None, None]

static get_evaluations_for_dataset(dataset_id, owner_org_id=None, roboto_client=None)#

Get all trigger evaluations for a specific dataset.

Retrieves the history of trigger evaluations that were performed for a given dataset, including successful invocations and failed attempts.

Parameters:
  • dataset_id (str) – The ID of the dataset to get evaluations for.

  • owner_org_id (Optional[str]) – Organization ID that owns the dataset. If not provided, searches in the caller’s organization.

  • roboto_client (Optional[roboto.http.RobotoClient]) – Roboto client instance. Uses default if not provided.

Yields:

TriggerEvaluationRecord instances for the dataset.

Raises:
Return type:

collections.abc.Generator[roboto.domain.actions.trigger_record.TriggerEvaluationRecord, None, None]

Examples

Get all evaluations for a dataset:

>>> for evaluation in Trigger.get_evaluations_for_dataset("ds_12345"):
...     print(f"Trigger: {evaluation.trigger_name}, Status: {evaluation.status}")

Check if any triggers succeeded for a dataset:

>>> from roboto.domain.actions import TriggerEvaluationStatus
>>> evaluations = list(Trigger.get_evaluations_for_dataset("ds_12345"))
>>> successful = [e for e in evaluations if e.status == TriggerEvaluationStatus.Succeeded]
>>> print(f"Found {len(successful)} successful trigger evaluations")
get_invocations()#
Return type:

collections.abc.Generator[roboto.domain.actions.invocation.Invocation, None, None]

invoke(data_source, idempotency_id=None, input_data_override=None, upload_destination=None)#
Parameters:
Return type:

Optional[roboto.domain.actions.invocation.Invocation]

latest_evaluation()#
Return type:

Optional[roboto.domain.actions.trigger_record.TriggerEvaluationRecord]

property modified: datetime.datetime#
Return type:

datetime.datetime

property modified_by: str#
Return type:

str

property name#
property org_id#
classmethod query(spec=None, owner_org_id=None, roboto_client=None)#
Parameters:
Return type:

collections.abc.Generator[Trigger, None, None]

property record: roboto.domain.actions.trigger_record.TriggerRecord#
Return type:

roboto.domain.actions.trigger_record.TriggerRecord

property service_user_id: str | None#
Return type:

Optional[str]

to_dict()#
Return type:

dict[str, Any]

property trigger_id: str#
Return type:

str

update(action_name=NotSet, action_owner_id=NotSet, action_digest=NotSet, additional_inputs=NotSet, causes=NotSet, compute_requirement_overrides=NotSet, container_parameter_overrides=NotSet, condition=NotSet, enabled=NotSet, for_each=NotSet, parameter_values=NotSet, required_inputs=NotSet, timeout=NotSet)#
Parameters:
Return type:

Trigger

wait_for_evaluations_to_complete(timeout=60 * 5, poll_interval=5)#

Wait for all evaluations for this trigger to complete.

Throws a TimeoutError if the timeout is reached.

Parameters:
  • timeout (float) – The maximum amount of time, in seconds, to wait for the evaluations to complete.

  • poll_interval (roboto.waiters.Interval) – The amount of time, in seconds, to wait between polling iterations.

Return type:

None