You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2024/12/27 13:27:48 UTC

[PR] Import the trigger module when importing all modules [airflow]

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

   Importing all modules did not include importing trigger module, and this caused strange errors when running tests that never imported Trigger separately.
   
   <!--
    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 [newsfragments](https://github.com/apache/airflow/tree/main/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] Import missing modules when importing all DB models [airflow]

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

   lso it is likely that this one was impacting some other ways Airflow DB is initialized: https://github.com/apache/airflow/discussions/45236


-- 
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] Import missing modules when importing all DB models [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed pull request #45244: Import missing modules when importing all DB models
URL: https://github.com/apache/airflow/pull/45244


-- 
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] Import missing modules when importing all DB models [airflow]

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

   I am not sure if we are missing other models here, but generally, depending on what sequence imports happened our DB scripts could "forget" to create certain tables, and our tests were failing with missing associations if referred DB models were not imported in earlier tests.
   
   This is somewhat a weakness of our "imports" doing a lot of work implicitly (and sometimes forgetting to do it).
   
   


-- 
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] Import missing modules when importing all DB models [airflow]

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

   Nope. It does not help;


-- 
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] Import the trigger module when importing all modules [airflow]

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

   Example errors appearing in xdist tests here: 
   
   https://github.com/apache/airflow/actions/runs/12515046642/job/34913595134?pr=44126#step:7:3627
   
   
   ```
   FAILED providers/tests/openlineage/utils/test_utils.py::test_get_user_provided_run_facets_with_multiple_function_definition - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   FAILED providers/tests/microsoft/azure/triggers/test_msgraph.py::TestMSGraphTrigger::test_run_when_response_is_bytes - AssertionError: assert equals failed
     'failure'  'success'
   FAILED providers/tests/openlineage/utils/test_utils.py::test_get_user_provided_run_facets_with_duplicate_facet_keys - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   FAILED providers/tests/openlineage/utils/test_utils.py::test_get_user_provided_run_facets_with_invalid_function_definition - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   FAILED providers/tests/openlineage/utils/test_utils.py::test_get_user_provided_run_facets_with_wrong_return_type_function - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   FAILED providers/tests/microsoft/azure/triggers/test_msgraph.py::TestMSGraphTrigger::test_serialize - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   FAILED providers/tests/microsoft/azure/triggers/test_powerbi.py::TestPowerBITrigger::test_powerbi_trigger_serialization - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   FAILED providers/tests/openlineage/utils/test_utils.py::test_get_user_provided_run_facets_with_exception - sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class AssetModel->asset'. Original exception was: When initializing mapper mapped class AssetModel->asset, expression 'Trigger' failed to locate a name ('Trigger'). If this is a class name, consider adding this relationship() to the <class 'airflow.models.asset.AssetModel'> class after both dependent classes have been defined.
   ```


-- 
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] Import missing modules when importing all DB models [airflow]

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

   Though @uranusjr @ashb -> I am not sure if this is right - I also saw that there are those __getrr_ calls for all lazy imports, so I am not at all sure if this is the right approach what I am doing - this mechanism of sometimes lazy, sometimes not importing of modules is .... complex ... and I am not sure what the intentions were to have some of the modules lazy and some not... So I am not all sure if what I am doing here is fine.


-- 
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