You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2025/06/29 09:33:25 UTC

(airflow) branch main updated: Replace `models.BaseOperator` to Task SDK one for Apache TinkerPop (#52400)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 50e69abdaa6 Replace `models.BaseOperator` to Task SDK one for Apache TinkerPop (#52400)
50e69abdaa6 is described below

commit 50e69abdaa63b8ecb368fe319813fe9774a2e9b5
Author: Farhan <52...@users.noreply.github.com>
AuthorDate: Sun Jun 29 10:33:19 2025 +0100

    Replace `models.BaseOperator` to Task SDK one for Apache TinkerPop (#52400)
    
    Follow-up of #52292 for Apache TinkerPop
---
 .../tests/unit/always/test_project_structure.py    |  1 +
 .../apache/tinkerpop/operators/gremlin.py          |  2 +-
 .../providers/apache/tinkerpop/version_compat.py   | 37 ++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/airflow-core/tests/unit/always/test_project_structure.py b/airflow-core/tests/unit/always/test_project_structure.py
index 31e6d64b6b3..fbe8434730f 100644
--- a/airflow-core/tests/unit/always/test_project_structure.py
+++ b/airflow-core/tests/unit/always/test_project_structure.py
@@ -96,6 +96,7 @@ class TestProjectStructure:
             "providers/apache/livy/tests/unit/apache/livy/test_version_compat.py",
             "providers/apache/pig/tests/unit/apache/pig/test_version_compat.py",
             "providers/apache/spark/tests/unit/apache/spark/test_version_compat.py",
+            "providers/apache/tinkerpop/tests/unit/apache/tinkerpop/test_version_compat.py",
             "providers/arangodb/tests/unit/arangodb/test_version_compat.py",
             "providers/asana/tests/unit/asana/test_version_compat.py",
             "providers/atlassian/jira/tests/unit/atlassian/jira/test_version_compat.py",
diff --git a/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/operators/gremlin.py b/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/operators/gremlin.py
index f7064890d5d..7a38a220d97 100644
--- a/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/operators/gremlin.py
+++ b/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/operators/gremlin.py
@@ -18,8 +18,8 @@ from __future__ import annotations
 
 from typing import TYPE_CHECKING, Any
 
-from airflow.models import BaseOperator
 from airflow.providers.apache.tinkerpop.hooks.gremlin import GremlinHook
+from airflow.providers.apache.tinkerpop.version_compat import BaseOperator
 
 if TYPE_CHECKING:
     try:
diff --git a/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/version_compat.py b/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/version_compat.py
new file mode 100644
index 00000000000..9e99cafacaf
--- /dev/null
+++ b/providers/apache/tinkerpop/src/airflow/providers/apache/tinkerpop/version_compat.py
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+
+def get_base_airflow_version_tuple() -> tuple[int, int, int]:
+    from packaging.version import Version
+
+    from airflow import __version__
+
+    airflow_version = Version(__version__)
+    return airflow_version.major, airflow_version.minor, airflow_version.micro
+
+
+AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
+
+if AIRFLOW_V_3_0_PLUS:
+    from airflow.sdk import BaseOperator
+else:
+    from airflow.models import BaseOperator
+
+__all__ = ["AIRFLOW_V_3_0_PLUS", "BaseOperator"]