-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(airflow): add
DatahubRestHook.make_graph
method (#12116)
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...-modules/airflow-plugin/src/datahub_airflow_plugin/example_dags/graph_usage_sample_dag.py
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,35 @@ | ||
"""This example DAG demonstrates how to create and use a DataHubGraph client.""" | ||
|
||
from datetime import timedelta | ||
|
||
import pendulum | ||
from airflow.decorators import dag, task | ||
from datahub.ingestion.graph.client import DataHubGraph, RemovedStatusFilter | ||
|
||
from datahub_airflow_plugin.hooks.datahub import DatahubRestHook | ||
|
||
|
||
@dag( | ||
schedule_interval=timedelta(days=1), | ||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"), | ||
catchup=False, | ||
) | ||
def datahub_graph_usage_sample_dag(): | ||
@task() | ||
def use_the_graph(): | ||
graph: DataHubGraph = DatahubRestHook("my_datahub_rest_conn_id").make_graph() | ||
graph.test_connection() | ||
|
||
# Example usage: Find all soft-deleted BigQuery DEV entities | ||
# in DataHub, and hard delete them. | ||
for urn in graph.get_urns_by_filter( | ||
platform="bigquery", | ||
env="DEV", | ||
status=RemovedStatusFilter.ONLY_SOFT_DELETED, | ||
): | ||
graph.hard_delete_entity(urn) | ||
|
||
use_the_graph() | ||
|
||
|
||
datahub_graph_usage_sample_dag() |
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