Skip to content

Enabling triggers from cloud-based function platforms

Most cloud providers offer a serverless function platform, such as Lambda in AWS, Cloud Functions in the Google Cloud Platform or Functions in Azure. These functions can be used to execute code based on events in services of those cloud providers, such as when new data is published in streaming solutions or when files are added to blob storage.

Using these functions and triggers, you can automatically push data to deployments or pipelines when new data or files become available by sending a request to the UbiOps API from the function.

An example script for making a pipeline request using the UbiOps Python client library, in a Google Cloud Functions script while reading messages from a Google Cloud Pub/Sub topic, could look as follows:

import base64
import ubiops

def ubiops_request(event, context):
    Triggered from a message on a Cloud Pub/Sub topic.

    :param dict event: Event payload.
    :param context: Metadata for the event.

    pubsub_message = base64.b64decode(event['data']).decode('utf-8')

    configuration = ubiops.Configuration()
    configuration.api_key['Authorization'] = 'Token abcdefghijklmnopqrstuvwxyz'

    client = ubiops.ApiClient(configuration)
    api = ubiops.api.CoreApi(client)
    api.pipeline_requests_create('test-project', 'test-pipeline', pubsub_message)

To see more extensive examples, see our Tutorials page.