-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:go-bazzinga/ds-dags
- Loading branch information
Showing
2 changed files
with
90 additions
and
40 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from airflow import DAG | ||
from airflow.providers.google.cloud.operators.bigquery import ( | ||
BigQueryExecuteQueryOperator, | ||
BigQueryGetDataOperator, | ||
) | ||
from airflow.operators.python_operator import PythonOperator | ||
from airflow.providers.google.cloud.hooks.gcs import GCSHook | ||
from airflow.contrib.hooks.bigquery_hook import BigQueryHook | ||
from airflow.utils.dates import days_ago | ||
from datetime import datetime, timedelta | ||
import requests | ||
|
||
default_args = { | ||
"owner": "airflow", | ||
"retries": 0, | ||
# "depends_on_past": True, | ||
} | ||
|
||
|
||
with DAG( | ||
"gcs_to_bigquery_metadata_dag", | ||
default_args=default_args, | ||
description="DAG for metadata enrichment", | ||
schedule_interval=None, | ||
max_active_runs=1, # Ensures only one active run at a time | ||
start_date=days_ago(1), | ||
catchup=False, | ||
) as dag: | ||
|
||
def enrich_metadata(**kwargs): | ||
hook = GCSHook() | ||
print(dir(hook)) | ||
obj_list = hook.list("yral-videos") | ||
|
||
for obj_mp4 in obj_list[:10]: | ||
print(obj_mp4) | ||
obj = hook.get_metadata("yral-videos", obj_mp4) | ||
print(obj) | ||
|
||
enrich_objects = PythonOperator( | ||
task_id="enrich_objects", | ||
provide_context=True, | ||
python_callable=enrich_metadata, | ||
) | ||
|
||
(enrich_objects) |