Created
September 21, 2021 02:23
-
-
Save momota10s/8f4543c1e710a1f7b971cbd7473d76d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from airflow import DAG | |
from airflow.models import Variable | |
from airflow.utils.dates import days_ago | |
from airflow.contrib.operators.pubsub_operator import ( | |
PubSubPublishOperator, | |
PubSubSubscriptionCreateOperator, | |
PubSubSubscriptionDeleteOperator, | |
PubSubTopicCreateOperator, | |
PubSubTopicDeleteOperator | |
) | |
from airflow.contrib.sensors.pubsub_sensor import PubSubPullSensor | |
PROJECT_ID = "your-project" | |
DAG_NAME = "sample-pubsub" | |
PUBSUB_MSG = { | |
'attributes': {"name": "momota"} | |
} | |
default_args = { | |
"start_date": days_ago(0), | |
} | |
with DAG( | |
DAG_NAME, | |
schedule_interval=None, | |
catchup=False, | |
default_args=default_args | |
) as dag: | |
task_exec_training_model = PubSubPublishOperator( | |
task_id="publish-task", | |
project=PROJECT_ID, | |
topic="test-topic", | |
messages=[PUBSUB_MSG], | |
create_topic=False, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment