astronomer.providers.google.cloud.triggers.gcs

Module Contents

Classes

GCSBlobTrigger

A trigger that fires and it finds the requested file or folder present in the given bucket.

GCSPrefixBlobTrigger

A trigger that fires and it looks for all the objects in the given bucket

GCSUploadSessionTrigger

Checks for changes in the number of objects at prefix in Google Cloud Storage

GCSCheckBlobUpdateTimeTrigger

A trigger that makes an async call to GCS to check whether the object is updated in a bucket.

class astronomer.providers.google.cloud.triggers.gcs.GCSBlobTrigger(bucket, object_name, poke_interval, google_cloud_conn_id, hook_params)[source]

Bases: airflow.triggers.base.BaseTrigger

A trigger that fires and it finds the requested file or folder present in the given bucket.

Parameters:
  • bucket (str) – the bucket in the google cloud storage where the objects are residing.

  • object_name (str) – the file or folder present in the bucket

  • google_cloud_conn_id (str) – reference to the Google Connection

  • poke_interval (float) – polling period in seconds to check for file/folder

serialize()[source]

Serializes GCSBlobTrigger arguments and classpath.

async run()[source]

Simple loop until the relevant file/folder is found.

class astronomer.providers.google.cloud.triggers.gcs.GCSPrefixBlobTrigger(bucket, prefix, poke_interval, google_cloud_conn_id, hook_params)[source]

Bases: GCSBlobTrigger

A trigger that fires and it looks for all the objects in the given bucket which matches the given prefix if not found sleep for certain interval and checks again.

Parameters:
  • bucket (str) – the bucket in the google cloud storage where the objects are residing.

  • prefix (str) – The prefix of the blob_names to match in the Google cloud storage bucket

  • google_cloud_conn_id (str) – reference to the Google Connection

  • poke_interval (float) – polling period in seconds to check

serialize()[source]

Serializes GCSPrefixBlobTrigger arguments and classpath.

async run()[source]

Simple loop until the matches are found for the given prefix on the bucket.

class astronomer.providers.google.cloud.triggers.gcs.GCSUploadSessionTrigger(bucket, prefix, poke_interval, google_cloud_conn_id, hook_params, inactivity_period=60 * 60, min_objects=1, previous_objects=None, allow_delete=True)[source]

Bases: GCSPrefixBlobTrigger

Checks for changes in the number of objects at prefix in Google Cloud Storage bucket and returns Trigger Event if the inactivity period has passed with no increase in the number of objects.

Parameters:
  • bucket (str) – The Google Cloud Storage bucket where the objects are. expected.

  • prefix (str) – The name of the prefix to check in the Google cloud storage bucket.

  • poke_interval (float) – polling period in seconds to check

  • inactivity_period (float) – The total seconds of inactivity to designate an upload session is over. Note, this mechanism is not real time and this operator may not return until a interval after this period has passed with no additional objects sensed.

  • min_objects (int) – The minimum number of objects needed for upload session to be considered valid.

  • previous_objects (Optional[Set[str]]) – The set of object ids found during the last poke.

  • allow_delete (bool) – Should this sensor consider objects being deleted between intervals valid behavior. If true a warning message will be logged when this happens. If false an error will be raised.

  • google_cloud_conn_id (str) – The connection ID to use when connecting to Google Cloud Storage.

serialize()[source]

Serializes GCSUploadSessionTrigger arguments and classpath.

async run()[source]

Simple loop until no change in any new files or deleted in list blob is found for the inactivity_period.

class astronomer.providers.google.cloud.triggers.gcs.GCSCheckBlobUpdateTimeTrigger(bucket, object_name, ts, poke_interval, google_cloud_conn_id, hook_params)[source]

Bases: airflow.triggers.base.BaseTrigger

A trigger that makes an async call to GCS to check whether the object is updated in a bucket.

Parameters:
  • bucket (str) – google cloud storage bucket name cloud storage where the objects are residing.

  • object_name (str) – the file or folder present in the bucket

  • ts (datetime.datetime) – datetime object

  • poke_interval (float) – polling period in seconds to check for file/folder

  • google_cloud_conn_id (str) – reference to the Google Connection

  • hook_params (Dict[str, Any]) – DIct object has delegate_to and impersonation_chain

serialize()[source]

Serializes GCSCheckBlobUpdateTimeTrigger arguments and classpath.

async run()[source]

Simple loop until the object updated time is greater than ts datetime in bucket.