Created
June 16, 2022 12:40
-
-
Save mesmacosta/1f485d50dbfc851103f2a1f49646e7f2 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 datetime import datetime, timedelta | |
from airflow.models import DAG | |
from airflow.operators.python import PythonOperator | |
from airflow.utils.session import provide_session | |
from alvin_integration.producers.airflow.pipeline.extractor import extract_dag_metadata | |
seven_days_ago = datetime.combine( | |
datetime.today() - timedelta(1), datetime.min.time() | |
) # noqa | |
args = { | |
"owner": "airflow", | |
"start_date": seven_days_ago, | |
} | |
@provide_session | |
def extract_metadata(session): | |
"""Extract metadata from DAG and send to Alvin Backend API.""" | |
extract_dag_metadata(session) | |
alvin_metadata_extractor = DAG( | |
dag_id="alvin_metadata_extractor", | |
default_args=args, | |
schedule_interval="@hourly", | |
catchup=False, | |
) # noqa | |
task_success_one = PythonOperator( | |
task_id="dag_metadata_extractor", | |
provide_context=True, | |
python_callable=extract_metadata, | |
dag=alvin_metadata_extractor, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment