Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade usa_names pipeline to use Airflow 2 operators #136

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions datasets/usa_names/usa_1910_current/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ resources:
source: http://www.ssa.gov/OACT/babynames/limits.html

dag:
airflow_version: 2
initialize:
dag_id: "usa_1910_current"
default_args:
Expand Down
8 changes: 4 additions & 4 deletions datasets/usa_names/usa_1910_current/usa_1910_current_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


from airflow import DAG
from airflow.contrib.operators import gcs_to_bq
from airflow.operators import bash_operator
from airflow.operators import bash
from airflow.providers.google.cloud.transfers import gcs_to_bigquery

default_args = {
"owner": "Google",
Expand All @@ -34,7 +34,7 @@
) as dag:

# Task to copy `namesbystate.zip` from Social Security Administration to GCS
download_and_process_source_zip_file = bash_operator.BashOperator(
download_and_process_source_zip_file = bash.BashOperator(
task_id="download_and_process_source_zip_file",
bash_command="mkdir -p $data_dir/{{ ds }}\ncurl -o $data_dir/{{ ds }}/namesbystate.zip -L $zip_source_url\nunzip $data_dir/{{ ds }}/namesbystate.zip -d $data_dir/{{ ds }}\ncat $data_dir/{{ ds }}/*.TXT \u003e\u003e $data_dir/{{ ds }}/data.csv\n",
env={
Expand All @@ -44,7 +44,7 @@
)

# Task to load the data from Airflow data folder to BigQuery
load_csv_file_to_bq_table = gcs_to_bq.GoogleCloudStorageToBigQueryOperator(
load_csv_file_to_bq_table = gcs_to_bigquery.GCSToBigQueryOperator(
task_id="load_csv_file_to_bq_table",
bucket="{{ var.json.shared.composer_bucket }}",
source_objects=["data/usa_names/usa_1910_current/{{ ds }}/data.csv"],
Expand Down