Skip to content

Commit f111699

Browse files
committed
feat(airflow): drop Airflow < 2.3 support + make plugin v2 the default
1 parent 46aa962 commit f111699

File tree

7 files changed

+25
-30
lines changed

7 files changed

+25
-30
lines changed

.github/workflows/airflow-plugin.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,20 @@ jobs:
3434
include:
3535
# Note: this should be kept in sync with tox.ini.
3636
- python-version: "3.8"
37-
extra_pip_requirements: "apache-airflow~=2.1.4"
38-
extra_pip_extras: plugin-v1
39-
- python-version: "3.8"
40-
extra_pip_requirements: "apache-airflow~=2.2.4"
41-
extra_pip_extras: plugin-v1
37+
extra_pip_requirements: "apache-airflow~=2.3.4 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.3.4/constraints-3.8.txt"
4238
- python-version: "3.10"
4339
extra_pip_requirements: "apache-airflow~=2.4.3"
44-
extra_pip_extras: plugin-v2,test-airflow24
40+
extra_pip_extras: test-airflow24
4541
- python-version: "3.10"
4642
extra_pip_requirements: "apache-airflow~=2.6.3 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.6.3/constraints-3.10.txt"
47-
extra_pip_extras: plugin-v2
4843
- python-version: "3.10"
4944
extra_pip_requirements: "apache-airflow~=2.7.3 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.7.3/constraints-3.10.txt"
50-
extra_pip_extras: plugin-v2
5145
- python-version: "3.10"
5246
extra_pip_requirements: "apache-airflow~=2.8.1 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.8.1/constraints-3.10.txt"
53-
extra_pip_extras: plugin-v2
5447
- python-version: "3.11"
5548
extra_pip_requirements: "apache-airflow~=2.9.3 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.9.3/constraints-3.11.txt"
56-
extra_pip_extras: plugin-v2
5749
- python-version: "3.11"
58-
extra_pip_requirements: "apache-airflow~=2.10.2 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.11.txt"
59-
extra_pip_extras: plugin-v2
50+
extra_pip_requirements: "apache-airflow~=2.10.3 -c https://raw.githubusercontent.com/apache/airflow/constraints-2.10.3/constraints-3.11.txt"
6051
fail-fast: false
6152
steps:
6253
- name: Set up JDK 17

docs/how/updating-datahub.md

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ This file documents any backwards-incompatible changes in DataHub and assists pe
3535

3636
- #11701: The Fivetran `sources_to_database` field is deprecated in favor of setting directly within `sources_to_platform_instance.<key>.database`.
3737
- #11742: For PowerBi ingestion, `use_powerbi_email` is now enabled by default when extracting ownership information.
38+
- #TODO: The DataHub Airflow plugin no longer supports Airflow 2.1 and Airflow 2.2.
39+
- #TODO: The DataHub Airflow plugin now defaults to the v2 plugin implementation.
3840

3941
### Breaking Changes
4042

metadata-ingestion-modules/airflow-plugin/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (!project.hasProperty("extra_pip_requirements")) {
1313
ext.extra_pip_requirements = ""
1414
}
1515
if (!project.hasProperty("extra_pip_extras")) {
16-
ext.extra_pip_extras = "plugin-v2"
16+
ext.extra_pip_extras = ""
1717
}
1818
// If extra_pip_extras is non-empty, we need to add a comma to the beginning of the string.
1919
if (extra_pip_extras != "") {

metadata-ingestion-modules/airflow-plugin/setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def get_long_description():
2424

2525
base_requirements = {
2626
f"acryl-datahub[datahub-rest]{_self_pin}",
27-
# Actual dependencies.
28-
"apache-airflow >= 2.0.2",
27+
# We require Airflow 2.3.x, since we need the new DAG listener API.
28+
"apache-airflow>=2.3.0",
2929
}
3030

3131
plugins: Dict[str, Set[str]] = {
@@ -48,8 +48,9 @@ def get_long_description():
4848
},
4949
}
5050

51-
# Include datahub-rest in the base requirements.
51+
# Require some plugins by default.
5252
base_requirements.update(plugins["datahub-rest"])
53+
base_requirements.update(plugins["plugin-v2"])
5354

5455

5556
mypy_stubs = {

metadata-ingestion-modules/airflow-plugin/src/datahub_airflow_plugin/datahub_listener.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def hookimpl(f: _F) -> _F: # type: ignore[misc] # noqa: F811
7474
"1",
7575
)
7676
_RUN_IN_THREAD_TIMEOUT = float(
77-
os.getenv("DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT", 15)
77+
os.getenv("DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT", 10)
7878
)
7979
_DATAHUB_CLEANUP_DAG = "Datahub_Cleanup"
8080

@@ -102,6 +102,7 @@ def get_airflow_plugin_listener() -> Optional["DataHubListener"]:
102102
"capture_tags": plugin_config.capture_tags_info,
103103
"capture_ownership": plugin_config.capture_ownership_info,
104104
"enable_extractors": plugin_config.enable_extractors,
105+
"render_templates": plugin_config.render_templates,
105106
"disable_openlineage_plugin": plugin_config.disable_openlineage_plugin,
106107
},
107108
)

metadata-ingestion-modules/airflow-plugin/tests/integration/test_plugin.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import time
1313
from typing import Any, Iterator, Sequence
1414

15+
import packaging.version
1516
import pytest
1617
import requests
1718
import tenacity
@@ -20,6 +21,7 @@
2021
from datahub.testing.compare_metadata_json import assert_metadata_files_equal
2122

2223
from datahub_airflow_plugin._airflow_shims import (
24+
AIRFLOW_VERSION,
2325
HAS_AIRFLOW_DAG_LISTENER_API,
2426
HAS_AIRFLOW_LISTENER_API,
2527
HAS_AIRFLOW_STANDALONE_CMD,
@@ -36,6 +38,8 @@
3638

3739
DAG_TO_SKIP_INGESTION = "dag_to_skip"
3840

41+
TEST_V1_PLUGIN = AIRFLOW_VERSION < packaging.version.parse("2.4.0")
42+
3943

4044
@dataclasses.dataclass
4145
class AirflowInstance:
@@ -242,6 +246,7 @@ def _run_airflow(
242246
# Note that we could also disable the RUN_IN_THREAD entirely,
243247
# but I want to minimize the difference between CI and prod.
244248
"DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT": "30",
249+
"DATAHUB_AIRFLOW_PLUGIN_USE_V1_PLUGIN": "true" if is_v1 else "false",
245250
# Convenience settings.
246251
"AIRFLOW__DATAHUB__LOG_LEVEL": "DEBUG",
247252
"AIRFLOW__DATAHUB__DEBUG_EMITTER": "True",
@@ -361,15 +366,14 @@ class DagTestCase:
361366
@pytest.mark.parametrize(
362367
["golden_filename", "test_case", "is_v1"],
363368
[
364-
# On Airflow <= 2.2, test plugin v1.
365369
*[
366370
pytest.param(
367371
f"v1_{test_case.dag_id}",
368372
test_case,
369373
True,
370374
id=f"v1_{test_case.dag_id}",
371375
marks=pytest.mark.skipif(
372-
HAS_AIRFLOW_LISTENER_API,
376+
not TEST_V1_PLUGIN,
373377
reason="Not testing plugin v1 on newer Airflow versions",
374378
),
375379
)

metadata-ingestion-modules/airflow-plugin/tox.ini

+7-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py38-airflow21, py38-airflow22, py310-airflow24, py310-airflow26, py310-airflow27, py310-airflow28, py311-airflow29, py311-airflow210
7+
envlist = py38-airflow23, py310-airflow24, py310-airflow26, py310-airflow27, py310-airflow28, py311-airflow29, py311-airflow210
88

99
[testenv]
1010
use_develop = true
11-
extras = dev,integration-tests,plugin-v1
11+
extras = dev,integration-tests,plugin-v1,plugin-v2
1212
deps =
1313
# This should be kept in sync with the Github Actions matrix.
1414
-e ../../metadata-ingestion/
1515
# Airflow version
16-
airflow21: apache-airflow~=2.1.0
17-
airflow22: apache-airflow~=2.2.0
16+
airflow23: apache-airflow~=2.3.0
1817
airflow24: apache-airflow~=2.4.0
1918
airflow26: apache-airflow~=2.6.0
2019
airflow27: apache-airflow~=2.7.0
@@ -24,14 +23,15 @@ deps =
2423

2524
# Respect the Airflow constraints files.
2625
# We can't make ourselves work with the constraints of Airflow < 2.3.
26+
py38-airflow23: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.3.4/constraints-3.8.txt
2727
# The Airflow 2.4 constraints file requires a version of the sqlite provider whose
2828
# hook type is missing the `conn_name_attr` property.
2929
; py310-airflow24: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.4.3/constraints-3.10.txt
3030
py310-airflow26: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.6.3/constraints-3.10.txt
3131
py310-airflow27: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.7.3/constraints-3.10.txt
3232
py310-airflow28: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.8.1/constraints-3.10.txt
3333
py311-airflow29: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.9.3/constraints-3.11.txt
34-
py311-airflow210: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.11.txt
34+
py311-airflow210: -c https://raw.githubusercontent.com/apache/airflow/constraints-2.10.3/constraints-3.11.txt
3535

3636
# Before pinning to the constraint files, we previously left the dependencies
3737
# more open. There were a number of packages for which this caused issues.
@@ -55,10 +55,6 @@ deps =
5555
commands =
5656
pytest --cov-append {posargs}
5757

58-
# For Airflow 2.4+, add the plugin-v2 extra.
58+
# For Airflow 2.4, add a few extra requirements.
5959
[testenv:py310-airflow24]
60-
extras = dev,integration-tests,plugin-v2,test-airflow24
61-
62-
[testenv:py3{10,11}-airflow{26,27,28,29,210}]
63-
extras = dev,integration-tests,plugin-v2
64-
60+
extras = dev,integration-tests,plugin-v1,plugin-v2,test-airflow24

0 commit comments

Comments
 (0)