Skip to content

Commit

Permalink
feat: Upgrade usa_names pipeline to usse Airflow 2 operators and en…
Browse files Browse the repository at this point in the history
…vironment (#136)
  • Loading branch information
adlersantos committed Aug 9, 2021
1 parent 268530f commit ea76661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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

0 comments on commit ea76661

Please sign in to comment.