You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/07 11:15:12 UTC

[GitHub] [airflow] kaxil commented on a diff in pull request #22808: Add example DAG for demonstrating usage of GCS sensors

kaxil commented on code in PR #22808:
URL: https://github.com/apache/airflow/pull/22808#discussion_r845012678


##########
airflow/example_dags/example_gcs.py:
##########
@@ -0,0 +1,74 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+This is an example dag for demonstrating usage of GCS sensors.
+"""
+import os
+from datetime import timedelta
+
+import pendulum
+
+from airflow import DAG
+from airflow.providers.google.cloud.sensors.gcs import GCSUploadSessionCompleteSensor, GCSObjectUpdateSensor
+
+TEST_BUCKET = os.getenv("GCP_TEST_BUCKET", "test-gcs-bucket")
+GCP_CONN_ID = os.getenv("GCP_CONN_ID", "google_cloud_default")
+
+# Upload example_test.txt in the <TEST_BUCKET> after triggering the DAG.
+BUCKET_FILE_LOCATION = "example_test.txt"
+
+# This is the upload file name prefix the sensor will be waiting for.
+PATH_TO_UPLOAD_FILE_PREFIX = "example_"
+
+DEFAULT_ARGS = {
+    "execution_timeout": timedelta(minutes=30),
+}
+
+with DAG(
+    "example_gcs_sensors",
+    start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
+    schedule_interval=None,
+    catchup=False,
+    default_args=DEFAULT_ARGS,
+    tags=["example", "gcs"],
+) as dag:

Review Comment:
   ```suggestion
   with DAG(
       "example_gcs_sensors",
       start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
       schedule_interval=None,
       catchup=False,
       default_args={
           "execution_timeout": timedelta(minutes=30),
       },
       tags=["example", "gcs"],
   ) as dag:
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org