You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kaxil (via GitHub)" <gi...@apache.org> on 2025/03/28 10:01:31 UTC

[PR] Move bases classes to `airflow.sdk.bases` [airflow]

kaxil opened a new pull request, #48487:
URL: https://github.com/apache/airflow/pull/48487

   These class aren't needed in DAG definition -- not atleast by DAG Authors
   
   This PR moves core base classes to a dedicated `airflow.sdk.bases` module to clarify their intended usage. These classes are internal implementation details and not meant for direct use by DAG authors. They are meant to be used by Providers developer or developer of custom operators.
   
   Key Changes:
   - Created new `airflow.sdk.bases` module
   - Moved base classes:
     - `BaseOperator` -> `airflow.sdk.bases.baseoperator`
     - `BaseSensorOperator` -> `airflow.sdk.bases.sensor`
     - `BaseOperatorLink` -> `airflow.sdk.bases.operatorlink`
     - `BaseNotifier` -> `airflow.sdk.bases.notifier`
     - `XCom` -> `airflow.sdk.bases.xcom`
   
   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #48487:
URL: https://github.com/apache/airflow/pull/48487#issuecomment-2760854623

   Would sdk.base look better? based sounds a little weird too me


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #48487:
URL: https://github.com/apache/airflow/pull/48487#discussion_r2018514608


##########
airflow-core/tests/unit/models/test_xcom.py:
##########
@@ -29,7 +29,7 @@
 from airflow.models.taskinstance import TaskInstance
 from airflow.models.xcom import XComModel
 from airflow.providers.standard.operators.empty import EmptyOperator
-from airflow.sdk.execution_time.xcom import BaseXCom, resolve_xcom_backend
+from airflow.sdk.bases.xcom import BaseXCom, resolve_xcom_backend

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #48487:
URL: https://github.com/apache/airflow/pull/48487#discussion_r2018611288


##########
task-sdk/src/airflow/sdk/execution_time/xcom.py:
##########
@@ -318,7 +26,7 @@ def resolve_xcom_backend():
 
     :returns: returns the custom XCom class if configured.
     """
-    clazz = conf.getimport("core", "xcom_backend", fallback="airflow.sdk.execution_time.xcom.BaseXCom")
+    clazz = conf.getimport("core", "xcom_backend", fallback="airflow.sdk.bases.xcom.BaseXCom")

Review Comment:
   Yeah this look ok :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #48487:
URL: https://github.com/apache/airflow/pull/48487#discussion_r2018331671


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py:
##########
@@ -201,7 +201,7 @@ def test_custom_xcom_deserialize(
         self._create_xcom(TEST_XCOM_KEY, TEST_XCOM_VALUE, backend=XCom)
 
         url = f"/api/v2/dags/{TEST_DAG_ID}/dagRuns/{run_id}/taskInstances/{TEST_TASK_ID}/xcomEntries/{TEST_XCOM_KEY}"
-        with mock.patch("airflow.sdk.execution_time.xcom.XCom", XCom):
+        with mock.patch("airflow.sdk.bases.xcom.XCom", XCom):

Review Comment:
   I agree with this. It doesnt seem right because the XCom is resolved at execution time



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #48487:
URL: https://github.com/apache/airflow/pull/48487#issuecomment-2761175419

   > Would sdk.base look better? based sounds a little weird to me
   
   `sdk.bases` is meant to indicate a collection of base classes. Follows common plural naming patterns (like operators, sensors, etc.).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #48487:
URL: https://github.com/apache/airflow/pull/48487#discussion_r2018328940


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py:
##########
@@ -201,7 +201,7 @@ def test_custom_xcom_deserialize(
         self._create_xcom(TEST_XCOM_KEY, TEST_XCOM_VALUE, backend=XCom)
 
         url = f"/api/v2/dags/{TEST_DAG_ID}/dagRuns/{run_id}/taskInstances/{TEST_TASK_ID}/xcomEntries/{TEST_XCOM_KEY}"
-        with mock.patch("airflow.sdk.execution_time.xcom.XCom", XCom):
+        with mock.patch("airflow.sdk.bases.xcom.XCom", XCom):

Review Comment:
   So this one I'm not sure about.
   
   Having BaseXCom be in bases is fine, but I think the "resolved" backend shouldn't be in there and should remain somewhere in execution_time package



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #48487:
URL: https://github.com/apache/airflow/pull/48487#discussion_r2018329920


##########
airflow-core/tests/unit/models/test_xcom.py:
##########
@@ -29,7 +29,7 @@
 from airflow.models.taskinstance import TaskInstance
 from airflow.models.xcom import XComModel
 from airflow.providers.standard.operators.empty import EmptyOperator
-from airflow.sdk.execution_time.xcom import BaseXCom, resolve_xcom_backend
+from airflow.sdk.bases.xcom import BaseXCom, resolve_xcom_backend

Review Comment:
   Ditto here for `resolve_xcom_backend`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #48487:
URL: https://github.com/apache/airflow/pull/48487#discussion_r2018516742


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py:
##########
@@ -201,7 +201,7 @@ def test_custom_xcom_deserialize(
         self._create_xcom(TEST_XCOM_KEY, TEST_XCOM_VALUE, backend=XCom)
 
         url = f"/api/v2/dags/{TEST_DAG_ID}/dagRuns/{run_id}/taskInstances/{TEST_TASK_ID}/xcomEntries/{TEST_XCOM_KEY}"
-        with mock.patch("airflow.sdk.execution_time.xcom.XCom", XCom):
+        with mock.patch("airflow.sdk.bases.xcom.XCom", XCom):

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #48487:
URL: https://github.com/apache/airflow/pull/48487#issuecomment-2761290583

   > > Would sdk.base look better? based sounds a little weird to me
   > 
   > `sdk.bases` is meant to indicate a collection of base classes. Follows common plural naming patterns (like operators, sensors, etc.).
   
   Yes definitely. It just felt a little odd :) But thats ok


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Move bases classes to `airflow.sdk.bases` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #48487:
URL: https://github.com/apache/airflow/pull/48487


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org