forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ingest/airflow): compat with pluggy 1.0 (datahub-project#9365)
- Loading branch information
Showing
5 changed files
with
57 additions
and
9 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
35 changes: 31 additions & 4 deletions
35
...a-ingestion-modules/airflow-plugin/src/datahub_airflow_plugin/_datahub_listener_module.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 |
---|---|---|
@@ -1,7 +1,34 @@ | ||
from datahub_airflow_plugin.datahub_listener import get_airflow_plugin_listener | ||
from datahub_airflow_plugin.datahub_listener import ( | ||
get_airflow_plugin_listener, | ||
hookimpl, | ||
) | ||
|
||
_listener = get_airflow_plugin_listener() | ||
if _listener: | ||
on_task_instance_running = _listener.on_task_instance_running | ||
on_task_instance_success = _listener.on_task_instance_success | ||
on_task_instance_failed = _listener.on_task_instance_failed | ||
# The run_in_thread decorator messes with pluggy's interface discovery, | ||
# which causes the hooks to be called with no arguments and results in TypeErrors. | ||
# This is only an issue with Pluggy <= 1.0.0. | ||
# See https://github.com/pytest-dev/pluggy/issues/358 | ||
# Note that pluggy 1.0.0 is in the constraints file for Airflow 2.4 and 2.5. | ||
|
||
@hookimpl | ||
def on_task_instance_running(previous_state, task_instance, session): | ||
assert _listener | ||
_listener.on_task_instance_running(previous_state, task_instance, session) | ||
|
||
@hookimpl | ||
def on_task_instance_success(previous_state, task_instance, session): | ||
assert _listener | ||
_listener.on_task_instance_success(previous_state, task_instance, session) | ||
|
||
@hookimpl | ||
def on_task_instance_failed(previous_state, task_instance, session): | ||
assert _listener | ||
_listener.on_task_instance_failed(previous_state, task_instance, session) | ||
|
||
if hasattr(_listener, "on_dag_run_running"): | ||
|
||
@hookimpl | ||
def on_dag_run_running(dag_run, session): | ||
assert _listener | ||
_listener.on_dag_run_running(dag_run, session) |
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